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