From 45dc2de8770390c5107218a803bdeaf517771a0c Mon Sep 17 00:00:00 2001 From: VMSolidus Date: Tue, 30 Jul 2024 21:59:20 -0400 Subject: [PATCH] Add job whitelist system (#28085) * Add job whitelist system * Address reviews * Fix name * Apply suggestions from code review Co-authored-by: Pieter-Jan Briers * cancinium --------- Co-authored-by: Pieter-Jan Briers --- .../Supermatter/Systems/SupermatterSystem.cs | 15 ++++-- Content.Shared/CCVar/CCVars.cs | 49 +++++++++++++++++++ 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/Content.Server/Supermatter/Systems/SupermatterSystem.cs b/Content.Server/Supermatter/Systems/SupermatterSystem.cs index eee4dbded1..cfce8b989d 100644 --- a/Content.Server/Supermatter/Systems/SupermatterSystem.cs +++ b/Content.Server/Supermatter/Systems/SupermatterSystem.cs @@ -1,4 +1,5 @@ using Robust.Shared.Audio.Systems; +using Robust.Shared.Configuration; using Robust.Shared.Containers; using Robust.Shared.Physics; using Robust.Shared.Physics.Events; @@ -25,6 +26,8 @@ using Content.Server.Popups; using System.Linq; using Content.Shared.Audio; +using System.Configuration; +using Content.Shared.CCVar; namespace Content.Server.Supermatter.Systems; @@ -43,6 +46,7 @@ public sealed class SupermatterSystem : EntitySystem [Dependency] private readonly DoAfterSystem _doAfter = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly PopupSystem _popup = default!; + [Dependency] private readonly IConfigurationManager _config = default!; public override void Initialize() { @@ -191,7 +195,7 @@ private void ProcessAtmos(EntityUid uid, SupermatterComponent sm) //Radiate stuff if (TryComp(uid, out var rad)) - rad.Intensity = sm.Power * Math.Max(0, 1f + transmissionBonus / 10f) * 0.003f; + rad.Intensity = sm.Power * Math.Max(0, 1f + transmissionBonus / 10f) * 0.003f * _config.GetCVar(CCVars.SupermatterRadsModifier); //Power * 0.55 * a value between 1 and 0.8 var energy = sm.Power * sm.ReactionPowerModifier; @@ -405,6 +409,9 @@ public float GetIntegrity(SupermatterComponent sm) /// public DelamType ChooseDelamType(EntityUid uid, SupermatterComponent sm) { + if (_config.GetCVar(CCVars.DoForceDelam)) + return _config.GetCVar(CCVars.ForcedDelamType); + var mix = _atmosphere.GetContainingMixture(uid, true, true); if (mix is { }) @@ -412,10 +419,12 @@ public DelamType ChooseDelamType(EntityUid uid, SupermatterComponent sm) var absorbedGas = mix.Remove(sm.GasEfficiency * mix.TotalMoles); var moles = absorbedGas.TotalMoles; - if (moles >= sm.MolePenaltyThreshold) + if (_config.GetCVar(CCVars.DoSingulooseDelam) + && moles >= sm.MolePenaltyThreshold * _config.GetCVar(CCVars.SingulooseMolesModifier)) return DelamType.Singulo; } - if (sm.Power >= sm.PowerPenaltyThreshold) + if (_config.GetCVar(CCVars.DoTeslooseDelam) + && sm.Power >= sm.PowerPenaltyThreshold * _config.GetCVar(CCVars.TesloosePowerModifier)) return DelamType.Tesla; // TODO: add resonance cascade when there's crazy conditions or a destabilizing crystal diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index dff08c7dda..8901fdb57c 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -1,3 +1,4 @@ +using Content.Shared.Supermatter.Components; using Robust.Shared; using Robust.Shared.Configuration; @@ -2411,6 +2412,54 @@ public static readonly CVarDef /// public static readonly CVarDef CPRAirlossReductionMultiplier = CVarDef.Create("cpr.airloss_reduction_multiplier", 1f, CVar.REPLICATED | CVar.SERVER); + #endregion + + #region Supermatter System + + /// + /// With completely default supermatter values, Singuloose delamination will occur if engineers inject at least 900 moles of coolant per tile + /// in the crystal chamber. For reference, a gas canister contains 1800 moles of air. This Cvar directly multiplies the amount of moles required to singuloose. + /// + public static readonly CVarDef SingulooseMolesModifier = + CVarDef.Create("supermatter.singuloose_moles_modifier", 1f, CVar.SERVER); + + /// + /// Toggles whether or not Singuloose delaminations can occur. If both Singuloose and Tesloose are disabled, it will always delam into a Nuke. + /// + public static readonly CVarDef DoSingulooseDelam = + CVarDef.Create("supermatter.do_singuloose", true, CVar.SERVER); + + /// + /// By default, Supermatter will "Tesloose" if the conditions for Singuloose are not met, and the core's power is at least 4000. + /// The actual reasons for being at least this amount vary by how the core was screwed up, but traditionally it's caused by "The core is on fire". + /// This Cvar multiplies said power threshold for the purpose of determining if the delam is a Tesloose. + /// + public static readonly CVarDef TesloosePowerModifier = + CVarDef.Create("supermatter.tesloose_power_modifier", 1f, CVar.SERVER); + + /// + /// Toggles whether or not Tesloose delaminations can occur. If both Singuloose and Tesloose are disabled, it will always delam into a Nuke. + /// + public static readonly CVarDef DoTeslooseDelam = + CVarDef.Create("supermatter.do_tesloose", true, CVar.SERVER); + + /// + /// When true, bypass the normal checks to determine delam type, and instead use the type chosen by supermatter.forced_delam_type + /// + public static readonly CVarDef DoForceDelam = + CVarDef.Create("supermatter.do_force_delam", false, CVar.SERVER); + + /// + /// If supermatter.do_force_delam is true, this determines the delamination type, bypassing the normal checks. + /// + public static readonly CVarDef ForcedDelamType = + CVarDef.Create("supermatter.forced_delam_type", DelamType.Singulo, CVar.SERVER); + + /// + /// Directly multiplies the amount of rads put out by the supermatter. Be VERY conservative with this. + /// + public static readonly CVarDef SupermatterRadsModifier = + CVarDef.Create("supermatter.rads_modifier", 1f, CVar.SERVER); #endregion }