StunnableComponent cleanup, proper prediction for stuns and slips. (#3552)
This commit is contained in:
committed by
GitHub
parent
0ad70d62ec
commit
6c77801d90
@@ -7,6 +7,8 @@ using Content.Shared.Audio;
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
using Content.Shared.GameObjects.Components.Mobs.State;
|
||||
using Content.Shared.GameObjects.Components.Movement;
|
||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||
using Content.Shared.GameObjects.EntitySystems.EffectBlocker;
|
||||
using Content.Shared.Interfaces;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -29,17 +31,23 @@ namespace Content.Server.GameObjects.Components.Mobs
|
||||
EntitySystem.Get<StandingStateSystem>().Down(Owner);
|
||||
}
|
||||
|
||||
protected override void OnKnockdownEnd()
|
||||
{
|
||||
if(Owner.TryGetComponent(out IMobStateComponent? mobState) && !mobState.IsIncapacitated())
|
||||
EntitySystem.Get<StandingStateSystem>().Standing(Owner);
|
||||
}
|
||||
|
||||
public void CancelAll()
|
||||
{
|
||||
KnockdownTimer = 0f;
|
||||
StunnedTimer = 0f;
|
||||
KnockdownTimer = null;
|
||||
StunnedTimer = null;
|
||||
Dirty();
|
||||
}
|
||||
|
||||
public void ResetStuns()
|
||||
{
|
||||
StunnedTimer = 0f;
|
||||
SlowdownTimer = 0f;
|
||||
StunnedTimer = null;
|
||||
SlowdownTimer = null;
|
||||
|
||||
if (KnockedDown &&
|
||||
Owner.TryGetComponent(out IMobStateComponent? mobState) && !mobState.IsIncapacitated())
|
||||
@@ -47,85 +55,16 @@ namespace Content.Server.GameObjects.Components.Mobs
|
||||
EntitySystem.Get<StandingStateSystem>().Standing(Owner);
|
||||
}
|
||||
|
||||
KnockdownTimer = 0f;
|
||||
KnockdownTimer = null;
|
||||
Dirty();
|
||||
}
|
||||
|
||||
public void Update(float delta)
|
||||
{
|
||||
if (Stunned)
|
||||
{
|
||||
StunnedTimer -= delta;
|
||||
|
||||
if (StunnedTimer <= 0)
|
||||
{
|
||||
StunnedTimer = 0f;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
if (KnockedDown)
|
||||
{
|
||||
KnockdownTimer -= delta;
|
||||
|
||||
if (KnockdownTimer <= 0f
|
||||
&& Owner.TryGetComponent(out IMobStateComponent? mobState) && !mobState.IsIncapacitated())
|
||||
{
|
||||
EntitySystem.Get<StandingStateSystem>().Standing(Owner);
|
||||
|
||||
KnockdownTimer = 0f;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
if (SlowedDown)
|
||||
{
|
||||
SlowdownTimer -= delta;
|
||||
|
||||
if (SlowdownTimer <= 0f)
|
||||
{
|
||||
SlowdownTimer = 0f;
|
||||
|
||||
if (Owner.TryGetComponent(out MovementSpeedModifierComponent? movement))
|
||||
{
|
||||
movement.RefreshMovementSpeedModifiers();
|
||||
}
|
||||
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
if (!StunStart.HasValue || !StunEnd.HasValue ||
|
||||
!Owner.TryGetComponent(out ServerAlertsComponent? status))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var start = StunStart.Value;
|
||||
var end = StunEnd.Value;
|
||||
|
||||
var length = (end - start).TotalSeconds;
|
||||
var progress = (_gameTiming.CurTime - start).TotalSeconds;
|
||||
|
||||
if (progress >= length)
|
||||
{
|
||||
Owner.SpawnTimer(250, () => status.ClearAlert(AlertType.Stun), StatusRemoveCancellation.Token);
|
||||
LastStun = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnInteractHand()
|
||||
{
|
||||
EntitySystem.Get<AudioSystem>()
|
||||
.PlayFromEntity("/Audio/Effects/thudswoosh.ogg", Owner, AudioHelpers.WithVariation(0.05f));
|
||||
}
|
||||
|
||||
public override ComponentState GetComponentState(ICommonSession player)
|
||||
{
|
||||
return new StunnableComponentState(StunnedTimer, KnockdownTimer, SlowdownTimer, WalkModifierOverride,
|
||||
RunModifierOverride);
|
||||
}
|
||||
|
||||
bool IDisarmedAct.Disarmed(DisarmedActEventArgs eventArgs)
|
||||
{
|
||||
if (!IoCManager.Resolve<IRobustRandom>().Prob(eventArgs.PushProbability))
|
||||
|
||||
Reference in New Issue
Block a user