Files
crystall-punk-14/Content.Shared/Mech/Components/SharedMechComponent.cs

133 lines
4.1 KiB
C#
Raw Normal View History

using Content.Shared.Actions.ActionTypes;
using Content.Shared.FixedPoint;
using Content.Shared.Whitelist;
using Robust.Shared.Containers;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Shared.Mech.Components;
/// <summary>
/// A large, pilotable machine that has equipment that is
/// powered via an internal battery.
/// </summary>
public abstract class SharedMechComponent : 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";
#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="SharedMechComponent"/>.
/// </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;
}