* Power stuff - Add shared IsPowered - Add shared ResolveApc - Move PowerChangedEvent to shared for now - Add SlimPoweredLight that actually functions how you'd expect a PoweredLight to function it id didn't have a bunch of bloat on it. * big update * boing
44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
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<ApcPowerReceiverComponent, ExaminedEvent>(OnExamined);
|
|
SubscribeLocalEvent<ApcPowerReceiverComponent, ComponentHandleState>(OnHandleState);
|
|
}
|
|
|
|
private void OnExamined(Entity<ApcPowerReceiverComponent> ent, ref ExaminedEvent args)
|
|
{
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|