--- /dev/null
+using Content.Shared.Clothing;
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Item;
+
+/// <summary>
+/// This is used for items that change your speed when they are held.
+/// </summary>
+/// <remarks>
+/// This is separate from <see cref="ClothingSpeedModifierComponent"/> because things like boots increase/decrease speed when worn, but
+/// shouldn't do that when just held in hand.
+/// </remarks>
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
+[Access(typeof(HeldSpeedModifierSystem))]
+public sealed partial class HeldSpeedModifierComponent : Component
+{
+ /// <summary>
+ /// A multiplier applied to the walk speed.
+ /// </summary>
+ [DataField] [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
+ public float WalkModifier = 1.0f;
+
+ /// <summary>
+ /// A multiplier applied to the sprint speed.
+ /// </summary>
+ [DataField] [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
+ public float SprintModifier = 1.0f;
+
+ /// <summary>
+ /// If true, values from <see cref="ClothingSpeedModifierComponent"/> will attempted to be used before the ones in this component.
+ /// </summary>
+ [DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
+ public bool MirrorClothingModifier = true;
+}
--- /dev/null
+using Content.Shared.Clothing;
+using Content.Shared.Hands;
+using Content.Shared.Movement.Systems;
+
+namespace Content.Shared.Item;
+
+/// <summary>
+/// This handles <see cref="HeldSpeedModifierComponent"/>
+/// </summary>
+public sealed class HeldSpeedModifierSystem : EntitySystem
+{
+ [Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!;
+
+ /// <inheritdoc/>
+ public override void Initialize()
+ {
+ SubscribeLocalEvent<HeldSpeedModifierComponent, GotEquippedHandEvent>(OnGotEquippedHand);
+ SubscribeLocalEvent<HeldSpeedModifierComponent, GotUnequippedHandEvent>(OnGotUnequippedHand);
+ SubscribeLocalEvent<HeldSpeedModifierComponent, HeldRelayedEvent<RefreshMovementSpeedModifiersEvent>>(OnRefreshMovementSpeedModifiers);
+ }
+
+ private void OnGotEquippedHand(Entity<HeldSpeedModifierComponent> ent, ref GotEquippedHandEvent args)
+ {
+ _movementSpeedModifier.RefreshMovementSpeedModifiers(args.User);
+ }
+
+ private void OnGotUnequippedHand(Entity<HeldSpeedModifierComponent> ent, ref GotUnequippedHandEvent args)
+ {
+ _movementSpeedModifier.RefreshMovementSpeedModifiers(args.User);
+ }
+
+ private void OnRefreshMovementSpeedModifiers(EntityUid uid, HeldSpeedModifierComponent component, HeldRelayedEvent<RefreshMovementSpeedModifiersEvent> args)
+ {
+ var walkMod = component.WalkModifier;
+ var sprintMod = component.SprintModifier;
+ if (component.MirrorClothingModifier && TryComp<ClothingSpeedModifierComponent>(uid, out var clothingSpeedModifier))
+ {
+ walkMod = clothingSpeedModifier.WalkModifier;
+ sprintMod = clothingSpeedModifier.SprintModifier;
+ }
+
+ args.Args.ModifySpeed(walkMod, sprintMod);
+ }
+}
- type: ClothingSpeedModifier
walkModifier: 0.80
sprintModifier: 0.80
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitBasic
- type: ClothingSpeedModifier
walkModifier: 0.7
sprintModifier: 0.7
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitAtmos
- type: ClothingSpeedModifier
walkModifier: 0.7
sprintModifier: 0.7
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitEngineering
- type: ClothingSpeedModifier
walkModifier: 0.9
sprintModifier: 0.8
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitSpatio
- type: ClothingSpeedModifier
walkModifier: 0.75
sprintModifier: 0.75
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitSalvage
- type: ClothingSpeedModifier
walkModifier: 0.75
sprintModifier: 0.75
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitSecurity
- type: ClothingSpeedModifier
walkModifier: 0.65
sprintModifier: 0.65
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitBrigmedic
- type: ClothingSpeedModifier
walkModifier: 0.7
sprintModifier: 0.7
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitWarden
- type: ClothingSpeedModifier
walkModifier: 0.8
sprintModifier: 0.8
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitCap
- type: ClothingSpeedModifier
walkModifier: 0.75
sprintModifier: 0.8
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitEngineeringWhite
- type: ClothingSpeedModifier
walkModifier: 0.9
sprintModifier: 0.95
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitMedical
- type: ClothingSpeedModifier
walkModifier: 0.75
sprintModifier: 0.75
+ - type: HeldSpeedModifier
- type: Item
size: Normal
- type: Tag
- type: ClothingSpeedModifier
walkModifier: 0.8
sprintModifier: 0.8
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitSecurityRed
- type: ClothingSpeedModifier
walkModifier: 0.85
sprintModifier: 0.9
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitLuxury
- type: ClothingSpeedModifier
walkModifier: 0.9
sprintModifier: 0.9
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitSyndie
- type: ClothingSpeedModifier
walkModifier: 1.0
sprintModifier: 1.0
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitSyndieElite
- type: ClothingSpeedModifier
walkModifier: 1.0
sprintModifier: 1.0
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitSyndieCommander
- type: ClothingSpeedModifier
walkModifier: 0.9
sprintModifier: 0.65
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitCybersun
- type: ClothingSpeedModifier
walkModifier: 0.8
sprintModifier: 0.8
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitWizard
- type: ClothingSpeedModifier
walkModifier: 0.8
sprintModifier: 0.8
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitLing
- type: ClothingSpeedModifier
walkModifier: 0.6
sprintModifier: 0.6
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitPirateEVA
- type: StaticPrice
- type: ClothingSpeedModifier
walkModifier: 0.8
sprintModifier: 0.8
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitPirateCap
- type: StaticPrice
- type: ClothingSpeedModifier
walkModifier: 1.0
sprintModifier: 1.0
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitDeathsquad
- type: ClothingSpeedModifier
walkModifier: 1.0
sprintModifier: 1.0
+ - type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetCBURN
- type: ClothingSpeedModifier
walkModifier: 0.9
sprintModifier: 0.9
+ - type: HeldSpeedModifier
- type: Construction
graph: ClownHardsuit
node: clownHardsuit