Files
tbd-station-14/Content.Client/Power/EntitySystems/PowerReceiverSystem.cs
metalgearsloth 75a7407e33 Predict some power PowerReceiver stuff (#33834)
* Predict some power PowerReceiver stuff

Need it for some atmos device prediction.

* Also this
2025-03-10 13:00:49 +11:00

46 lines
1.4 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;
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;
}
}