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 { /// /// Map of device network addresses to cyborg data. /// public Dictionary Cyborgs; public RoboticsConsoleState(Dictionary cyborgs) { Cyborgs = cyborgs; } } /// /// Message to disable the selected cyborg. /// [Serializable, NetSerializable] public sealed class RoboticsConsoleDisableMessage : BoundUserInterfaceMessage { public readonly string Address; public RoboticsConsoleDisableMessage(string address) { Address = address; } } /// /// Message to destroy the selected cyborg. /// [Serializable, NetSerializable] public sealed class RoboticsConsoleDestroyMessage : BoundUserInterfaceMessage { public readonly string Address; public RoboticsConsoleDestroyMessage(string address) { Address = address; } } /// /// All data a client needs to render the console UI for a single cyborg. /// Created by BorgTransponderComponent and sent to clients by RoboticsConsoleComponent. /// [DataRecord, Serializable, NetSerializable] public record struct CyborgControlData { /// /// Texture of the borg chassis. /// [DataField(required: true)] public SpriteSpecifier? ChassisSprite; /// /// Name of the borg chassis. /// [DataField(required: true)] public string ChassisName = string.Empty; /// /// Name of the borg's entity, including its silicon id. /// [DataField(required: true)] public string Name = string.Empty; /// /// Battery charge from 0 to 1. /// [DataField] public float Charge; /// /// 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. /// [DataField] public int ModuleCount; /// /// Whether the borg has a brain installed or not. /// [DataField] public bool HasBrain; /// /// When this cyborg's data will be deleted. /// Set by the console when receiving the packet. /// [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))] public TimeSpan Timeout = TimeSpan.Zero; public CyborgControlData(SpriteSpecifier? chassisSprite, string chassisName, string name, float charge, int moduleCount, bool hasBrain) { ChassisSprite = chassisSprite; ChassisName = chassisName; Name = name; Charge = charge; ModuleCount = moduleCount; HasBrain = hasBrain; } } 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"; }