Files
wwdpublic/Content.Shared/Movement/Components/MovementSpeedModifierComponent.cs
DEATHB4DEFEAT ac2fc06e10 Invert the Running/Walking States (#485)
# Description

Ports
https://github.com/Simple-Station/Parkstation-Friendly-Chainsaw/pull/39

A change made to encourage people to [stop and smell the
roses](https://www.urbandictionary.com/define.php?term=slow+down+and+smell+the+roses),
instead of sprinting everywhere trying to get shit done.
This goes well with #486, so people don't actually *have* to rush places
to try to get things done before the shift ends fatally.
It's weird anyway how we're all constantly sprinting everywhere and have
to *very actively* choose not to (and why would you?).
Increases the default speeds so that walking isn't painfully slow and
sprinting feels more like sprinting in combination with the active
choice to sprint.

Someone needs to PR changing the default sprint or examine buttons, so
people can fight and sprint with this change.
(A lot of other default keybinds suck or conflict too and need to
change)

# Media

Terrible video but whatever


https://github.com/user-attachments/assets/5ff3863d-92c8-4df3-b76b-82874b5e1ae3

# Changelog

🆑
- tweak: The station's crew hivemind has decided to slow down their
movement and enjoy The Park instead of sprinting everywhere

---------

Signed-off-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com>
Co-authored-by: Pspritechologist <81725545+Pspritechologist@users.noreply.github.com>
2024-08-01 09:30:47 +01:00

117 lines
4.3 KiB
C#

using Content.Shared.Movement.Systems;
using Robust.Shared.GameStates;
namespace Content.Shared.Movement.Components
{
/// <summary>
/// Applies basic movement speed and movement modifiers for an entity.
/// If this is not present on the entity then they will use defaults for movement.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(MovementSpeedModifierSystem))]
public sealed partial class MovementSpeedModifierComponent : Component
{
// Weightless
public const float DefaultMinimumFrictionSpeed = 0.005f;
public const float DefaultWeightlessFriction = 1f;
public const float DefaultWeightlessFrictionNoInput = 0f;
public const float DefaultWeightlessModifier = 0.7f;
public const float DefaultWeightlessAcceleration = 1f;
public const float DefaultAcceleration = 20f;
public const float DefaultFriction = 20f;
public const float DefaultFrictionNoInput = 20f;
public const float DefaultBaseWalkSpeed = 3f;
public const float DefaultBaseSprintSpeed = 5f;
[AutoNetworkedField, ViewVariables]
public float WalkSpeedModifier = 1.0f;
[AutoNetworkedField, ViewVariables]
public float SprintSpeedModifier = 1.0f;
[ViewVariables(VVAccess.ReadWrite)]
private float _baseWalkSpeedVV
{
get => BaseWalkSpeed;
set
{
BaseWalkSpeed = value;
Dirty();
}
}
[ViewVariables(VVAccess.ReadWrite)]
private float _baseSprintSpeedVV
{
get => BaseSprintSpeed;
set
{
BaseSprintSpeed = value;
Dirty();
}
}
/// <summary>
/// Minimum speed a mob has to be moving before applying movement friction.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField]
public float MinimumFrictionSpeed = DefaultMinimumFrictionSpeed;
/// <summary>
/// The negative velocity applied for friction when weightless and providing inputs.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField]
public float WeightlessFriction = DefaultWeightlessFriction;
/// <summary>
/// The negative velocity applied for friction when weightless and not providing inputs.
/// This is essentially how much their speed decreases per second.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField]
public float WeightlessFrictionNoInput = DefaultWeightlessFrictionNoInput;
/// <summary>
/// The movement speed modifier applied to a mob's total input velocity when weightless.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField]
public float WeightlessModifier = DefaultWeightlessModifier;
/// <summary>
/// The acceleration applied to mobs when moving and weightless.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField]
public float WeightlessAcceleration = DefaultWeightlessAcceleration;
/// <summary>
/// The acceleration applied to mobs when moving.
/// </summary>
[AutoNetworkedField, ViewVariables(VVAccess.ReadWrite), DataField]
public float Acceleration = DefaultAcceleration;
/// <summary>
/// The negative velocity applied for friction.
/// </summary>
[AutoNetworkedField, ViewVariables(VVAccess.ReadWrite), DataField]
public float Friction = DefaultFriction;
/// <summary>
/// The negative velocity applied for friction.
/// </summary>
[AutoNetworkedField, ViewVariables(VVAccess.ReadWrite), DataField]
public float? FrictionNoInput;
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
public float BaseWalkSpeed { get; set; } = DefaultBaseWalkSpeed;
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
public float BaseSprintSpeed { get; set; } = DefaultBaseSprintSpeed;
[ViewVariables]
public float CurrentWalkSpeed => WalkSpeedModifier * BaseWalkSpeed;
[ViewVariables]
public float CurrentSprintSpeed => SprintSpeedModifier * BaseSprintSpeed;
}
}