using Content.Shared.FixedPoint; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; namespace Content.Shared.Silicons.Laws; [Virtual, DataDefinition] [Serializable, NetSerializable] public partial class SiliconLaw : IComparable, IEquatable { /// /// A locale string which is the actual text of the law. /// [DataField(required: true), ViewVariables(VVAccess.ReadWrite)] public string LawString = string.Empty; /// /// The order of the law in the sequence. /// Also is the identifier if is null. /// /// /// This is a fixedpoint2 only for the niche case of supporting laws that go between 0 and 1. /// Funny. /// [DataField(required: true), ViewVariables(VVAccess.ReadWrite)] public FixedPoint2 Order; /// /// An identifier that overrides in the law menu UI. /// [DataField, ViewVariables(VVAccess.ReadWrite)] public string? LawIdentifierOverride; public int CompareTo(SiliconLaw? other) { if (other == null) return -1; return Order.CompareTo(other.Order); } public bool Equals(SiliconLaw? other) { if (other == null) return false; return LawString == other.LawString && Order == other.Order && LawIdentifierOverride == other.LawIdentifierOverride; } public override bool Equals(object? obj) { if (obj == null) return false; return Equals(obj as SiliconLaw); } public override int GetHashCode() { return HashCode.Combine(LawString, Order, LawIdentifierOverride); } /// /// Return a shallow clone of this law. /// public SiliconLaw ShallowClone() { return new SiliconLaw() { LawString = LawString, Order = Order, LawIdentifierOverride = LawIdentifierOverride }; } } /// /// This is a prototype for a law governing the behavior of silicons. /// [Prototype] [Serializable, NetSerializable] public sealed partial class SiliconLawPrototype : SiliconLaw, IPrototype { /// [IdDataField] public string ID { get; private set; } = default!; }