using Content.Shared.FixedPoint; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; namespace Content.Shared.Silicons.Laws; /// /// Lawset data used internally. /// [DataDefinition, Serializable, NetSerializable] public sealed partial class SiliconLawset { /// /// List of laws in this lawset. /// [DataField(required: true), ViewVariables(VVAccess.ReadWrite)] public List Laws = new(); /// /// What entity the lawset considers as a figure of authority. /// [DataField(required: true), ViewVariables(VVAccess.ReadWrite)] public string ObeysTo = string.Empty; /// /// A single line used in logging laws. /// public string LoggingString() { var laws = new List(Laws.Count); foreach (var law in Laws) { laws.Add($"{law.Order}: {Loc.GetString(law.LawString)}"); } return string.Join(" / ", laws); } /// /// Do a clone of this lawset. /// It will have unique laws but their strings are still shared. /// public SiliconLawset Clone() { var laws = new List(Laws.Count); foreach (var law in Laws) { laws.Add(law.ShallowClone()); } return new SiliconLawset() { Laws = laws, ObeysTo = ObeysTo }; } } /// /// This is a prototype for a list. /// Cannot be used directly since it is a list of prototype ids rather than List. /// [Prototype, Serializable, NetSerializable] public sealed partial class SiliconLawsetPrototype : IPrototype { /// [IdDataField] public string ID { get; private set; } = default!; /// /// List of law prototype ids in this lawset. /// [DataField(required: true, customTypeSerializer: typeof(PrototypeIdListSerializer))] public List Laws = new(); /// /// What entity the lawset considers as a figure of authority. /// [DataField(required: true), ViewVariables(VVAccess.ReadWrite)] public string ObeysTo = string.Empty; }