using Content.Server.Shuttles.Systems;
using Content.Shared.Construction.Prototypes;
using Content.Shared.Damage;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Shuttles.Components
{
[RegisterComponent]
[Access(typeof(ThrusterSystem))]
public sealed class ThrusterComponent : Component
{
///
/// Whether the thruster has been force to be enabled / disabled (e.g. VV, interaction, etc.)
///
[ViewVariables(VVAccess.ReadWrite)]
public bool Enabled
{
get => _enabled;
[Obsolete("Use the system method")]
set
{
if (_enabled == value) return;
_enabled = value;
var system = EntitySystem.Get();
if (!_enabled)
{
system.DisableThruster(Owner, this);
}
else if (system.CanEnable(Owner, this))
{
system.EnableThruster(Owner, this);
}
}
}
[DataField("enabled")]
private bool _enabled = true;
///
/// This determines whether the thruster is actually enabled for the purposes of thrust
///
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;
[DataField("baseThrust"), ViewVariables(VVAccess.ReadWrite)]
public float BaseThrust = 750f;
[DataField("thrusterType")]
public ThrusterType Type = ThrusterType.Linear;
[DataField("burnShape")] public List 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)
};
///
/// How much damage is done per second to anything colliding with our thrust.
///
[DataField("damage")] public DamageSpecifier? Damage = new();
[DataField("requireSpace")]
public bool RequireSpace = true;
// Used for burns
public List Colliding = new();
public bool Firing = false;
///
/// Next time we tick damage for anyone colliding.
///
[ViewVariables(VVAccess.ReadWrite), DataField("nextFire", customTypeSerializer:typeof(TimeOffsetSerializer))]
public TimeSpan NextFire;
[DataField("machinePartThrust", customTypeSerializer: typeof(PrototypeIdSerializer))]
public string MachinePartThrust = "Capacitor";
[DataField("partRatingThrustMultiplier")]
public float PartRatingThrustMultiplier = 1.5f;
}
public enum ThrusterType
{
Linear,
// Angular meaning rotational.
Angular,
}
}