using Content.Shared.Atmos;
using Robust.Shared.Audio;
namespace Content.Server.Supermatter.Components;
[RegisterComponent]
public sealed partial class SupermatterComponent : Component
{
///
/// The damage taken from direct hits, e.g. laser weapons
///
[ViewVariables(VVAccess.ReadOnly)]
public float AVExternalDamage = 0f;
//
[ViewVariables(VVAccess.ReadOnly)]
public float HeatAccumulatorRate = 0.5f;
[ViewVariables(VVAccess.ReadOnly)]
public float AVHeatAccumulator = 0f;
[ViewVariables(VVAccess.ReadOnly)]
public float RadiationAccumulatorRate = 0.3f;
[ViewVariables(VVAccess.ReadOnly)]
public float AVRadiationAccumulator = 0f;
[ViewVariables(VVAccess.ReadOnly)]
public float LightingAccumulatorThreshold = 2f;
[ViewVariables(VVAccess.ReadOnly)]
public float LightingAccumulatorRate = 0.1f;
[ViewVariables(VVAccess.ReadOnly)]
public float AVLightingAccumulator = 0f;
[ViewVariables(VVAccess.ReadOnly)]
public float InternalEnergyAccumulatorRate = 0.1f;
///
/// Lightning prototype IDs that the supermatter should spit out.
///
public readonly string[] LightningPrototypeIDs =
{
"Lightning",
"ChargedLightning",
"SuperchargedLightning",
"HyperchargedLightning"
};
public readonly string SliverPrototype = "SupermatterSliver";
[DataField("zapSound")]
public static SoundSpecifier SupermatterZapSound = new SoundPathSpecifier("/Audio/Weapons/emitter2.ogg");
[DataField("calmAmbienceSound")]
public SoundSpecifier CalmAmbienceSound = new SoundPathSpecifier("/Audio/Ambience/Objects/supermatter_calm.ogg");
[DataField("delamAmbienceSound")]
public SoundSpecifier DelamAmbienceSound = new SoundPathSpecifier("/Audio/Ambience/Objects/supermatter_delam.ogg");
[ViewVariables]
public SoundSpecifier CurrentAmbience = new SoundPathSpecifier("/Audio/Ambience/Objects/supermatter_calm.ogg");
[DataField("vaporizeSound")]
public static SoundSpecifier VaporizeSound = new SoundPathSpecifier("/Audio/Effects/Grenades/Supermatter/supermatter_start.ogg");
[DataField("teslaSpawnPrototype")]
public string TeslaPrototype = "TeslaEnergyBall";
[DataField("singularitySpawnPrototype")]
public string SingularityPrototype = "Singularity";
[DataField("supermatterKudzuSpawnPrototype")]
public string SupermatterKudzuPrototype = "SupermatterKudzu";
///
/// If a supermatter sliver has been removed. Lowers the delamination countdown time.
///
[ViewVariables(VVAccess.ReadOnly)]
public bool SliverRemoved = false;
///
/// Indicates whether supermatter crystal is active or not.
///
[DataField("activated")]
public bool Activated = false;
[ViewVariables]
public GasMixture AbsorbedGasMix = new();
///
/// Delta time between Update() calls storage.
///
public float DeltaTime = 0f;
public float UpdateTimerAccumulator = 0f;
public float AnnouncementTimerAccumulator = 0f;
///
/// Amount of seconds to pass before another SM cycle.
///
[DataField("updateTimer")]
public float UpdateTimer = 1f;
///
/// Amount of seconds to pass before makes an announcement.
///
[DataField("announcementTimer")]
public float AnnouncementTimer = 60f;
[ViewVariables(VVAccess.ReadWrite)]
public int? PreferredDelamType = 0;
///
/// The time in seconds for crystal to delaminate.
///
[DataField("countdownTimer")]
public float DelamCountdownTimerRaw = 120f;
public float DelamCountdownTimer => SliverRemoved ? DelamCountdownTimerRaw / 2 : DelamCountdownTimerRaw;
public bool DelamAnnouncementHappened = false;
[ViewVariables(VVAccess.ReadWrite)]
public float DelamCountdownAccumulator = 0f;
///
/// The portion of gasmix we should absorb.
///
[DataField("gasAbsorptionRatio")]
public float AbsorptionRatio = .15f;
///
/// This value effects gas output, damage and power generation.
///
[ViewVariables(VVAccess.ReadOnly)]
public float InternalEnergy = 0f;
///
/// The amount of damage the SM currently has.
///
[DataField("damage")]
public float Damage = 0f;
///
/// The amount of damage SM had before the cycle.
///
public float DamageArchive = 0f;
///
/// The temperature at which the supermatter crystal will begin to take damage.
///
[ViewVariables(VVAccess.ReadOnly)]
public float TempLimit = Atmospherics.T0C + HeatPenaltyThreshold;
///
/// Multiplies our gas waste amount and temperature.
///
[ViewVariables(VVAccess.ReadOnly)]
public float WasteMultiplier = 0f;
[DataField("damageDangerPoint")]
public float DamageDangerPoint = 50f;
[DataField("damageEmergencyPoint")]
public float DamageEmergencyPoint = 75f;
[DataField("damageDelaminationPoint")]
public float DelaminationPoint = 100f;
[ViewVariables(VVAccess.ReadOnly)]
public bool AreWeDelaming = false;
///
/// Affects the heat SM makes.
///
[ViewVariables(VVAccess.ReadOnly)]
public float GasHeatModifier = 0f;
///
/// Affters the minimum point at which SM takes damage.
///
[ViewVariables(VVAccess.ReadOnly)]
public float GasHeatResistance = 0f;
///
/// How much power decay is negated. Complete power decay negation at 1.
///
[ViewVariables(VVAccess.ReadOnly)]
public float GasPowerlossInhibition = 0f;
[ViewVariables(VVAccess.ReadOnly)]
public float ThermalСonductivity = 0f;
///
/// Affects the power gain the SM experiences from heat.
///
[ViewVariables(VVAccess.ReadOnly)]
public float HeatPowerGeneration = 0f;
///
/// Lesser than that and it's not worth processing.
///
public const float MinimumMoleCount = .01f;
public const float HeatPenaltyThreshold = 40f;
public const float PowerPenaltyThreshold = 3f;
public const float MolePenaltyThreshold = 900f;
public const float ThermalReleaseModifier = 4f;
public const float PlasmaReleaseModifier = 1.5f;
public const float OxygenReleaseModifier = 2.5f;
public const float GasHeatPowerScaling = 1f / 6f;
///
/// Stores gas properties used for the supermatter.
/// Array values should alwayd match gas enum values.
///
[ViewVariables(VVAccess.ReadOnly)]
public GasFact[] GasFacts =
{
new (thermalConductivity: 2.4f, heatPowerGeneration: 1f), // o2
new (thermalConductivity: 2.0f, heatModifier: -2.5f, heatPowerGeneration: -1), // n2
new (thermalConductivity: 1.2f, heatModifier: 1f, heatPowerGeneration: 1f, powerlossInhibition: 1f), // co2
new (thermalConductivity: 6.0f, heatModifier: 14f, heatPowerGeneration: 1f), // plasma
new (thermalConductivity: 3.0f, heatModifier: 9f, heatPowerGeneration: 1f), // tritium
new (thermalConductivity: 1.4f, heatModifier: 11f, heatPowerGeneration: 1f), // vapor
new (thermalConductivity: 1.6f, heatPowerGeneration: .5f), // ommonium
new (thermalConductivity: 1.3f, heatResistance: 5f), // n2o
new (thermalConductivity: 9.9f, heatModifier: 9f, heatResistance: 1f, heatPowerGeneration: 1f), // frezon
};
}
///
/// Stores gas properties used for the supermatter.
///
[Serializable]
[DataDefinition]
public sealed partial class GasFact
{
///
/// Affects the amount of power the main SM zap makes.
///
[ViewVariables(VVAccess.ReadWrite)]
public float ThermalСonductivity;
///
/// Affects the heat SM makes.
///
[ViewVariables(VVAccess.ReadWrite)]
public float HeatModifier;
///
/// Affters the minimum point at which SM takes damage.
///
[ViewVariables(VVAccess.ReadWrite)]
public float HeatResistance;
///
/// Affects the power gain the SM experiences from heat.
///
[ViewVariables(VVAccess.ReadWrite)]
public float HeatPowerGeneration;
///
/// How much power decay is negated. Complete power decay negation at 1.
///
[ViewVariables(VVAccess.ReadWrite)]
public float PowerlossInhibition;
public GasFact(float? thermalConductivity = null, float? heatModifier = null, float? heatResistance = null, float? heatPowerGeneration = null, float? powerlossInhibition = null)
{
ThermalСonductivity = thermalConductivity ?? 1;
HeatModifier = heatModifier ?? 1;
HeatResistance = heatResistance ?? 0;
HeatPowerGeneration = heatPowerGeneration ?? 0;
PowerlossInhibition = powerlossInhibition ?? 0;
}
}
///
/// Type of delamination that should occur.
///
public enum DelamType : sbyte
{
Explosion = 0,
Tesla = 1,
Singularity = 2,
ResonanceCascade = 3,
}