From 15b1326fa7f1fd43454e2026f491b9be52e9c90d Mon Sep 17 00:00:00 2001 From: Anri Date: Thu, 8 Aug 2024 21:47:13 +0300 Subject: [PATCH] AnnoucesAndIntegrity --- .../SuperMatterObserverBUI.cs | 1 + .../SuperMatterObserverMenu.xaml | 1 + .../SuperMatterObserverMenu.xaml.cs | 1 + .../PlotFigure/Plot2DTimeView.cs | 3 + .../UserInterface/PlotFigure/Point2DHelper.cs | 1 + .../Components/SuperMatterComponent.cs | 30 ++++- .../SuperMatterSpecificConsumableComponent.cs | 2 +- .../SuperMatterInternalProcess.cs | 6 +- .../SuperMatterSystem.Announcement.cs | 125 ++++++++++++++++++ .../SuperMatterSystem.Delamination.cs | 13 ++ .../SuperMatterSystem.Integrity.cs | 87 ++++++++++++ .../SuperMatterSystem.Interaction.cs | 51 +++++++ .../SuperMatterSystem.Thermodynamics.cs | 6 +- .../SuperMatterCrystal/SuperMatterSystem.cs | 32 +++-- .../SuperMatterObserverUI.cs | 1 + 15 files changed, 336 insertions(+), 24 deletions(-) create mode 100644 Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Announcement.cs create mode 100644 Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Delamination.cs create mode 100644 Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Integrity.cs create mode 100644 Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Interaction.cs diff --git a/Content.Client/SS220/SuperMatterCrystalUIs/SuperMatterObserverBUI.cs b/Content.Client/SS220/SuperMatterCrystalUIs/SuperMatterObserverBUI.cs index b6f94cb0a0e1..b78c25890e64 100644 --- a/Content.Client/SS220/SuperMatterCrystalUIs/SuperMatterObserverBUI.cs +++ b/Content.Client/SS220/SuperMatterCrystalUIs/SuperMatterObserverBUI.cs @@ -1,3 +1,4 @@ +// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt namespace Content.Client.SS220.SuperMatterCrystalUIs; public sealed class SuperMatterObserverBUI : BoundUserInterface diff --git a/Content.Client/SS220/SuperMatterCrystalUIs/SuperMatterObserverMenu.xaml b/Content.Client/SS220/SuperMatterCrystalUIs/SuperMatterObserverMenu.xaml index bb086137ba27..b3ac3fe61e0f 100644 --- a/Content.Client/SS220/SuperMatterCrystalUIs/SuperMatterObserverMenu.xaml +++ b/Content.Client/SS220/SuperMatterCrystalUIs/SuperMatterObserverMenu.xaml @@ -1,3 +1,4 @@ + The SM will only cycle if activated. [DataField, ViewVariables(VVAccess.ReadWrite)] public bool Activated = false; + /// Super flag for freezing all SM interaction. + /// Only changing it to true will invoke base SM logic [DataField, ViewVariables(VVAccess.ReadWrite)] public bool DisabledByAdmin = false; + + + // Accumulators + [ViewVariables(VVAccess.ReadOnly)] + public float IntegrityDamageAccumulator = 0f; + [DataField, ViewVariables(VVAccess.ReadOnly)] public float AccumulatedZapEnergy = 0f; [DataField, ViewVariables(VVAccess.ReadOnly)] public float AccumulatedRadiationEnergy = 0f; - /// Current Value set to 4.1f cause for Arcs where is no point in lesser - [DataField] - public TimeSpan OutputEnergySourceUpdateDelay = TimeSpan.FromSeconds(4.1f); - [DataField, ViewVariables(VVAccess.ReadOnly)] + // TimeSpans + /// Current Value set to 3.5f cause for Arcs where is no point in lesser + [ViewVariables(VVAccess.ReadOnly)] + public TimeSpan OutputEnergySourceUpdateDelay = TimeSpan.FromSeconds(3.5f); + [ViewVariables(VVAccess.ReadOnly)] [AutoPausedField] public TimeSpan NextOutputEnergySourceUpdate = default!; - [DataField, ViewVariables(VVAccess.ReadOnly)] + [ViewVariables(VVAccess.ReadOnly)] + [AutoPausedField] + public TimeSpan NextDamageImplementTime = default!; + [ViewVariables(VVAccess.ReadOnly)] + [AutoPausedField] + public TimeSpan NextDamageStationAnnouncement = default!; + + // SM params + + [ViewVariables(VVAccess.ReadOnly)] + public float Integrity = 100f; public float Temperature = Atmospherics.T20C; [DataField, ViewVariables(VVAccess.ReadOnly)] public float Matter = 200 * SuperMatterSystem.MatterNondimensionalization; // To wrap it in own VAR diff --git a/Content.Server/SS220/SuperMatterCrystal/Components/SuperMatterSpecificConsumableComponent.cs b/Content.Server/SS220/SuperMatterCrystal/Components/SuperMatterSpecificConsumableComponent.cs index 6b839ad55442..9327df55c6ae 100644 --- a/Content.Server/SS220/SuperMatterCrystal/Components/SuperMatterSpecificConsumableComponent.cs +++ b/Content.Server/SS220/SuperMatterCrystal/Components/SuperMatterSpecificConsumableComponent.cs @@ -5,5 +5,5 @@ namespace Content.Server.SS220.SuperMatterCrystal.Components; public sealed partial class SuperMatterSpecificConsumableComponent : Component { [DataField] - public float AdditionalEnergyOnConsumption = 0f; + public float AdditionalMatterOnConsumption = 0f; } diff --git a/Content.Server/SS220/SuperMatterCrystal/SuperMatterInterior/SuperMatterInternalProcess.cs b/Content.Server/SS220/SuperMatterCrystal/SuperMatterInterior/SuperMatterInternalProcess.cs index f3be684cab48..b2514e76a47d 100644 --- a/Content.Server/SS220/SuperMatterCrystal/SuperMatterInterior/SuperMatterInternalProcess.cs +++ b/Content.Server/SS220/SuperMatterCrystal/SuperMatterInterior/SuperMatterInternalProcess.cs @@ -3,7 +3,7 @@ using Content.Shared.Atmos; namespace Content.Server.SS220.SuperMatterCrystal; -/// TODO DESC + public static class SuperMatterInternalProcess { private const float TriplePointTemperature = SuperMatterPhaseDiagram.SuperMatterTriplePointTemperature; @@ -72,12 +72,10 @@ public static float GetZapToRadiationRatio(float temperature, float pressure, Su private const float O2ToPlasmaFloatRatio = 1.7f; private const float RatioValueOffset = 0.44f; private const float SqrtOfMaxRatioValue = 1.2f; - /// MADE IT! - /// public static float GetOxygenToPlasmaRatio(float temperature, float pressure, SuperMatterPhaseState smState) { var ratio = GetZapToRadiationRatio(temperature, pressure, smState); - return (O2ToPlasmaBaseRatio + O2ToPlasmaFloatRatio * MathF.Sqrt(ratio+RatioValueOffset)) + return (O2ToPlasmaBaseRatio + O2ToPlasmaFloatRatio * MathF.Sqrt(ratio + RatioValueOffset)) / (O2ToPlasmaBaseRatio + O2ToPlasmaFloatRatio * SqrtOfMaxRatioValue); } diff --git a/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Announcement.cs b/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Announcement.cs new file mode 100644 index 000000000000..207a65591122 --- /dev/null +++ b/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Announcement.cs @@ -0,0 +1,125 @@ +// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt +using System.Diagnostics.CodeAnalysis; +using Content.Server.Chat.Managers; +using Content.Server.Chat.Systems; +using Content.Server.SS220.SuperMatterCrystal.Components; +using Content.Shared.Radio; +using Robust.Shared.Prototypes; + +namespace Content.Server.SS220.SuperMatterCrystal; + +public sealed partial class SuperMatterSystem : EntitySystem +{ + [Dependency] IChatManager _chatManager = default!; + [Dependency] ChatSystem _chatSystem = default!; + [Dependency] IPrototypeManager _prototypeManager = default!; + private ProtoId _engineerRadio = "Engineering"; + private ProtoId _commonRadio = "Common"; + private char _engineerRadioKey = '\0'; + private char _commonRadioKey = '\0'; + + + private void InitializeAnnouncement() + { + _engineerRadioKey = _prototypeManager.Index(_engineerRadio).KeyCode; + _commonRadioKey = _prototypeManager.Index(_commonRadio).KeyCode; + } + + public void RadioAnnounceIntegrity(Entity crystal, AnnounceIntegrityTypeEnum announceType) + { + if (announceType == AnnounceIntegrityTypeEnum.None) + return; + var integrity = GetIntegrity(crystal.Comp); + var localePath = "supermatter-" + announceType.ToString().ToLower(); + var message = Loc.GetString(localePath, ("integrity", integrity)); + if (TryGetChannelKey(announceType, out var channelKey)) + message = channelKey + message; + RadioAnnouncement(crystal.Owner, message); + } + public void StationAnnounceIntegrity(Entity crystal, AnnounceIntegrityTypeEnum announceType) + { + if (!(announceType == AnnounceIntegrityTypeEnum.DelaminationStopped + || announceType == AnnounceIntegrityTypeEnum.Delamination)) + return; + var integrity = GetIntegrity(crystal.Comp); + var localePath = "supermatter-" + announceType.ToString().ToLower(); + var message = Loc.GetString(localePath, ("integrity", integrity)); + } + + private void SendAdminChatAlert(Entity crystal, string msg, string? whom = null) + { + var startString = $"SuperMatter {crystal} Alert! "; + var endString = ""; + if (whom != null) + endString = $" caused by {whom}."; + _chatManager.SendAdminAlert(startString + msg + endString); + } + private void SendStationAnnouncement(EntityUid uid, string message, string? sender = null) + { + var localizedSender = GetLocalizedSender(sender); + + _chatSystem.DispatchStationAnnouncement(uid, message, localizedSender, colorOverride: Color.FromHex("#deb63d")); + return; + } + private void RadioAnnouncement(EntityUid uid, string message) + { + _chatSystem.TrySendInGameICMessage(uid, message, InGameICChatType.Speak, false, checkRadioPrefix: true); + } + private string GetLocalizedSender(string? sender) + { + var resultSender = sender ?? "supermatter-announcer"; + if (!Loc.TryGetString(resultSender, out var localizedSender)) + localizedSender = resultSender; + return localizedSender; + } + /// Gets announce type, do it before zeroing AccumulatedDamage + /// + /// + private AnnounceIntegrityTypeEnum GetAnnounceIntegrityType(SuperMatterComponent smComp) + { + var type = AnnounceIntegrityTypeEnum.Error; + if (smComp.IntegrityDamageAccumulator > 0) + type = smComp.Integrity switch + { + < 15f => AnnounceIntegrityTypeEnum.Delamination, + < 35f => AnnounceIntegrityTypeEnum.Danger, + < 80f => AnnounceIntegrityTypeEnum.Warning, + _ => AnnounceIntegrityTypeEnum.None + }; + else type = smComp.Integrity switch + { + < 15f => AnnounceIntegrityTypeEnum.DelaminationStopped, + < 35f => AnnounceIntegrityTypeEnum.DangerRecovering, + < 80f => AnnounceIntegrityTypeEnum.WarningRecovering, + _ => AnnounceIntegrityTypeEnum.None + }; + + return type; + } + private bool TryGetChannelKey(AnnounceIntegrityTypeEnum announceType, [NotNullWhen(true)] out char? channelKey) + { + channelKey = announceType switch + { + AnnounceIntegrityTypeEnum.DangerRecovering => _commonRadioKey, + AnnounceIntegrityTypeEnum.Danger => _commonRadioKey, + AnnounceIntegrityTypeEnum.Delamination => _commonRadioKey, + AnnounceIntegrityTypeEnum.DelaminationStopped => _commonRadioKey, + AnnounceIntegrityTypeEnum.Warning => _engineerRadioKey, + AnnounceIntegrityTypeEnum.WarningRecovering => _engineerRadioKey, + _ => null + }; + return channelKey is not null; + } +} + +public enum AnnounceIntegrityTypeEnum +{ + Error = -1, + None, + Warning, + Danger, + WarningRecovering, + DangerRecovering, + Delamination, + DelaminationStopped +} diff --git a/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Delamination.cs b/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Delamination.cs new file mode 100644 index 000000000000..7f4824b06b79 --- /dev/null +++ b/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Delamination.cs @@ -0,0 +1,13 @@ +// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt +using Content.Server.SS220.SuperMatterCrystal.Components; + +namespace Content.Server.SS220.SuperMatterCrystal; + +public sealed partial class SuperMatterSystem : EntitySystem +{ + /// !TODO IT! + private void MarkAsLaminated(Entity crystal) + { + // TODO + } +} diff --git a/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Integrity.cs b/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Integrity.cs new file mode 100644 index 000000000000..8262b9d834d3 --- /dev/null +++ b/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Integrity.cs @@ -0,0 +1,87 @@ +// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt +using Content.Shared.Atmos; +using Content.Server.SS220.SuperMatterCrystal.Components; + +namespace Content.Server.SS220.SuperMatterCrystal; + +public sealed partial class SuperMatterSystem : EntitySystem +{ + /// Based lie, negative damage = heal, no exception will thrown + /// if positive - damage, if negative - heal + public float GetIntegrityDamage(SuperMatterComponent smComp) + { + var (internalEnergy, matter, temperature) = (smComp.InternalEnergy, smComp.Matter, smComp.Temperature); + var damageFromDelta = GetInternalEnergyToMatterDamageFactor(internalEnergy, matter); + var temperatureFactor = TemperatureDamageFactorFunction(temperature); + var damage = damageFromDelta > 0 ? damageFromDelta * temperatureFactor : damageFromDelta; + return damage; + } + public float GetInternalEnergyToMatterDamageFactor(float internalEnergy, float matter) + { + var safeInternalEnergy = GetSafeInternalEnergyToMatterValue(matter); + var delta = internalEnergy - safeInternalEnergy; + var damageFromDelta = EnergyToMatterDamageFactorFunction(delta); + return damageFromDelta; + } + public float GetSafeInternalEnergyToMatterValue(float matter) + { + var normalizedMatter = matter / MatterNondimensionalization; + return SafeInternalEnergyToMatterFunction(normalizedMatter); + } + public void AddIntegrityDamage(SuperMatterComponent smComp, float damage) + { + smComp.IntegrityDamageAccumulator += damage; + } + public float GetIntegrity(SuperMatterComponent smComp) + { + return MathF.Round(smComp.Integrity, 2); + } + + private const float MaxDamagePerSecond = 1.5f; + private const float MaxRegenerationPerSecond = 1.5f; + /// Based lie, negative damage = heal, no exception will thrown + /// Return false only if SM integrity WILL fall below zero, but wont set it to zero + private bool TryImplementIntegrityDamage(SuperMatterComponent smComp) + { + var resultIntegrityDamage = Math.Clamp(smComp.IntegrityDamageAccumulator, -MaxDamagePerSecond, MaxRegenerationPerSecond); + if (smComp.Integrity + resultIntegrityDamage < 0f) + return false; + if (smComp.Integrity + resultIntegrityDamage < 100f) + { + smComp.Integrity += resultIntegrityDamage; + return true; + } + if (smComp.Integrity != 100f) + smComp.Integrity = 100f; + return true; + } + + private const float EnergyToMatterDamageFactorSlowerOffset = 1000f; + private const float EnergyToMatterDamageFactorDeltaOffset = 1000f; + private float EnergyToMatterDamageFactorFunction(float delta) + { + var offsetedDelta = delta - EnergyToMatterDamageFactorDeltaOffset; + return offsetedDelta / (MathF.Abs(offsetedDelta) + EnergyToMatterDamageFactorSlowerOffset); + } + + private const float SafeInternalEnergyToMatterCoeff = 800f; + private const float SafeInternalEnergyToMatterSlowerOffset = 50f; + private float SafeInternalEnergyToMatterFunction(float normalizedMatter) + { + return SafeInternalEnergyToMatterCoeff * MathF.Pow(normalizedMatter, 1.5f) + / (normalizedMatter + SafeInternalEnergyToMatterSlowerOffset); + } + + private const float TemperatureDamageFactorCoeff = 3f; + private const float TemperatureDamageFactorSlowerOffset = 20f; + private float TemperatureDamageFactorFunction(float normalizedTemperature) + { + var normalizedMaxTemperature = Atmospherics.Tmax / SuperMatterPhaseDiagram.SuperMatterTriplePointTemperature; + var maxFuncValue = MathF.Pow(normalizedMaxTemperature, 1.5f) / + (normalizedMaxTemperature - TemperatureDamageFactorSlowerOffset); + + return TemperatureDamageFactorCoeff * (MathF.Pow(normalizedTemperature, 1.5f) / + (normalizedTemperature - TemperatureDamageFactorSlowerOffset)) / maxFuncValue; + } + +} diff --git a/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Interaction.cs b/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Interaction.cs new file mode 100644 index 000000000000..13ff8bfd00d7 --- /dev/null +++ b/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Interaction.cs @@ -0,0 +1,51 @@ +// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt +using Robust.Shared.Physics; +using Robust.Shared.Physics.Events; +using Content.Server.SS220.SuperMatterCrystal.Components; +using Content.Shared.Interaction; +using Content.Shared.Projectiles; + +namespace Content.Server.SS220.SuperMatterCrystal; + +public sealed partial class SuperMatterSystem : EntitySystem +{ + private void InitializeInteractions() + { + // subscribe Events + SubscribeLocalEvent(OnHandInteract); + SubscribeLocalEvent(OnItemInteract); + SubscribeLocalEvent(OnCollideEvent); + } + private void OnHandInteract(Entity entity, ref InteractHandEvent args) + { + entity.Comp.Matter += MatterNondimensionalization; + ConsumeObject(args.User, entity.Comp); + } + private void OnItemInteract(Entity entity, ref InteractUsingEvent args) + { + entity.Comp.Matter += MatterNondimensionalization / 4; + ConsumeObject(args.User, entity.Comp); + } + private void OnCollideEvent(Entity entity, ref StartCollideEvent args) + { + if (args.OtherBody.BodyType == BodyType.Static) + return; + if (TryComp(args.OtherEntity, out var projectile)) + entity.Comp.InternalEnergy += CHEMISTRY_POTENTIAL_BASE * MathF.Max((float) projectile.Damage.GetTotal(), 0f); + entity.Comp.Matter += MatterNondimensionalization / 4; + ConsumeObject(args.OtherEntity, entity.Comp); + } + private void ConsumeObject(EntityUid uid, SuperMatterComponent smComp) + { + if (smComp.DisabledByAdmin) + return; + if (HasComp(uid)) + return; + if (!smComp.Activated) + smComp.Activated = true; + if (TryComp(uid, out var consumableComponent)) + smComp.Matter += consumableComponent.AdditionalMatterOnConsumption; + // TODO: Spawn Ash & make sound/popup + EntityManager.QueueDeleteEntity(uid); + } +} diff --git a/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Thermodynamics.cs b/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Thermodynamics.cs index 8a306fcb8a61..a558eab227fe 100644 --- a/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Thermodynamics.cs +++ b/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.Thermodynamics.cs @@ -36,7 +36,7 @@ [ ] Make Internal log of starting SM /// Defines how fast SM gets in thermal equilibrium with gas in it. Do not make it greater than 1! private const float SM_HEAT_TRANSFER_RATIO = 0.07f; - public void EvaluateDeltaInternalEnergy(Entity crystal, GasMixture gasMixture, float frameTime) + private void EvaluateDeltaInternalEnergy(Entity crystal, GasMixture gasMixture, float frameTime) { var (crystalUid, smComp) = crystal; var chemistryPotential = GetChemistryPotential(smComp.Temperature, gasMixture.Pressure); @@ -61,11 +61,11 @@ public void EvaluateDeltaInternalEnergy(Entity crystal, Ga { // TODO loc it Log.Error($"Internal Energy of SuperMatter {crystal} became negative, forced to truthish value."); - _chatManager.SendAdminAlert($"SuperMatter {crystal} caught physics law breaking! If it possible ask how they do it and convey it to developer"); + SendAdminChatAlert(crystal, "Physics law breaking! If it possible ask how they do it and convey it to developer"); smComp.InternalEnergy = EvaluateTruthishInternalEnergy(crystal); } smComp.Matter = MathF.Max(smComp.Matter + deltaMatter * frameTime, MatterNondimensionalization); // actually should go boom at this low, but... - smComp.Temperature = MathF.Max(MathF.Min(Atmospherics.Tmax, smComp.Temperature + smDeltaT * frameTime), Atmospherics.TCMB); // weird but okay + smComp.Temperature = Math.Clamp(smComp.Temperature + smDeltaT * frameTime, Atmospherics.TCMB, Atmospherics.Tmax); // weird but okay _atmosphere.AddHeat(gasMixture, -crystalHeatFromGas * frameTime); } /// We dont apply it to Matter field of SMComp because we need this value in internal energy evaluation diff --git a/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.cs b/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.cs index 74ac1be90e1f..0911d35d9689 100644 --- a/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.cs +++ b/Content.Server/SS220/SuperMatterCrystal/SuperMatterSystem.cs @@ -1,17 +1,14 @@ // © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt -using Content.Server.Chat.Managers; using Content.Server.SS220.SuperMatterCrystal.Components; using Content.Server.Tesla.Components; using Content.Shared.Radiation.Components; using Content.Shared.Atmos; - using Robust.Shared.Timing; namespace Content.Server.SS220.SuperMatterCrystal; public sealed partial class SuperMatterSystem : EntitySystem { - [Dependency] IChatManager _chatManager = default!; [Dependency] IGameTiming _gameTiming = default!; private const float ZapPerEnergy = 60f; @@ -21,27 +18,42 @@ public sealed partial class SuperMatterSystem : EntitySystem private const float MaxTimeDecreaseBetweenArcs = 4f; private const int MaxAmountOfArcs = 7; private const float ArcsToTimeDecreaseEfficiency = 0.3f; + private const float IntegrityDamageICAnnounceDelay = 10f; + private const float IntegrityDamageStationAnnouncementDelay = 20f; public override void Initialize() { base.Initialize(); + InitializeAnnouncement(); + InitializeInteractions(); + SubscribeLocalEvent(OnComponentInit); - // subscribe FCK EVENTS } public override void Update(float frameTime) { base.Update(frameTime); - var curTime = _gameTiming.CurTime; var query = EntityQueryEnumerator(); while (query.MoveNext(out var uid, out var smComp)) { + if (!smComp.Activated) + continue; var crystal = new Entity(uid, smComp); - UpdateSuperMatter(crystal, frameTime); + SuperMatterUpdate(crystal, frameTime); + if (_gameTiming.CurTime > smComp.NextDamageImplementTime) + { + if (!TryImplementIntegrityDamage(smComp)) + MarkAsLaminated(crystal); + var announceType = GetAnnounceIntegrityType(smComp); + RadioAnnounceIntegrity(crystal, announceType); + smComp.IntegrityDamageAccumulator = 0f; + smComp.NextDamageImplementTime = _gameTiming.CurTime + + TimeSpan.FromSeconds(IntegrityDamageICAnnounceDelay); + } } } - private void UpdateSuperMatter(Entity crystal, float frameTime) + private void SuperMatterUpdate(Entity crystal, float frameTime) { if (!crystal.Comp.Activated) return; @@ -76,9 +88,9 @@ private void UpdateSuperMatter(Entity crystal, float frame EjectGases(decayedMatter, crystalTemperature, smState, gasMixture); } - // You can cry about it. Entity not supported in ComponentInit - private void OnComponentInit(EntityUid uid, SuperMatterComponent smComp, ComponentInit args) + private void OnComponentInit(Entity entity, ref ComponentInit args) { + var (uid, _) = entity; RadiationSourceComponent? radiationSource = null; LightningArcShooterComponent? arcShooterComponent = null; @@ -125,7 +137,7 @@ private void ReleaseEnergy(Entity crystal) var radiationIntensity = smComp.AccumulatedRadiationEnergy / RadiationPerEnergy; radiationSource.Intensity = radiationIntensity; } - private void EjectGases(float decayedMatter, float crystalTemperature, SuperMatterPhaseState smState , GasMixture gasMixture) + private void EjectGases(float decayedMatter, float crystalTemperature, SuperMatterPhaseState smState, GasMixture gasMixture) { var pressure = gasMixture.Pressure; var oxygenMoles = decayedMatter * GetOxygenToPlasmaRatio(crystalTemperature, pressure, smState); diff --git a/Content.Shared/SS220/SuperMatterCrystalUI/SuperMatterObserverUI.cs b/Content.Shared/SS220/SuperMatterCrystalUI/SuperMatterObserverUI.cs index 5d9761073a36..9cc2a636cbe9 100644 --- a/Content.Shared/SS220/SuperMatterCrystalUI/SuperMatterObserverUI.cs +++ b/Content.Shared/SS220/SuperMatterCrystalUI/SuperMatterObserverUI.cs @@ -1,3 +1,4 @@ +// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt using Robust.Shared.Serialization; namespace Content.Shared.Store;