using System.Diagnostics.CodeAnalysis; using Content.Client.Power.Components; using Content.Shared.Power.Components; using Content.Shared.Power.EntitySystems; using Content.Shared.Examine; using Robust.Shared.GameStates; namespace Content.Client.Power.EntitySystems; public sealed class PowerReceiverSystem : SharedPowerReceiverSystem { public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnExamined); SubscribeLocalEvent(OnHandleState); } private void OnExamined(Entity ent, ref ExaminedEvent args) { if (ent.Comp.NeedsPower){ args.PushMarkup(GetExamineText(ent.Comp.Powered)); } } private void OnHandleState(EntityUid uid, ApcPowerReceiverComponent component, ref ComponentHandleState args) { if (args.Current is not ApcPowerReceiverComponentState state) return; component.Powered = state.Powered; component.NeedsPower = state.NeedsPower; component.PowerDisabled = state.PowerDisabled; } public override bool ResolveApc(EntityUid entity, [NotNullWhen(true)] ref SharedApcPowerReceiverComponent? component) { if (component != null) return true; if (!TryComp(entity, out ApcPowerReceiverComponent? receiver)) return false; component = receiver; return true; } }