using System.Threading;
using Content.Shared.Construction.Prototypes;
using Robust.Shared.Audio;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Singularity.Components
{
[RegisterComponent]
public sealed class EmitterComponent : Component
{
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;
// For the "emitter fired" sound
public const float Variation = 0.25f;
public const float Volume = 0.5f;
public const float Distance = 6f;
///
/// counts the number of consecutive shots fired.
///
[ViewVariables]
public int FireShotCounter;
[DataField("fireSound"), ViewVariables]
public SoundSpecifier FireSound = new SoundPathSpecifier("/Audio/Weapons/emitter.ogg");
///
/// The entity that is spawned when the emitter fires.
///
[DataField("boltType"), ViewVariables]
public string BoltType = "EmitterBolt";
///
/// The current amount of power being used.
///
[DataField("powerUseActive"), ViewVariables]
public int PowerUseActive = 600;
///
/// The base amount of power that is consumed.
/// Used in machine part rating calculations.
///
[DataField("basePowerUseActive"), ViewVariables(VVAccess.ReadWrite)]
public int BasePowerUseActive = 600;
///
/// Multiplier that is applied to the basePowerUseActive
/// to get the actual power use.
///
[DataField("powerUseMultiplier")]
public float PowerUseMultiplier = 0.75f;
///
/// The machine part used to reduce the power use of the machine.
///
[DataField("machinePartPowerUse", customTypeSerializer: typeof(PrototypeIdSerializer))]
public string MachinePartPowerUse = "Capacitor";
///
/// The amount of shots that are fired in a single "burst"
///
[DataField("fireBurstSize"), ViewVariables]
public int FireBurstSize = 3;
///
/// The time between each shot during a burst.
///
[DataField("fireInterval"), ViewVariables]
public TimeSpan FireInterval = TimeSpan.FromSeconds(2);
///
/// The base amount of time between each shot during a burst.
///
[DataField("baseFireInterval"), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan BaseFireInterval = TimeSpan.FromSeconds(2);
///
/// The current minimum delay between bursts.
///
[DataField("fireBurstDelayMin"), ViewVariables]
public TimeSpan FireBurstDelayMin = TimeSpan.FromSeconds(4);
///
/// The current maximum delay between bursts.
///
[DataField("fireBurstDelayMax"), ViewVariables]
public TimeSpan FireBurstDelayMax = TimeSpan.FromSeconds(10);
///
/// The base minimum delay between shot bursts.
/// Used for machine part rating calculations.
///
[DataField("baseFireBurstDelayMin"), ViewVariables]
public TimeSpan BaseFireBurstDelayMin = TimeSpan.FromSeconds(4);
///
/// The base maximum delay between shot bursts.
/// Used for machine part rating calculations.
///
[DataField("baseFireBurstDelayMax"), ViewVariables]
public TimeSpan BaseFireBurstDelayMax = TimeSpan.FromSeconds(10);
///
/// The multiplier for the base delay between shot bursts as well as
/// the fire interval
///
[DataField("fireRateMultiplier"), ViewVariables(VVAccess.ReadWrite)]
public float FireRateMultiplier = 0.8f;
///
/// The machine part that affects burst delay.
///
[DataField("machinePartFireRate", customTypeSerializer: typeof(PrototypeIdSerializer))]
public string MachinePartFireRate = "Laser";
}
}