mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
# Description This is a very simple and apparently minor update to the Carrying System, bringing it up to date with more modern code. The biggest difference is that rather than having a private one-off implementation of one of the original Nyano MassContest functions, it uses the new public Reworked MassContests. With this change, pick up durations no longer infinitely scale with arbitrary mass, meaning that a hypothetical 2000kg Lamia doesn't have an arbitrarily infinitesimal pickup duration when trying to pick up a 10kg Harpy. Carrying is also more strictly limited by mass, rather than by carrying duration, meaning that if a target character is more than 25% heavier than your character, it will not be possible to shoulder them. You'll just have to either drag them, or get a roller bed to move overly massive characters. The last thing I did was just cleanup all of the code, so that has nice, Single-IF exit conditions, rather than 30+ line blocks of IF(THING) RETURN; Oh, and entities can now set their own internal base PickupDuration, so that entities can declare however easy or difficult they should be to pick up! # MEDIA https://github.com/user-attachments/assets/9ee0f1dd-ac75-406f-8bbd-9a130594d46d # Changelog 🆑 - tweak: The Carrying system has been reworked as a means of better supporting having extremely large species and characters. 10kg Harpies should no longer be oppressed by 2000kg Lamia with infinitely short carry attempts.
47 lines
1.9 KiB
C#
47 lines
1.9 KiB
C#
using Content.Shared.Movement.Systems;
|
|
using Robust.Shared.GameStates;
|
|
|
|
namespace Content.Shared.Carrying
|
|
{
|
|
public sealed class CarryingSlowdownSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeed = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<CarryingSlowdownComponent, ComponentGetState>(OnGetState);
|
|
SubscribeLocalEvent<CarryingSlowdownComponent, ComponentHandleState>(OnHandleState);
|
|
SubscribeLocalEvent<CarryingSlowdownComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMoveSpeed);
|
|
}
|
|
|
|
public void SetModifier(EntityUid uid, float walkSpeedModifier, float sprintSpeedModifier, CarryingSlowdownComponent? component = null)
|
|
{
|
|
if (!Resolve(uid, ref component))
|
|
return;
|
|
|
|
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 not CarryingSlowdownComponentState state)
|
|
return;
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|