Update puddle stickiness (#16597)

This commit is contained in:
Slava0135
2023-06-03 22:34:43 +03:00
committed by GitHub
parent 10932cc384
commit d3f7a9e820
4 changed files with 45 additions and 34 deletions

View File

@@ -1,5 +1,4 @@
using Content.Shared.Movement.Components;
using Robust.Shared.GameStates;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Events;
using Robust.Shared.Physics.Systems;
@@ -21,9 +20,6 @@ public sealed class SlowContactsSystem : EntitySystem
SubscribeLocalEvent<SlowContactsComponent, EndCollideEvent>(OnEntityExit);
SubscribeLocalEvent<SlowedByContactComponent, RefreshMovementSpeedModifiersEvent>(MovementSpeedCheck);
SubscribeLocalEvent<SlowContactsComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<SlowContactsComponent, ComponentGetState>(OnGetState);
UpdatesAfter.Add(typeof(SharedPhysicsSystem));
}
@@ -46,18 +42,20 @@ public sealed class SlowContactsSystem : EntitySystem
_toUpdate.Clear();
}
private void OnGetState(EntityUid uid, SlowContactsComponent component, ref ComponentGetState args)
public void ChangeModifiers(EntityUid uid, float speed, SlowContactsComponent? component = null)
{
args.State = new SlowContactsComponentState(component.WalkSpeedModifier, component.SprintSpeedModifier);
ChangeModifiers(uid, speed, speed, component);
}
private void OnHandleState(EntityUid uid, SlowContactsComponent component, ref ComponentHandleState args)
public void ChangeModifiers(EntityUid uid, float walkSpeed, float sprintSpeed, SlowContactsComponent? component = null)
{
if (args.Current is not SlowContactsComponentState state)
if (!Resolve(uid, ref component))
{
return;
component.WalkSpeedModifier = state.WalkSpeedModifier;
component.SprintSpeedModifier = state.SprintSpeedModifier;
}
component.WalkSpeedModifier = walkSpeed;
component.SprintSpeedModifier = sprintSpeed;
Dirty(component);
}
private void MovementSpeedCheck(EntityUid uid, SlowedByContactComponent component, RefreshMovementSpeedModifiersEvent args)