CatStation/Content.Shared/Singularity/Components/SharedEmitterComponent.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

111 lines
2.8 KiB
C#

using System.Threading;
using Content.Shared.DeviceLinking;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
namespace Content.Shared.Singularity.Components;
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class EmitterComponent : Component
{
public CancellationTokenSource? TimerCancel;
// Whether the power switch is on AND the machine has enough power (so is actively firing)
[ViewVariables] public bool IsPowered;
/// <summary>
/// counts the number of consecutive shots fired.
/// </summary>
[ViewVariables]
public int FireShotCounter;
/// <summary>
/// The entity that is spawned when the emitter fires.
/// </summary>
[DataField, AutoNetworkedField]
public EntProtoId BoltType = "EmitterBolt";
[DataField]
public List<EntProtoId> SelectableTypes = new();
/// <summary>
/// The amount of shots that are fired in a single "burst"
/// </summary>
[DataField]
public int FireBurstSize = 3;
/// <summary>
/// The time between each shot during a burst.
/// </summary>
[DataField]
public TimeSpan FireInterval = TimeSpan.FromSeconds(2);
/// <summary>
/// The current minimum delay between bursts.
/// </summary>
[DataField]
public TimeSpan FireBurstDelayMin = TimeSpan.FromSeconds(4);
/// <summary>
/// The current maximum delay between bursts.
/// </summary>
[DataField]
public TimeSpan FireBurstDelayMax = TimeSpan.FromSeconds(10);
/// <summary>
/// The visual state that is set when the emitter is turned on
/// </summary>
[DataField]
public string? OnState = "beam";
/// <summary>
/// The visual state that is set when the emitter doesn't have enough power.
/// </summary>
[DataField]
public string? UnderpoweredState = "underpowered";
/// <summary>
/// Signal port that turns on the emitter.
/// </summary>
[DataField]
public ProtoId<SinkPortPrototype> OnPort = "On";
/// <summary>
/// Signal port that turns off the emitter.
/// </summary>
[DataField]
public ProtoId<SinkPortPrototype> OffPort = "Off";
/// <summary>
/// Signal port that toggles the emitter on or off.
/// </summary>
[DataField]
public ProtoId<SinkPortPrototype> TogglePort = "Toggle";
/// <summary>
/// Map of signal ports to entity prototype IDs of the entity that will be fired.
/// </summary>
[DataField]
public Dictionary<ProtoId<SinkPortPrototype>, EntProtoId> SetTypePorts = new();
}
[NetSerializable, Serializable]
public enum EmitterVisuals : byte
{
VisualState
}
[Serializable, NetSerializable]
public enum EmitterVisualLayers : byte
{
Lights
}
[NetSerializable, Serializable]
public enum EmitterVisualState
{
On,
Underpowered,
Off
}