2023-01-08 22:42:31 -05:00
|
|
|
|
using System.Threading;
|
2023-05-28 08:44:28 +02:00
|
|
|
|
using Content.Shared.DeviceLinking;
|
2023-01-08 22:42:31 -05:00
|
|
|
|
using Robust.Shared.GameStates;
|
2023-01-17 00:05:20 -05:00
|
|
|
|
using Robust.Shared.Prototypes;
|
2023-01-08 22:42:31 -05:00
|
|
|
|
using Robust.Shared.Serialization;
|
2020-10-28 19:19:47 +01:00
|
|
|
|
|
2023-01-08 22:42:31 -05:00
|
|
|
|
namespace Content.Shared.Singularity.Components;
|
|
|
|
|
|
|
2025-08-01 13:40:15 -04:00
|
|
|
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
2023-08-22 18:14:33 -07:00
|
|
|
|
public sealed partial class EmitterComponent : Component
|
2023-01-08 22:42:31 -05:00
|
|
|
|
{
|
|
|
|
|
|
public CancellationTokenSource? TimerCancel;
|
|
|
|
|
|
|
|
|
|
|
|
// whether the power switch is in "on"
|
|
|
|
|
|
[ViewVariables] public bool IsOn;
|
|
|
|
|
|
// 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>
|
2025-08-01 13:40:15 -04:00
|
|
|
|
[DataField, AutoNetworkedField]
|
|
|
|
|
|
public EntProtoId BoltType = "EmitterBolt";
|
2023-01-08 22:42:31 -05:00
|
|
|
|
|
2025-07-09 20:06:51 -07:00
|
|
|
|
[DataField]
|
|
|
|
|
|
public List<EntProtoId> SelectableTypes = new();
|
2023-01-17 00:05:20 -05:00
|
|
|
|
|
2023-01-08 22:42:31 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The current amount of power being used.
|
|
|
|
|
|
/// </summary>
|
2025-08-01 13:40:15 -04:00
|
|
|
|
[DataField]
|
2023-01-08 22:42:31 -05:00
|
|
|
|
public int PowerUseActive = 600;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The amount of shots that are fired in a single "burst"
|
|
|
|
|
|
/// </summary>
|
2025-08-01 13:40:15 -04:00
|
|
|
|
[DataField]
|
2023-01-08 22:42:31 -05:00
|
|
|
|
public int FireBurstSize = 3;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The time between each shot during a burst.
|
|
|
|
|
|
/// </summary>
|
2025-08-01 13:40:15 -04:00
|
|
|
|
[DataField]
|
2023-01-08 22:42:31 -05:00
|
|
|
|
public TimeSpan FireInterval = TimeSpan.FromSeconds(2);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The current minimum delay between bursts.
|
|
|
|
|
|
/// </summary>
|
2025-08-01 13:40:15 -04:00
|
|
|
|
[DataField]
|
2023-01-08 22:42:31 -05:00
|
|
|
|
public TimeSpan FireBurstDelayMin = TimeSpan.FromSeconds(4);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The current maximum delay between bursts.
|
|
|
|
|
|
/// </summary>
|
2025-08-01 13:40:15 -04:00
|
|
|
|
[DataField]
|
2023-01-08 22:42:31 -05:00
|
|
|
|
public TimeSpan FireBurstDelayMax = TimeSpan.FromSeconds(10);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The visual state that is set when the emitter is turned on
|
|
|
|
|
|
/// </summary>
|
2025-08-01 13:40:15 -04:00
|
|
|
|
[DataField]
|
2023-01-08 22:42:31 -05:00
|
|
|
|
public string? OnState = "beam";
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The visual state that is set when the emitter doesn't have enough power.
|
|
|
|
|
|
/// </summary>
|
2025-08-01 13:40:15 -04:00
|
|
|
|
[DataField]
|
2023-01-08 22:42:31 -05:00
|
|
|
|
public string? UnderpoweredState = "underpowered";
|
2023-05-28 08:44:28 +02:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Signal port that turns on the emitter.
|
|
|
|
|
|
/// </summary>
|
2025-08-01 13:40:15 -04:00
|
|
|
|
[DataField]
|
|
|
|
|
|
public ProtoId<SinkPortPrototype> OnPort = "On";
|
2023-05-28 08:44:28 +02:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Signal port that turns off the emitter.
|
|
|
|
|
|
/// </summary>
|
2025-08-01 13:40:15 -04:00
|
|
|
|
[DataField]
|
|
|
|
|
|
public ProtoId<SinkPortPrototype> OffPort = "Off";
|
2023-05-28 08:44:28 +02:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Signal port that toggles the emitter on or off.
|
|
|
|
|
|
/// </summary>
|
2025-08-01 13:40:15 -04:00
|
|
|
|
[DataField]
|
|
|
|
|
|
public ProtoId<SinkPortPrototype> TogglePort = "Toggle";
|
2023-05-28 08:44:28 +02:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Map of signal ports to entity prototype IDs of the entity that will be fired.
|
|
|
|
|
|
/// </summary>
|
2025-08-01 13:40:15 -04:00
|
|
|
|
[DataField]
|
|
|
|
|
|
public Dictionary<ProtoId<SinkPortPrototype>, EntProtoId> SetTypePorts = new();
|
2023-01-08 22:42:31 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[NetSerializable, Serializable]
|
|
|
|
|
|
public enum EmitterVisuals : byte
|
|
|
|
|
|
{
|
|
|
|
|
|
VisualState
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
|
public enum EmitterVisualLayers : byte
|
|
|
|
|
|
{
|
|
|
|
|
|
Lights
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[NetSerializable, Serializable]
|
|
|
|
|
|
public enum EmitterVisualState
|
2020-10-28 19:19:47 +01:00
|
|
|
|
{
|
2023-01-08 22:42:31 -05:00
|
|
|
|
On,
|
|
|
|
|
|
Underpowered,
|
|
|
|
|
|
Off
|
2020-10-28 19:19:47 +01:00
|
|
|
|
}
|