2022-06-24 17:44:30 +10:00
|
|
|
using Content.Shared.Movement.Systems;
|
2021-11-01 23:24:00 +11:00
|
|
|
using Robust.Shared.GameStates;
|
2020-02-22 23:37:56 +00:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Shared.Movement.Components
|
2020-02-22 23:37:56 +00:00
|
|
|
{
|
2022-07-16 13:51:52 +10:00
|
|
|
/// <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>
|
2023-09-28 16:20:29 -07:00
|
|
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
|
|
|
|
[Access(typeof(MovementSpeedModifierSystem))]
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class MovementSpeedModifierComponent : Component
|
2020-02-22 23:37:56 +00:00
|
|
|
{
|
2022-07-16 13:51:52 +10:00
|
|
|
// Weightless
|
|
|
|
|
public const float DefaultMinimumFrictionSpeed = 0.005f;
|
|
|
|
|
public const float DefaultWeightlessFriction = 1f;
|
|
|
|
|
public const float DefaultWeightlessFrictionNoInput = 0.2f;
|
|
|
|
|
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 = 2.5f;
|
|
|
|
|
public const float DefaultBaseSprintSpeed = 4.5f;
|
2020-04-18 13:46:35 +02:00
|
|
|
|
2023-09-28 16:20:29 -07:00
|
|
|
[AutoNetworkedField, ViewVariables]
|
2021-11-07 22:17:35 -07:00
|
|
|
public float WalkSpeedModifier = 1.0f;
|
|
|
|
|
|
2023-09-28 16:20:29 -07:00
|
|
|
[AutoNetworkedField, ViewVariables]
|
2021-11-07 22:17:35 -07:00
|
|
|
public float SprintSpeedModifier = 1.0f;
|
2020-02-22 23:37:56 +00:00
|
|
|
|
2020-04-18 13:46:35 +02:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2022-06-29 15:11:09 +12:00
|
|
|
private float _baseWalkSpeedVV
|
2021-11-01 23:24:00 +11:00
|
|
|
{
|
|
|
|
|
get => BaseWalkSpeed;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
BaseWalkSpeed = value;
|
|
|
|
|
Dirty();
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-05 01:08:38 +01:00
|
|
|
|
2020-04-18 13:46:35 +02:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2022-06-29 15:11:09 +12:00
|
|
|
private float _baseSprintSpeedVV
|
2021-11-01 23:24:00 +11:00
|
|
|
{
|
|
|
|
|
get => BaseSprintSpeed;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
BaseSprintSpeed = value;
|
|
|
|
|
Dirty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-16 13:51:52 +10:00
|
|
|
/// <summary>
|
|
|
|
|
/// Minimum speed a mob has to be moving before applying movement friction.
|
|
|
|
|
/// </summary>
|
2023-09-28 16:20:29 -07:00
|
|
|
[ViewVariables(VVAccess.ReadWrite), DataField]
|
2022-07-16 13:51:52 +10:00
|
|
|
public float MinimumFrictionSpeed = DefaultMinimumFrictionSpeed;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The negative velocity applied for friction when weightless and providing inputs.
|
|
|
|
|
/// </summary>
|
2023-09-28 16:20:29 -07:00
|
|
|
[ViewVariables(VVAccess.ReadWrite), DataField]
|
2022-07-16 13:51:52 +10:00
|
|
|
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>
|
2023-09-28 16:20:29 -07:00
|
|
|
[ViewVariables(VVAccess.ReadWrite), DataField]
|
2022-07-16 13:51:52 +10:00
|
|
|
public float WeightlessFrictionNoInput = DefaultWeightlessFrictionNoInput;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The movement speed modifier applied to a mob's total input velocity when weightless.
|
|
|
|
|
/// </summary>
|
2023-09-28 16:20:29 -07:00
|
|
|
[ViewVariables(VVAccess.ReadWrite), DataField]
|
2022-07-16 13:51:52 +10:00
|
|
|
public float WeightlessModifier = DefaultWeightlessModifier;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The acceleration applied to mobs when moving and weightless.
|
|
|
|
|
/// </summary>
|
2023-09-28 16:20:29 -07:00
|
|
|
[ViewVariables(VVAccess.ReadWrite), DataField]
|
2022-07-16 13:51:52 +10:00
|
|
|
public float WeightlessAcceleration = DefaultWeightlessAcceleration;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The acceleration applied to mobs when moving.
|
|
|
|
|
/// </summary>
|
2023-11-06 04:41:42 +02:00
|
|
|
[AutoNetworkedField, ViewVariables(VVAccess.ReadWrite), DataField]
|
2022-07-16 13:51:52 +10:00
|
|
|
public float Acceleration = DefaultAcceleration;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The negative velocity applied for friction.
|
|
|
|
|
/// </summary>
|
2023-11-06 04:41:42 +02:00
|
|
|
[AutoNetworkedField, ViewVariables(VVAccess.ReadWrite), DataField]
|
2022-07-16 13:51:52 +10:00
|
|
|
public float Friction = DefaultFriction;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The negative velocity applied for friction.
|
|
|
|
|
/// </summary>
|
2023-11-06 04:41:42 +02:00
|
|
|
[AutoNetworkedField, ViewVariables(VVAccess.ReadWrite), DataField]
|
2023-09-28 16:20:29 -07:00
|
|
|
public float? FrictionNoInput;
|
2022-07-16 13:51:52 +10:00
|
|
|
|
2023-09-28 16:20:29 -07:00
|
|
|
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
2021-11-01 23:24:00 +11:00
|
|
|
public float BaseWalkSpeed { get; set; } = DefaultBaseWalkSpeed;
|
|
|
|
|
|
2023-09-28 16:20:29 -07:00
|
|
|
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
2021-11-01 23:24:00 +11:00
|
|
|
public float BaseSprintSpeed { get; set; } = DefaultBaseSprintSpeed;
|
2020-04-18 13:46:35 +02:00
|
|
|
|
|
|
|
|
[ViewVariables]
|
|
|
|
|
public float CurrentWalkSpeed => WalkSpeedModifier * BaseWalkSpeed;
|
|
|
|
|
[ViewVariables]
|
|
|
|
|
public float CurrentSprintSpeed => SprintSpeedModifier * BaseSprintSpeed;
|
2020-02-22 23:37:56 +00:00
|
|
|
}
|
|
|
|
|
}
|