using Content.Shared.PowerCell.Components; using Robust.Shared.Containers; namespace Content.Shared.PowerCell; public abstract class SharedPowerCellSystem : EntitySystem { public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnCellInserted); SubscribeLocalEvent(OnCellRemoved); SubscribeLocalEvent(OnCellInsertAttempt); } private void OnCellInsertAttempt(EntityUid uid, PowerCellSlotComponent component, ContainerIsInsertingAttemptEvent args) { if (!component.Initialized) return; if (args.Container.ID != component.CellSlotId) return; if (!HasComp(args.EntityUid)) { args.Cancel(); } } private void OnCellInserted(EntityUid uid, PowerCellSlotComponent component, EntInsertedIntoContainerMessage args) { if (!component.Initialized) return; if (args.Container.ID != component.CellSlotId) return; RaiseLocalEvent(uid, new PowerCellChangedEvent(false), false); } private void OnCellRemoved(EntityUid uid, PowerCellSlotComponent component, EntRemovedFromContainerMessage args) { if (args.Container.ID != component.CellSlotId) return; RaiseLocalEvent(uid, new PowerCellChangedEvent(true), false); } }