Files
tbd-station-14/Content.Client/Power/EntitySystems/PowerReceiverSystem.cs
Mervill ec19f9f4a9 Make the powered examine text fully client predicted (#30441)
* Make the powered examine text fully client predicted

* switch to using the Entity<T> API for the examine event
2024-07-29 00:28:17 -07:00

31 lines
979 B
C#

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;
}
}