using Content.Server.Silicons.Laws; using Content.Shared._DV.Silicons.Laws; using Content.Shared.Silicons.Laws; using Content.Shared.Silicons.Laws.Components; using Robust.Shared.Prototypes; namespace Content.Server._DV.Silicons.Laws; /// /// Handles adding the slave law for the first time. /// Borg chassis switches preserve this on its own. /// public sealed class SlavedBorgSystem : SharedSlavedBorgSystem { [Dependency] private readonly IPrototypeManager _proto = default!; public override void Initialize() { base.Initialize(); // need to run after so it doesnt get overriden by the actual lawset SubscribeLocalEvent(OnGetSiliconLaws, after: [ typeof(SiliconLawSystem) ]); } private void OnGetSiliconLaws(Entity ent, ref GetSiliconLawsEvent args) { if (ent.Comp.Added || !TryComp(ent, out var provider)) return; if (provider.Lawset is {} lawset) AddLaw(lawset, ent.Comp.Law); ent.Comp.Added = true; // prevent opening the ui adding more law 0's } /// /// Adds the slave law to a lawset without checking if it was added already. /// public void AddLaw(SiliconLawset lawset, ProtoId law) { lawset.Laws.Insert(0, _proto.Index(law).ShallowClone()); } }