mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 02:41:18 +03:00
* refactor: extracted notify-on-non-functioning feature from emitter component * refactor: revert server side PowerStateSystem usage of SubscribeLocalEvent - it is not calling base Initialize, skip SetWorkingState raising event on init * refactor: ensureAPC is now conditional for powerstate * refactor: fix double notifiation on destruction and on un-powering for emitter * refactor: added LocTurnedOff for NotifyOnNonFunctioningComponent, fix double alert on destruction, removed emitter-deconstructed-broadcast as it is unused (cannot deconstruct withou unanchor) * refactor: modernize server PowerStateSystem subscription * refactor: update and modernize PowerStatePrototypeTest * refactor: give APE specific radio message upon unlocking * refactor: extracted PowerStateSystem.SetPowerLoad to split init from triggering is-working change event * Update Content.Server/Power/EntitySystems/PowerStateSystem.cs --------- Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com>
28 lines
948 B
C#
28 lines
948 B
C#
using Content.Server.Power.Components;
|
|
using Content.Shared.Power.Components;
|
|
using Content.Shared.Power.EntitySystems;
|
|
|
|
namespace Content.Server.Power.EntitySystems;
|
|
|
|
/// <inheritdoc/>>
|
|
public sealed partial class PowerStateSystem : SharedPowerStateSystem
|
|
{
|
|
/// <summary> Init IsWorking and power values on startup. </summary>
|
|
[SubscribeLocalEvent]
|
|
private void OnComponentStartup(Entity<PowerStateComponent> ent, ref ComponentStartup args)
|
|
{
|
|
if (ent.Comp.EnsureApc)
|
|
EnsureComp<ApcPowerReceiverComponent>(ent);
|
|
|
|
SetPowerLoad(ent, ent.Comp.IsWorking);
|
|
}
|
|
|
|
/// <inheritdoc/>>
|
|
protected override void SetPowerLoad(Entity<PowerStateComponent> ent, bool isWorking)
|
|
{
|
|
base.SetPowerLoad(ent, isWorking);
|
|
|
|
if (TryComp<PowerConsumerComponent>(ent, out var powerConsumer))
|
|
powerConsumer.DrawRate = isWorking ? ent.Comp.WorkingPowerDraw : ent.Comp.IdlePowerDraw;
|
|
}
|
|
}
|