фикс системы таскания

This commit is contained in:
Remuchi
2024-03-27 16:56:45 +07:00
parent ad78f747c1
commit 8514b94683
10 changed files with 357 additions and 395 deletions

View File

@@ -1,47 +1,35 @@
using Content.Shared.DoAfter;
using Content.Shared.Movement.Systems;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.Carrying
namespace Content.Shared._White.Carrying;
public sealed class CarryingSlowdownSystem : EntitySystem
{
public sealed class CarryingSlowdownSystem : EntitySystem
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeed = default!;
public override void Initialize()
{
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeed = default!;
base.Initialize();
SubscribeLocalEvent<CarryingSlowdownComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMoveSpeed);
}
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CarryingSlowdownComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<CarryingSlowdownComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<CarryingSlowdownComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMoveSpeed);
}
public void SetModifier(EntityUid uid, CarryingSlowdownComponent? component = null)
{
if (!Resolve(uid, ref component))
return;
public void SetModifier(EntityUid uid, float walkSpeedModifier, float sprintSpeedModifier, CarryingSlowdownComponent? component = null)
{
if (!Resolve(uid, ref component))
return;
_movementSpeed.RefreshMovementSpeedModifiers(uid);
}
component.WalkModifier = walkSpeedModifier;
component.SprintModifier = sprintSpeedModifier;
_movementSpeed.RefreshMovementSpeedModifiers(uid);
}
private void OnGetState(EntityUid uid, CarryingSlowdownComponent component, ref ComponentGetState args)
{
args.State = new CarryingSlowdownComponentState(component.WalkModifier, component.SprintModifier);
}
private void OnHandleState(EntityUid uid, CarryingSlowdownComponent component, ref ComponentHandleState args)
{
if (args.Current is CarryingSlowdownComponentState state)
{
component.WalkModifier = state.WalkModifier;
component.SprintModifier = state.SprintModifier;
_movementSpeed.RefreshMovementSpeedModifiers(uid);
}
}
private void OnRefreshMoveSpeed(EntityUid uid, CarryingSlowdownComponent component, RefreshMovementSpeedModifiersEvent args)
{
args.ModifySpeed(component.WalkModifier, component.SprintModifier);
}
private void OnRefreshMoveSpeed(
EntityUid uid,
CarryingSlowdownComponent component,
RefreshMovementSpeedModifiersEvent args)
{
args.ModifySpeed(component.WalkModifier, component.SprintModifier);
}
}
[Serializable, NetSerializable]
public sealed partial class CarryDoAfterEvent : SimpleDoAfterEvent;