| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- using Robust.Shared.Prototypes;
- using Robust.Shared.Serialization;
- using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
- using Robust.Shared.Utility;
- namespace Content.Shared.Robotics;
- [Serializable, NetSerializable]
- public enum RoboticsConsoleUiKey : byte
- {
- Key
- }
- [Serializable, NetSerializable]
- public sealed class RoboticsConsoleState : BoundUserInterfaceState
- {
- /// <summary>
- /// Map of device network addresses to cyborg data.
- /// </summary>
- public Dictionary<string, CyborgControlData> Cyborgs;
- public RoboticsConsoleState(Dictionary<string, CyborgControlData> cyborgs)
- {
- Cyborgs = cyborgs;
- }
- }
- /// <summary>
- /// Message to disable the selected cyborg.
- /// </summary>
- [Serializable, NetSerializable]
- public sealed class RoboticsConsoleDisableMessage : BoundUserInterfaceMessage
- {
- public readonly string Address;
- public RoboticsConsoleDisableMessage(string address)
- {
- Address = address;
- }
- }
- /// <summary>
- /// Message to destroy the selected cyborg.
- /// </summary>
- [Serializable, NetSerializable]
- public sealed class RoboticsConsoleDestroyMessage : BoundUserInterfaceMessage
- {
- public readonly string Address;
- public RoboticsConsoleDestroyMessage(string address)
- {
- Address = address;
- }
- }
- /// <summary>
- /// All data a client needs to render the console UI for a single cyborg.
- /// Created by <c>BorgTransponderComponent</c> and sent to clients by <c>RoboticsConsoleComponent</c>.
- /// </summary>
- [DataRecord, Serializable, NetSerializable]
- public partial record struct CyborgControlData
- {
- /// <summary>
- /// Texture of the borg chassis.
- /// </summary>
- [DataField(required: true)]
- public SpriteSpecifier? ChassisSprite;
- /// <summary>
- /// Name of the borg chassis.
- /// </summary>
- [DataField(required: true)]
- public string ChassisName = string.Empty;
- /// <summary>
- /// Name of the borg's entity, including its silicon id.
- /// </summary>
- [DataField(required: true)]
- public string Name = string.Empty;
- /// <summary>
- /// Battery charge from 0 to 1.
- /// </summary>
- [DataField]
- public float Charge;
- /// <summary>
- /// How many modules this borg has, just useful information for roboticists.
- /// Lets them keep track of the latejoin borgs that need new modules and stuff.
- /// </summary>
- [DataField]
- public int ModuleCount;
- /// <summary>
- /// Whether the borg has a brain installed or not.
- /// </summary>
- [DataField]
- public bool HasBrain;
- /// <summary>
- /// Whether the borg can currently be disabled if the brain is installed,
- /// if on cooldown then can't queue up multiple disables.
- /// </summary>
- [DataField]
- public bool CanDisable;
- /// <summary>
- /// When this cyborg's data will be deleted.
- /// Set by the console when receiving the packet.
- /// </summary>
- [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
- public TimeSpan Timeout = TimeSpan.Zero;
- public CyborgControlData(SpriteSpecifier? chassisSprite, string chassisName, string name, float charge, int moduleCount, bool hasBrain, bool canDisable)
- {
- ChassisSprite = chassisSprite;
- ChassisName = chassisName;
- Name = name;
- Charge = charge;
- ModuleCount = moduleCount;
- HasBrain = hasBrain;
- CanDisable = canDisable;
- }
- }
- public static class RoboticsConsoleConstants
- {
- // broadcast by cyborgs on Robotics Console frequency
- public const string NET_CYBORG_DATA = "cyborg-data";
- // sent by robotics console to cyborgs on Cyborg Control frequency
- public const string NET_DISABLE_COMMAND = "cyborg-disable";
- public const string NET_DESTROY_COMMAND = "cyborg-destroy";
- }
|