CatStation/Content.Shared/Power/Components/PowerStateComponent.cs
Fildrance 1a5e9acb24
Extract notify on non-functioning from emitter (#45346)
* 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>
2026-08-16 23:08:58 +00:00

42 lines
1.4 KiB
C#

using Content.Shared.Power.EntitySystems;
namespace Content.Shared.Power.Components;
/// <summary>
/// Generic component for giving entities "idle" and "working" power states.
/// </summary>
/// <remarks><para>Entities that have more complex power draw
/// (ex. a thermomachine whose heating power is directly tied to its power consumption)
/// should just directly set their load on the <see cref="SharedApcPowerReceiverComponent"/>.</para>
///
/// <para>This is also applicable if you would like to add
/// more complex power behavior that is tied to a generic component.</para></remarks>
[RegisterComponent]
[Access(typeof(SharedPowerStateSystem))]
public sealed partial class PowerStateComponent : Component
{
/// <summary>
/// Whether the entity is currently in the working state.
/// </summary>
[DataField]
public bool IsWorking;
/// <summary>
/// The idle power draw of this entity when not working, in watts.
/// </summary>
[DataField]
public float IdlePowerDraw = 20f;
/// <summary>
/// The working power draw of this entity when working, in watts.
/// </summary>
[DataField]
public float WorkingPowerDraw = 350f;
/// <summary>
/// Needs to ensure ApcPowerReceiverComponent is attached to entity on startup.
/// Entities which work with PowerConsumerComponent do not need that.
/// </summary>
[DataField]
public bool EnsureApc = true;
}