Mirror speed penalty for worn duffels and hardsuits when in-hand (#22168)

* Add speed penalty for holding hardsuits and duffels

* just inherit from ClothingSpeedModifier

* comment godo
This commit is contained in:
Nemanja
2023-12-06 22:41:29 -05:00
committed by GitHub
parent 6509681f00
commit fb10dff335
11 changed files with 150 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
using Content.Shared.Hands.Components;
using Content.Shared.Movement.Systems;
namespace Content.Shared.Hands.EntitySystems;
public abstract partial class SharedHandsSystem
{
private void InitializeRelay()
{
SubscribeLocalEvent<HandsComponent, RefreshMovementSpeedModifiersEvent>(RelayEvent);
}
private void RelayEvent<T>(Entity<HandsComponent> entity, ref T args) where T : EntityEventArgs
{
var ev = new HeldRelayedEvent<T>(args);
foreach (var held in EnumerateHeld(entity, entity.Comp))
{
RaiseLocalEvent(held, ref ev);
}
}
}

View File

@@ -31,6 +31,7 @@ public abstract partial class SharedHandsSystem
InitializeDrop();
InitializePickup();
InitializeVirtual();
InitializeRelay();
}
public override void Shutdown()

View File

@@ -319,4 +319,15 @@ namespace Content.Shared.Hands
public EntityUid Sender { get; }
}
[ByRefEvent]
public sealed class HeldRelayedEvent<TEvent> : EntityEventArgs
{
public TEvent Args;
public HeldRelayedEvent(TEvent args)
{
Args = args;
}
}
}