Files
wwdpublic/Content.Shared/Movement/Components/MovementSpeedModifierComponent.cs
VMSolidus b329c1cf6b Port Frictionless Space (#464)
# Description

This ports
https://github.com/Simple-Station/Parkstation-Friendly-Chainsaw/pull/46.
This PR is something I consider a key feature adjacent to Space Wind
Rework and its accompanying updates, and is an essential part of the
space station experience.
In practice, this weirdly enough makes being launched into space a bit
easier to survive, since instead of needing to throw potentially
hundreds of items, you can simply throw enough items to get started
flying in the direction of the station and will eventually float back to
the station.

---

<details><summary><h1>Media</h1></summary>
<p>


https://github.com/Simple-Station/Parkstation-Friendly-Chainsaw/assets/77995199/5570ef35-16e2-493a-ac35-738f27751346


https://github.com/Simple-Station/Parkstation-Friendly-Chainsaw/assets/77995199/51fba943-8dce-4265-a9cc-7181155eb8de


https://github.com/Simple-Station/Parkstation-Friendly-Chainsaw/assets/77995199/cd6c0511-2639-4e14-8160-426ba7f2ba73

---
</p>
</details> 

# Changelog

🆑 DEATHB4DEFEAT
- tweak: Space has suddenly become less dense (objects don't slow down
in space)
- remove: Moths are unable to move in space
- tweak: Moths have way better control in zero gravity environments

---------

Signed-off-by: VMSolidus <evilexecutive@gmail.com>
Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com>
2024-06-17 08:58:34 +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 = 2.5f;
public const float DefaultBaseSprintSpeed = 4.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;
}
}