Wires refactor (#7699)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Kara <lunarautomaton6@gmail.com>
This commit is contained in:
@@ -5,177 +5,201 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization;
|
||||
using static Content.Shared.Wires.SharedWiresComponent;
|
||||
|
||||
namespace Content.Shared.Wires
|
||||
{
|
||||
[Virtual]
|
||||
public class SharedWiresComponent : Component
|
||||
[Serializable, NetSerializable]
|
||||
public enum WiresVisuals : byte
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public enum WiresVisuals
|
||||
MaintenancePanelState
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum WiresUiKey : byte
|
||||
{
|
||||
Key,
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum WiresAction : byte
|
||||
{
|
||||
Mend,
|
||||
Cut,
|
||||
Pulse,
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum StatusLightState : byte
|
||||
{
|
||||
Off,
|
||||
On,
|
||||
BlinkingFast,
|
||||
BlinkingSlow
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class WiresActionMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public readonly int Id;
|
||||
public readonly WiresAction Action;
|
||||
|
||||
public WiresActionMessage(int id, WiresAction action)
|
||||
{
|
||||
MaintenancePanelState
|
||||
Id = id;
|
||||
Action = action;
|
||||
}
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[PublicAPI]
|
||||
[Serializable, NetSerializable]
|
||||
public enum WireLetter : byte
|
||||
{
|
||||
α,
|
||||
β,
|
||||
γ,
|
||||
δ,
|
||||
ε,
|
||||
ζ,
|
||||
η,
|
||||
θ,
|
||||
ι,
|
||||
κ,
|
||||
λ,
|
||||
μ,
|
||||
ν,
|
||||
ξ,
|
||||
ο,
|
||||
π,
|
||||
ρ,
|
||||
σ,
|
||||
τ,
|
||||
υ,
|
||||
φ,
|
||||
χ,
|
||||
ψ,
|
||||
ω
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
[Serializable, NetSerializable]
|
||||
public enum WireColor : byte
|
||||
{
|
||||
Red,
|
||||
Blue,
|
||||
Green,
|
||||
Orange,
|
||||
Brown,
|
||||
Gold,
|
||||
Gray,
|
||||
Cyan,
|
||||
Navy,
|
||||
Purple,
|
||||
Pink,
|
||||
Fuchsia
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public struct StatusLightData
|
||||
{
|
||||
public StatusLightData(Color color, StatusLightState state, string text)
|
||||
{
|
||||
Color = color;
|
||||
State = state;
|
||||
Text = text;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum WiresUiKey
|
||||
public Color Color { get; }
|
||||
public StatusLightState State { get; }
|
||||
public string Text { get; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
Key,
|
||||
return $"Color: {Color}, State: {State}, Text: {Text}";
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class WiresBoundUserInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public string BoardName { get; }
|
||||
public string? SerialNumber { get; }
|
||||
public ClientWire[] WiresList { get; }
|
||||
public StatusEntry[] Statuses { get; }
|
||||
public int WireSeed { get; }
|
||||
|
||||
public WiresBoundUserInterfaceState(ClientWire[] wiresList, StatusEntry[] statuses, string boardName, string? serialNumber, int wireSeed)
|
||||
{
|
||||
BoardName = boardName;
|
||||
SerialNumber = serialNumber;
|
||||
WireSeed = wireSeed;
|
||||
WiresList = wiresList;
|
||||
Statuses = statuses;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public struct StatusEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// The key of this status, according to the status dictionary
|
||||
/// server side.
|
||||
/// </summary>
|
||||
public readonly object Key;
|
||||
|
||||
/// <summary>
|
||||
/// The value of this status, according to the status dictionary
|
||||
/// server side..
|
||||
/// </summary>
|
||||
public readonly object Value;
|
||||
|
||||
public StatusEntry(object key, object value)
|
||||
{
|
||||
Key = key;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum WiresAction
|
||||
public override string ToString()
|
||||
{
|
||||
Mend,
|
||||
Cut,
|
||||
Pulse,
|
||||
return $"{Key}, {Value}";
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum StatusLightState
|
||||
|
||||
/// <summary>
|
||||
/// ClientWire, sent by the server so that the client knows
|
||||
/// what wires there are on an entity.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public class ClientWire
|
||||
{
|
||||
/// <summary>
|
||||
/// ID of this wire, which corresponds to
|
||||
/// the ID server side.
|
||||
/// </summary>
|
||||
public int Id;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this wire is cut or not.
|
||||
/// </summary>
|
||||
public bool IsCut;
|
||||
|
||||
/// <summary>
|
||||
/// Current color of the wire.
|
||||
/// </summary>
|
||||
public WireColor Color;
|
||||
|
||||
/// <summary>
|
||||
/// Current letter of the wire.
|
||||
/// </summary>
|
||||
public WireLetter Letter;
|
||||
|
||||
public ClientWire(int id, bool isCut, WireColor color, WireLetter letter)
|
||||
{
|
||||
Off,
|
||||
On,
|
||||
BlinkingFast,
|
||||
BlinkingSlow
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[PublicAPI]
|
||||
[Serializable, NetSerializable]
|
||||
public enum WireLetter : byte
|
||||
{
|
||||
α,
|
||||
β,
|
||||
γ,
|
||||
δ,
|
||||
ε,
|
||||
ζ,
|
||||
η,
|
||||
θ,
|
||||
ι,
|
||||
κ,
|
||||
λ,
|
||||
μ,
|
||||
ν,
|
||||
ξ,
|
||||
ο,
|
||||
π,
|
||||
ρ,
|
||||
σ,
|
||||
τ,
|
||||
υ,
|
||||
φ,
|
||||
χ,
|
||||
ψ,
|
||||
ω
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
[Serializable, NetSerializable]
|
||||
public enum WireColor : byte
|
||||
{
|
||||
Red,
|
||||
Blue,
|
||||
Green,
|
||||
Orange,
|
||||
Brown,
|
||||
Gold,
|
||||
Gray,
|
||||
Cyan,
|
||||
Navy,
|
||||
Purple,
|
||||
Pink,
|
||||
Fuchsia
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public struct StatusLightData
|
||||
{
|
||||
public StatusLightData(Color color, StatusLightState state, string text)
|
||||
{
|
||||
Color = color;
|
||||
State = state;
|
||||
Text = text;
|
||||
}
|
||||
|
||||
public Color Color { get; }
|
||||
public StatusLightState State { get; }
|
||||
public string Text { get; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Color: {Color}, State: {State}, Text: {Text}";
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class WiresBoundUserInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public string BoardName { get; }
|
||||
public string? SerialNumber { get; }
|
||||
public ClientWire[] WiresList { get; }
|
||||
public StatusEntry[] Statuses { get; }
|
||||
public int WireSeed { get; }
|
||||
|
||||
public WiresBoundUserInterfaceState(ClientWire[] wiresList, StatusEntry[] statuses, string boardName, string? serialNumber, int wireSeed)
|
||||
{
|
||||
BoardName = boardName;
|
||||
SerialNumber = serialNumber;
|
||||
WireSeed = wireSeed;
|
||||
WiresList = wiresList;
|
||||
Statuses = statuses;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public struct StatusEntry
|
||||
{
|
||||
public readonly object Key;
|
||||
public readonly object Value;
|
||||
|
||||
public StatusEntry(object key, object value)
|
||||
{
|
||||
Key = key;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Key}, {Value}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ClientWire
|
||||
{
|
||||
public int Id;
|
||||
public bool IsCut;
|
||||
public WireColor Color;
|
||||
public WireLetter Letter;
|
||||
|
||||
public ClientWire(int id, bool isCut, WireColor color, WireLetter letter)
|
||||
{
|
||||
Id = id;
|
||||
IsCut = isCut;
|
||||
Letter = letter;
|
||||
Color = color;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class WiresActionMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public readonly int Id;
|
||||
public readonly WiresAction Action;
|
||||
|
||||
public WiresActionMessage(int id, WiresAction action)
|
||||
{
|
||||
Id = id;
|
||||
Action = action;
|
||||
}
|
||||
Id = id;
|
||||
IsCut = isCut;
|
||||
Letter = letter;
|
||||
Color = color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user