Fix Whoopie Cushions from lagging the game. (#39194)
This commit is contained in:
committed by
GitHub
parent
2b8145ce87
commit
ce7b7c1adf
@@ -194,6 +194,16 @@ public sealed class MovementModStatusSystem : EntitySystem
|
|||||||
return TryUpdateMovementStatus(uid, status, speedModifier, speedModifier);
|
return TryUpdateMovementStatus(uid, status, speedModifier, speedModifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="TryAddFrictionModDuration(EntityUid,TimeSpan,float,float)"/>
|
||||||
|
public bool TryAddFrictionModDuration(
|
||||||
|
EntityUid uid,
|
||||||
|
TimeSpan duration,
|
||||||
|
float friction
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return TryAddFrictionModDuration(uid, duration, friction, friction);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Apply friction modifier with provided duration,
|
/// Apply friction modifier with provided duration,
|
||||||
/// or incrementing duration of existing.
|
/// or incrementing duration of existing.
|
||||||
@@ -210,8 +220,18 @@ public sealed class MovementModStatusSystem : EntitySystem
|
|||||||
float acceleration
|
float acceleration
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return _status.TryAddStatusEffectDuration(uid, StatusEffectFriction, out var status, duration)
|
return _status.TryAddStatusEffectDuration(uid, StatusEffectFriction, out var status, duration)
|
||||||
&& TrySetFrictionStatus(status.Value, friction, acceleration, uid);
|
&& TrySetFrictionStatus(status.Value, friction, acceleration, uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="TryUpdateFrictionModDuration(EntityUid,TimeSpan,float,float)"/>
|
||||||
|
public bool TryUpdateFrictionModDuration(
|
||||||
|
EntityUid uid,
|
||||||
|
TimeSpan duration,
|
||||||
|
float friction
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return TryUpdateFrictionModDuration(uid,duration, friction, friction);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -30,10 +30,18 @@ public sealed class SlipperySystem : EntitySystem
|
|||||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||||
[Dependency] private readonly SpeedModifierContactsSystem _speedModifier = default!;
|
[Dependency] private readonly SpeedModifierContactsSystem _speedModifier = default!;
|
||||||
|
|
||||||
|
private EntityQuery<KnockedDownComponent> _knockedDownQuery;
|
||||||
|
private EntityQuery<PhysicsComponent> _physicsQuery;
|
||||||
|
private EntityQuery<SlidingComponent> _slidingQuery;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
|
_knockedDownQuery = GetEntityQuery<KnockedDownComponent>();
|
||||||
|
_physicsQuery = GetEntityQuery<PhysicsComponent>();
|
||||||
|
_slidingQuery = GetEntityQuery<SlidingComponent>();
|
||||||
|
|
||||||
SubscribeLocalEvent<SlipperyComponent, StepTriggerAttemptEvent>(HandleAttemptCollide);
|
SubscribeLocalEvent<SlipperyComponent, StepTriggerAttemptEvent>(HandleAttemptCollide);
|
||||||
SubscribeLocalEvent<SlipperyComponent, StepTriggeredOffEvent>(HandleStepTrigger);
|
SubscribeLocalEvent<SlipperyComponent, StepTriggeredOffEvent>(HandleStepTrigger);
|
||||||
SubscribeLocalEvent<NoSlipComponent, SlipAttemptEvent>(OnNoSlipAttempt);
|
SubscribeLocalEvent<NoSlipComponent, SlipAttemptEvent>(OnNoSlipAttempt);
|
||||||
@@ -92,7 +100,8 @@ public sealed class SlipperySystem : EntitySystem
|
|||||||
|
|
||||||
public void TrySlip(EntityUid uid, SlipperyComponent component, EntityUid other, bool requiresContact = true)
|
public void TrySlip(EntityUid uid, SlipperyComponent component, EntityUid other, bool requiresContact = true)
|
||||||
{
|
{
|
||||||
if (HasComp<KnockedDownComponent>(other) && !component.SlipData.SuperSlippery)
|
var knockedDown = _knockedDownQuery.HasComp(other);
|
||||||
|
if (knockedDown && !component.SlipData.SuperSlippery)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var attemptEv = new SlipAttemptEvent(uid);
|
var attemptEv = new SlipAttemptEvent(uid);
|
||||||
@@ -111,7 +120,7 @@ public sealed class SlipperySystem : EntitySystem
|
|||||||
var ev = new SlipEvent(other);
|
var ev = new SlipEvent(other);
|
||||||
RaiseLocalEvent(uid, ref ev);
|
RaiseLocalEvent(uid, ref ev);
|
||||||
|
|
||||||
if (TryComp(other, out PhysicsComponent? physics) && !HasComp<SlidingComponent>(other))
|
if (_physicsQuery.TryComp(other, out var physics) && !_slidingQuery.HasComp(other))
|
||||||
{
|
{
|
||||||
_physics.SetLinearVelocity(other, physics.LinearVelocity * component.SlipData.LaunchForwardsMultiplier, body: physics);
|
_physics.SetLinearVelocity(other, physics.LinearVelocity * component.SlipData.LaunchForwardsMultiplier, body: physics);
|
||||||
|
|
||||||
@@ -120,16 +129,23 @@ public sealed class SlipperySystem : EntitySystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Preventing from playing the slip sound and stunning when you are already knocked down.
|
// Preventing from playing the slip sound and stunning when you are already knocked down.
|
||||||
if (!HasComp<KnockedDownComponent>(other))
|
if (!knockedDown)
|
||||||
{
|
{
|
||||||
|
// Status effects should handle a TimeSpan of 0 properly...
|
||||||
_stun.TryUpdateStunDuration(other, component.SlipData.StunTime);
|
_stun.TryUpdateStunDuration(other, component.SlipData.StunTime);
|
||||||
_stamina.TakeStaminaDamage(other, component.StaminaDamage); // Note that this can stamCrit
|
|
||||||
_movementMod.TryUpdateFrictionModDuration(
|
// Don't make a new status effect entity if the entity wouldn't do anything
|
||||||
other,
|
if (!MathHelper.CloseTo(component.SlipData.SlipFriction, 1f))
|
||||||
component.FrictionStatusTime,
|
{
|
||||||
component.SlipData.SlipFriction,
|
_movementMod.TryUpdateFrictionModDuration(
|
||||||
component.SlipData.SlipFriction
|
other,
|
||||||
);
|
component.FrictionStatusTime,
|
||||||
|
component.SlipData.SlipFriction
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_stamina.TakeStaminaDamage(other, component.StaminaDamage); // Note that this can StamCrit
|
||||||
|
|
||||||
_audio.PlayPredicted(component.SlipSound, other, other);
|
_audio.PlayPredicted(component.SlipSound, other, other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,13 @@ public sealed partial class StatusEffectsSystem
|
|||||||
TimeSpan duration
|
TimeSpan duration
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if (duration == TimeSpan.Zero)
|
||||||
|
{
|
||||||
|
statusEffect = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We check to make sure time is greater than zero here because sometimes you want to use TryAddStatusEffect to remove duration instead...
|
||||||
if (!TryGetStatusEffect(target, effectProto, out statusEffect))
|
if (!TryGetStatusEffect(target, effectProto, out statusEffect))
|
||||||
return TryAddStatusEffect(target, effectProto, out statusEffect, duration);
|
return TryAddStatusEffect(target, effectProto, out statusEffect, duration);
|
||||||
|
|
||||||
@@ -53,6 +60,12 @@ public sealed partial class StatusEffectsSystem
|
|||||||
TimeSpan? duration = null
|
TimeSpan? duration = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if (duration <= TimeSpan.Zero)
|
||||||
|
{
|
||||||
|
statusEffect = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!TryGetStatusEffect(target, effectProto, out statusEffect))
|
if (!TryGetStatusEffect(target, effectProto, out statusEffect))
|
||||||
return TryAddStatusEffect(target, effectProto, out statusEffect, duration);
|
return TryAddStatusEffect(target, effectProto, out statusEffect, duration);
|
||||||
|
|
||||||
@@ -83,6 +96,12 @@ public sealed partial class StatusEffectsSystem
|
|||||||
TimeSpan? duration = null
|
TimeSpan? duration = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if (duration <= TimeSpan.Zero)
|
||||||
|
{
|
||||||
|
statusEffect = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!TryGetStatusEffect(target, effectProto, out statusEffect))
|
if (!TryGetStatusEffect(target, effectProto, out statusEffect))
|
||||||
return TryAddStatusEffect(target, effectProto, out statusEffect, duration);
|
return TryAddStatusEffect(target, effectProto, out statusEffect, duration);
|
||||||
|
|
||||||
|
|||||||
@@ -202,6 +202,10 @@ public sealed partial class StatusEffectsSystem : EntitySystem
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
statusEffect = null;
|
statusEffect = null;
|
||||||
|
|
||||||
|
if (duration <= TimeSpan.Zero)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!CanAddStatusEffect(target, effectProto))
|
if (!CanAddStatusEffect(target, effectProto))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -911,6 +911,7 @@
|
|||||||
delay: 0.8
|
delay: 0.8
|
||||||
- type: Slippery
|
- type: Slippery
|
||||||
staminaDamage: 0
|
staminaDamage: 0
|
||||||
|
frictionStatusTime: 0
|
||||||
slipData:
|
slipData:
|
||||||
stunTime: 0
|
stunTime: 0
|
||||||
knockdownTime: 0
|
knockdownTime: 0
|
||||||
|
|||||||
Reference in New Issue
Block a user