using Content.Shared.Actions.ActionTypes; using Content.Shared.FixedPoint; using Content.Shared.Whitelist; using Robust.Shared.Containers; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; namespace Content.Shared.Mech.Components; /// /// A large, pilotable machine that has equipment that is /// powered via an internal battery. /// [RegisterComponent, NetworkedComponent] public sealed partial class MechComponent : Component { /// /// How much "health" the mech has left. /// [ViewVariables(VVAccess.ReadWrite)] public FixedPoint2 Integrity; /// /// The maximum amount of damage the mech can take. /// [DataField("maxIntegrity")] public FixedPoint2 MaxIntegrity = 250; /// /// How much energy the mech has. /// Derived from the currently inserted battery. /// [ViewVariables(VVAccess.ReadWrite)] public FixedPoint2 Energy = 0; /// /// The maximum amount of energy the mech can have. /// Derived from the currently inserted battery. /// [DataField("maxEnergy")] public FixedPoint2 MaxEnergy = 0; /// /// The slot the battery is stored in. /// [ViewVariables] public ContainerSlot BatterySlot = default!; [ViewVariables] public readonly string BatterySlotId = "mech-battery-slot"; /// /// A multiplier used to calculate how much of the damage done to a mech /// is transfered to the pilot /// [DataField("mechToPilotDamageMultiplier")] public float MechToPilotDamageMultiplier; /// /// Whether the mech has been destroyed and is no longer pilotable. /// [ViewVariables(VVAccess.ReadWrite)] public bool Broken = false; /// /// The slot the pilot is stored in. /// [ViewVariables(VVAccess.ReadWrite)] public ContainerSlot PilotSlot = default!; [ViewVariables] public readonly string PilotSlotId = "mech-pilot-slot"; /// /// The current selected equipment of the mech. /// If null, the mech is using just its fists. /// [ViewVariables] public EntityUid? CurrentSelectedEquipment; /// /// The maximum amount of equipment items that can be installed in the mech /// [DataField("maxEquipmentAmount")] public int MaxEquipmentAmount = 3; /// /// A whitelist for inserting equipment items. /// [DataField("equipmentWhitelist")] public EntityWhitelist? EquipmentWhitelist; [DataField("pilotWhitelist")] public EntityWhitelist? PilotWhitelist; /// /// A container for storing the equipment entities. /// [ViewVariables(VVAccess.ReadWrite)] public Container EquipmentContainer = default!; [ViewVariables] public readonly string EquipmentContainerId = "mech-equipment-container"; /// /// How long it takes to enter the mech. /// [DataField("entryDelay")] public float EntryDelay = 3; /// /// How long it takes to pull *another person* /// outside of the mech. You can exit instantly yourself. /// [DataField("exitDelay")] public float ExitDelay = 3; /// /// How long it takes to pull out the battery. /// [DataField("batteryRemovalDelay")] public float BatteryRemovalDelay = 2; /// /// Whether or not the mech is airtight. /// /// /// This needs to be redone /// when mech internals are added /// [DataField("airtight"), ViewVariables(VVAccess.ReadWrite)] public bool Airtight; /// /// The equipment that the mech initially has when it spawns. /// Good for things like nukie mechs that start with guns. /// [DataField("startingEquipment", customTypeSerializer: typeof(PrototypeIdListSerializer))] public List StartingEquipment = new(); #region Action Prototypes [DataField("mechCycleAction", customTypeSerializer: typeof(PrototypeIdSerializer))] public string MechCycleAction = "MechCycleEquipment"; [DataField("mechUiAction", customTypeSerializer: typeof(PrototypeIdSerializer))] public string MechUiAction = "MechOpenUI"; [DataField("mechEjectAction", customTypeSerializer: typeof(PrototypeIdSerializer))] public string MechEjectAction = "MechEject"; #endregion #region Visualizer States [DataField("baseState")] public string? BaseState; [DataField("openState")] public string? OpenState; [DataField("brokenState")] public string? BrokenState; #endregion } /// /// Contains network state for . /// [Serializable, NetSerializable] public sealed class MechComponentState : ComponentState { public FixedPoint2 Integrity; public FixedPoint2 MaxIntegrity; public FixedPoint2 Energy; public FixedPoint2 MaxEnergy; public EntityUid? CurrentSelectedEquipment; public bool Broken; }