CatStation/Content.Server/Shuttles/Components/ThrusterComponent.cs
Krunklehorn cb28e542b0
Gyroscope throttling take 2, automatic, inertia based (#37419)
* Sync debug gyroscope, rename SetAngularThrust to SetAngularThrustVisualState

* inertiaThreshold and GetInertiaThresholdScale

* basePowerLoad and UpdatePowerLoad

* Re-accumulate and update during OnShuttleTileChange

* Move to subscription on MassDataChangedEvent

* Fix for IsOn if the grid loses it's shuttle component

* Fixed return

* Reuse cached thruster ids

* Missing using

* Fixed map keys must be unique

* Somehow this got pasted in

* Copied basePowerLoad for large thrusters too

* Updated default threshold

* Fixed variable case
2026-07-11 04:07:59 +00:00

90 lines
2.9 KiB
C#

using System.Numerics;
using Content.Server.Shuttles.Systems;
using Content.Shared.Damage;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Server.Shuttles.Components
{
[RegisterComponent, NetworkedComponent, AutoGenerateComponentPause]
[Access(typeof(ThrusterSystem))]
public sealed partial class ThrusterComponent : Component
{
/// <summary>
/// If the thruster can be toggled on or off via interaction
/// </summary>
[DataField]
public bool CanToggle = true;
/// <summary>
/// Whether the thruster has been force to be enabled / disabled (e.g. VV, interaction, etc.)
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public bool Enabled { get; set; } = true;
/// <summary>
/// Base power for the <see cref="ApcPowerReceiverComponent"/>, scaled by thruster setting.
/// </summary>
[DataField]
public float BasePowerLoad = 1500;
/// <summary>
/// This determines whether the thruster is actually enabled for the purposes of thrust
/// </summary>
public bool IsOn;
// Need to serialize this because RefreshParts isn't called on Init and this will break post-mapinit maps!
[ViewVariables(VVAccess.ReadWrite), DataField("thrust")]
public float Thrust = 160000f;
/// <summary>
/// Throttles the influence of gyroscopes on small shuttles. The default value is roughly half the inertia of the standard 4-door cargo shuttle.
/// </summary>
[DataField]
public float InertiaThreshold = 850000f;
[DataField("thrusterType")]
public ThrusterType Type = ThrusterType.Linear;
[DataField("burnShape")] public List<Vector2> BurnPoly = new()
{
new Vector2(-0.4f, 0.5f),
new Vector2(-0.1f, 1.2f),
new Vector2(0.1f, 1.2f),
new Vector2(0.4f, 0.5f)
};
/// <summary>
/// How much damage is done per second to anything colliding with our thrust.
/// </summary>
[DataField("damage")] public DamageSpecifier? Damage = new();
[DataField("requireSpace")]
public bool RequireSpace = true;
// Used for burns
public List<EntityUid> Colliding = new();
public bool Firing = false;
/// <summary>
/// How often thruster deals damage.
/// </summary>
[DataField]
public TimeSpan FireCooldown = TimeSpan.FromSeconds(2);
/// <summary>
/// Next time we tick damage for anyone colliding.
/// </summary>
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField]
public TimeSpan NextFire = TimeSpan.Zero;
}
public enum ThrusterType
{
Linear,
// Angular meaning rotational.
Angular,
}
}