Improve ClothingSpeedModifier, Fix Paramedic Void Suit (#41820)
* Add RequireActivated bool * Fix paramedic voidsuit * Remove explicit check This is actually unnecessarily verbose. * Improve comment * Update Content.Shared/Clothing/ClothingSpeedModifierSystem.cs Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Add cref linking * Change reference from system to component * Fix missing closing tag before anyone notices * Add clarity about when this field is used. * Add early return if not affected by toggling --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
parent
681c4dac12
commit
8e96ddfa6a
|
|
@ -5,7 +5,7 @@ namespace Content.Shared.Clothing;
|
|||
|
||||
/// <summary>
|
||||
/// Modifies speed when worn and activated.
|
||||
/// Supports <c>ItemToggleComponent</c>.
|
||||
/// Supports <see cref="ItemToggleComponent"/>.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, Access(typeof(ClothingSpeedModifierSystem))]
|
||||
public sealed partial class ClothingSpeedModifierComponent : Component
|
||||
|
|
@ -16,6 +16,13 @@ public sealed partial class ClothingSpeedModifierComponent : Component
|
|||
[DataField]
|
||||
public float SprintModifier = 1.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Defines if the speed modifier requires <see cref="ItemToggleComponent"/> activation to apply.
|
||||
/// This will have no effect without an <see cref="ItemToggleComponent"/> on the entity.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public bool RequireActivated = true;
|
||||
|
||||
/// <summary>
|
||||
/// An optional required standing state.
|
||||
/// Set to true if you need to be standing, false if you need to not be standing, null if you don't care.
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public sealed class ClothingSpeedModifierSystem : EntitySystem
|
|||
|
||||
private void OnRefreshMoveSpeed(EntityUid uid, ClothingSpeedModifierComponent component, InventoryRelayedEvent<RefreshMovementSpeedModifiersEvent> args)
|
||||
{
|
||||
if (!_toggle.IsActivated(uid))
|
||||
if (component.RequireActivated && !_toggle.IsActivated(uid))
|
||||
return;
|
||||
|
||||
if (component.Standing != null && !_standing.IsMatchingState(args.Owner, component.Standing.Value))
|
||||
|
|
@ -132,6 +132,9 @@ public sealed class ClothingSpeedModifierSystem : EntitySystem
|
|||
|
||||
private void OnToggled(Entity<ClothingSpeedModifierComponent> ent, ref ItemToggledEvent args)
|
||||
{
|
||||
if (!ent.Comp.RequireActivated)
|
||||
return;
|
||||
|
||||
// make sentient boots slow or fast too
|
||||
_movementSpeed.RefreshMovementSpeedModifiers(ent);
|
||||
|
||||
|
|
|
|||
|
|
@ -200,6 +200,7 @@
|
|||
- type: ClothingSpeedModifier
|
||||
walkModifier: 0.9
|
||||
sprintModifier: 0.9
|
||||
requireActivated: false
|
||||
- type: HeldSpeedModifier
|
||||
- type: TemperatureProtection
|
||||
heatingCoefficient: 0.1
|
||||
|
|
|
|||
Loading…
Reference in New Issue