diff --git a/Content.Server/_EE/Supermatter/Systems/SupermatterSystem.Processing.cs b/Content.Server/_EE/Supermatter/Systems/SupermatterSystem.Processing.cs index 6e1e0b63a5..edbb8b13bd 100644 --- a/Content.Server/_EE/Supermatter/Systems/SupermatterSystem.Processing.cs +++ b/Content.Server/_EE/Supermatter/Systems/SupermatterSystem.Processing.cs @@ -1,20 +1,16 @@ using System.Linq; using System.Text; -using Content.Server.Chat.Systems; using Content.Server.Explosion.EntitySystems; using Content.Server.Sound.Components; -using Content.Shared._EE.CCVars; using Content.Shared._EE.Supermatter.Components; using Content.Shared._EE.Supermatter.Monitor; using Content.Shared.Atmos; using Content.Shared.Audio; -using Content.Shared.CCVar; using Content.Shared.Chat; using Content.Shared.Popups; using Content.Shared.Radiation.Components; using Content.Shared.Speech; using Robust.Shared.Audio; -using Robust.Shared.Configuration; using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Random; @@ -108,14 +104,14 @@ public sealed partial class SupermatterSystem sm.Power = Math.Max(absorbedGas.Temperature * tempFactor / Atmospherics.T0C * powerRatio + sm.Power, 0); // Irradiate stuff - if (TryComp(uid, out var rad)) + if (sm.Activated && TryComp(uid, out var rad)) { rad.Intensity = - _config.GetCVar(ECCVars.SupermatterRadsBase) + + SupermatterRadsBase + (sm.Power * Math.Max(0, 1f + transmissionBonus / 10f) * 0.003f - * _config.GetCVar(ECCVars.SupermatterRadsModifier)); + * SupermatterRadsModifier); rad.Slope = Math.Clamp(rad.Intensity / 15, 0.2f, 1f); } @@ -323,7 +319,7 @@ public sealed partial class SupermatterSystem { message = Loc.GetString("supermatter-delam-cancel", ("integrity", integrity)); sm.DelamAnnounced = false; - sm.YellTimer = TimeSpan.FromSeconds(_config.GetCVar(ECCVars.SupermatterYellTimer)); + sm.YellTimer = TimeSpan.FromSeconds(SupermatterYellTimer); global = true; SendSupermatterAnnouncement(uid, sm, message, global); @@ -350,7 +346,7 @@ public sealed partial class SupermatterSystem > 30 => TimeSpan.FromSeconds(10), > 5 => TimeSpan.FromSeconds(5), <= 5 => TimeSpan.FromSeconds(1), - _ => TimeSpan.FromSeconds(_config.GetCVar(ECCVars.SupermatterYellTimer)) + _ => TimeSpan.FromSeconds(SupermatterYellTimer) }; message = Loc.GetString(loc, ("seconds", seconds)); @@ -429,8 +425,8 @@ public sealed partial class SupermatterSystem /// public DelamType ChooseDelamType(EntityUid uid, SupermatterComponent sm) { - if (_config.GetCVar(ECCVars.SupermatterDoForceDelam)) - return _config.GetCVar(ECCVars.SupermatterForcedDelamType); + if (SupermatterDoForceDelam) + return SupermatterForcedDelamType; var mix = _atmosphere.GetContainingMixture(uid, true, true); @@ -439,13 +435,13 @@ public sealed partial class SupermatterSystem var absorbedGas = mix.Remove(sm.GasEfficiency * mix.TotalMoles); var moles = absorbedGas.TotalMoles; - if (_config.GetCVar(ECCVars.SupermatterDoSingulooseDelam) - && moles >= sm.MolePenaltyThreshold * _config.GetCVar(ECCVars.SupermatterSingulooseMolesModifier)) + if (SupermatterDoSingulooseDelam + && moles >= sm.MolePenaltyThreshold * SupermatterSingulooseMolesModifier) return DelamType.Singulo; } - if (_config.GetCVar(ECCVars.SupermatterDoTeslooseDelam) - && sm.Power >= sm.PowerPenaltyThreshold * _config.GetCVar(ECCVars.SupermatterTesloosePowerModifier)) + if (SupermatterDoTeslooseDelam + && sm.Power >= sm.PowerPenaltyThreshold * SupermatterTesloosePowerModifier) return DelamType.Tesla; //TODO: Add resonance cascade when there's crazy conditions or a destabilizing crystal diff --git a/Content.Server/_EE/Supermatter/Systems/SupermatterSystem.cs b/Content.Server/_EE/Supermatter/Systems/SupermatterSystem.cs index a29b5049a5..11384a3cc6 100644 --- a/Content.Server/_EE/Supermatter/Systems/SupermatterSystem.cs +++ b/Content.Server/_EE/Supermatter/Systems/SupermatterSystem.cs @@ -1,24 +1,17 @@ -using Content.Server.AlertLevel; using Content.Server.Atmos.EntitySystems; using Content.Server.Atmos.Piping.Components; using Content.Server.Chat.Systems; -using Content.Server.Decals; using Content.Server.DoAfter; using Content.Server.Explosion.EntitySystems; using Content.Server.Kitchen.Components; using Content.Server.Lightning; -using Content.Server.Lightning.Components; using Content.Server.Popups; using Content.Server.Radio.EntitySystems; -using Content.Server.Speech; -using Content.Server.Station.Systems; using Content.Shared._EE.CCVars; using Content.Shared._EE.Supermatter.Components; using Content.Shared._EE.Supermatter.Monitor; using Content.Shared.Atmos; using Content.Shared.Audio; -using Content.Shared.Body.Components; -using Content.Shared.CCVar; using Content.Shared.DoAfter; using Content.Shared.Examine; using Content.Shared.Interaction; @@ -47,9 +40,6 @@ public sealed partial class SupermatterSystem : EntitySystem [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedAmbientSoundSystem _ambient = default!; [Dependency] private readonly LightningSystem _lightning = default!; - [Dependency] private readonly AlertLevelSystem _alert = default!; - [Dependency] private readonly StationSystem _station = default!; - [Dependency] private readonly MapSystem _map = default!; [Dependency] private readonly DoAfterSystem _doAfter = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly PopupSystem _popup = default!; @@ -57,14 +47,35 @@ public sealed partial class SupermatterSystem : EntitySystem [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IRobustRandom _random = default!; + // As a performance optimization, we store the CVars here so that fetching them repeatedly on every frame isn't necessary. + public float SupermatterSingulooseMolesModifier { get; private set; } + public bool SupermatterDoSingulooseDelam { get; private set; } + public float SupermatterTesloosePowerModifier { get; private set; } + public bool SupermatterDoTeslooseDelam { get; private set; } + public bool SupermatterDoForceDelam { get; private set; } + public DelamType SupermatterForcedDelamType { get; private set; } + public float SupermatterRadsBase { get; private set; } + public float SupermatterRadsModifier { get; private set; } + public float SupermatterYellTimer { get; private set; } public override void Initialize() { base.Initialize(); + // CVar subscriptions + Subs.CVar(_config, ECCVars.SupermatterSingulooseMolesModifier, value => SupermatterSingulooseMolesModifier = value, true); + Subs.CVar(_config, ECCVars.SupermatterDoSingulooseDelam, value => SupermatterDoSingulooseDelam = value, true); + Subs.CVar(_config, ECCVars.SupermatterTesloosePowerModifier, value => SupermatterTesloosePowerModifier = value, true); + Subs.CVar(_config, ECCVars.SupermatterDoTeslooseDelam, value => SupermatterDoTeslooseDelam = value, true); + Subs.CVar(_config, ECCVars.SupermatterDoForceDelam, value => SupermatterDoForceDelam = value, true); + Subs.CVar(_config, ECCVars.SupermatterForcedDelamType, value => SupermatterForcedDelamType = value, true); + Subs.CVar(_config, ECCVars.SupermatterRadsBase, value => SupermatterRadsBase = value, true); + Subs.CVar(_config, ECCVars.SupermatterRadsModifier, value => SupermatterRadsModifier = value, true); + Subs.CVar(_config, ECCVars.SupermatterYellTimer, value => SupermatterYellTimer = value, true); + + // Event subscriptions SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnSupermatterUpdated); - SubscribeLocalEvent(OnCollideEvent); SubscribeLocalEvent(OnHandInteract); SubscribeLocalEvent(OnItemInteract); @@ -72,24 +83,25 @@ public sealed partial class SupermatterSystem : EntitySystem SubscribeLocalEvent(OnGetSliver); } + private HashSet> _activeSupermatterCrystals = new(); + public override void Update(float frameTime) { base.Update(frameTime); - foreach (var sm in EntityManager.EntityQuery()) + foreach (var ent in _activeSupermatterCrystals) { - if (!sm.Activated) - continue; + if (!ent.Comp.Activated) + _activeSupermatterCrystals.Remove(ent); - var uid = sm.Owner; - AnnounceCoreDamage(uid, sm); + AnnounceCoreDamage(ent.Owner, ent.Comp); } } private void OnMapInit(EntityUid uid, SupermatterComponent sm, MapInitEvent args) { // Set the yell timer - sm.YellTimer = TimeSpan.FromSeconds(_config.GetCVar(ECCVars.SupermatterYellTimer)); + sm.YellTimer = TimeSpan.FromSeconds(SupermatterYellTimer); // Set the Sound _ambient.SetAmbience(uid, true); @@ -121,7 +133,10 @@ public sealed partial class SupermatterSystem : EntitySystem private void OnCollideEvent(EntityUid uid, SupermatterComponent sm, ref StartCollideEvent args) { if (!sm.Activated) + { sm.Activated = true; + _activeSupermatterCrystals.Add((uid, sm)); + } var target = args.OtherEntity; if (args.OtherBody.BodyType == BodyType.Static @@ -165,7 +180,10 @@ public sealed partial class SupermatterSystem : EntitySystem private void OnHandInteract(EntityUid uid, SupermatterComponent sm, ref InteractHandEvent args) { if (!sm.Activated) + { sm.Activated = true; + _activeSupermatterCrystals.Add((uid, sm)); + } var target = args.User; @@ -183,7 +201,10 @@ public sealed partial class SupermatterSystem : EntitySystem private void OnItemInteract(EntityUid uid, SupermatterComponent sm, ref InteractUsingEvent args) { if (!sm.Activated) + { sm.Activated = true; + _activeSupermatterCrystals.Add((uid, sm)); + } if (sm.SliverRemoved) return; diff --git a/Content.Shared/_EE/Supermatter/Components/SupermatterComponent.cs b/Content.Shared/_EE/Supermatter/Components/SupermatterComponent.cs index 5db4e6da42..407e49945a 100644 --- a/Content.Shared/_EE/Supermatter/Components/SupermatterComponent.cs +++ b/Content.Shared/_EE/Supermatter/Components/SupermatterComponent.cs @@ -2,7 +2,6 @@ using Content.Shared._EE.Supermatter.Monitor; using Content.Shared.Atmos; using Content.Shared.DoAfter; using Content.Shared.Radio; -using Content.Shared.Speech; using Robust.Shared.Audio; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; @@ -19,7 +18,7 @@ public sealed partial class SupermatterComponent : Component /// The SM will only cycle if activated. /// [DataField] - public bool Activated = false; + public bool Activated; /// /// The current status of the singularity, used for alert sounds and the monitoring console @@ -453,7 +452,4 @@ public sealed partial class GasFact } [Serializable, NetSerializable] -public sealed partial class SupermatterDoAfterEvent : SimpleDoAfterEvent -{ - -} +public sealed partial class SupermatterDoAfterEvent : SimpleDoAfterEvent { } diff --git a/Resources/Prototypes/Entities/Markers/atmos_blocker.yml b/Resources/Prototypes/Entities/Markers/atmos_blocker.yml index 4e0a03c0ce..1027791ce8 100644 --- a/Resources/Prototypes/Entities/Markers/atmos_blocker.yml +++ b/Resources/Prototypes/Entities/Markers/atmos_blocker.yml @@ -128,5 +128,5 @@ volume: 2500 moles: - 0 # oxygen - - 18710.71051 # nitrogen + - 9350.0 # nitrogen temperature: 72