Throwing item scaling animation + recoil (#24724)

This commit is contained in:
Kara
2024-01-30 03:50:41 -07:00
committed by GitHub
parent aa806c306c
commit ef55039560
4 changed files with 109 additions and 53 deletions

View File

@@ -36,41 +36,10 @@ namespace Content.Shared.Throwing
SubscribeLocalEvent<ThrownItemComponent, PreventCollideEvent>(PreventCollision);
SubscribeLocalEvent<ThrownItemComponent, ThrownEvent>(ThrowItem);
SubscribeLocalEvent<ThrownItemComponent, EntityUnpausedEvent>(OnThrownUnpaused);
SubscribeLocalEvent<ThrownItemComponent, ComponentGetState>(OnThrownGetState);
SubscribeLocalEvent<ThrownItemComponent, ComponentHandleState>(OnThrownHandleState);
SubscribeLocalEvent<PullStartedMessage>(HandlePullStarted);
}
private void OnThrownGetState(EntityUid uid, ThrownItemComponent component, ref ComponentGetState args)
{
// TODO: Throwing needs to handle this properly I just want the bad asserts to stop getting in my way.
TryGetNetEntity(component.Thrower, out var nent);
args.State = new ThrownItemComponentState()
{
ThrownTime = component.ThrownTime,
LandTime = component.LandTime,
Thrower = nent,
Landed = component.Landed,
PlayLandSound = component.PlayLandSound,
};
}
private void OnThrownHandleState(EntityUid uid, ThrownItemComponent component, ref ComponentHandleState args)
{
if (args.Current is not ThrownItemComponentState state)
return;
TryGetEntity(state.Thrower, out var thrower);
component.ThrownTime = state.ThrownTime;
component.LandTime = state.LandTime;
component.Thrower = thrower;
component.Landed = state.Landed;
component.PlayLandSound = state.PlayLandSound;
}
private void OnMapInit(EntityUid uid, ThrownItemComponent component, MapInitEvent args)
{
component.ThrownTime ??= _gameTiming.CurTime;