Skip to content

Commit

Permalink
Add job whitelist system (#28085)
Browse files Browse the repository at this point in the history
* Add job whitelist system

* Address reviews

* Fix name

* Apply suggestions from code review

Co-authored-by: Pieter-Jan Briers <[email protected]>

* cancinium

---------

Co-authored-by: Pieter-Jan Briers <[email protected]>
  • Loading branch information
VMSolidus and PJB3005 committed Aug 2, 2024
1 parent e117c79 commit 45dc2de
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Content.Server/Supermatter/Systems/SupermatterSystem.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand All @@ -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()
{
Expand Down Expand Up @@ -191,7 +195,7 @@ private void ProcessAtmos(EntityUid uid, SupermatterComponent sm)

//Radiate stuff
if (TryComp<RadiationSourceComponent>(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;
Expand Down Expand Up @@ -405,17 +409,22 @@ public float GetIntegrity(SupermatterComponent sm)
/// </summary>
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 { })
{
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
Expand Down
49 changes: 49 additions & 0 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Shared.Supermatter.Components;
using Robust.Shared;
using Robust.Shared.Configuration;

Expand Down Expand Up @@ -2411,6 +2412,54 @@ public static readonly CVarDef<float>
/// </summary>
public static readonly CVarDef<float> CPRAirlossReductionMultiplier =
CVarDef.Create("cpr.airloss_reduction_multiplier", 1f, CVar.REPLICATED | CVar.SERVER);
#endregion

#region Supermatter System

/// <summary>
/// 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.
/// </summary>
public static readonly CVarDef<float> SingulooseMolesModifier =
CVarDef.Create("supermatter.singuloose_moles_modifier", 1f, CVar.SERVER);

/// <summary>
/// Toggles whether or not Singuloose delaminations can occur. If both Singuloose and Tesloose are disabled, it will always delam into a Nuke.
/// </summary>
public static readonly CVarDef<bool> DoSingulooseDelam =
CVarDef.Create("supermatter.do_singuloose", true, CVar.SERVER);

/// <summary>
/// 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.
/// </summary>
public static readonly CVarDef<float> TesloosePowerModifier =
CVarDef.Create("supermatter.tesloose_power_modifier", 1f, CVar.SERVER);

/// <summary>
/// Toggles whether or not Tesloose delaminations can occur. If both Singuloose and Tesloose are disabled, it will always delam into a Nuke.
/// </summary>
public static readonly CVarDef<bool> DoTeslooseDelam =
CVarDef.Create("supermatter.do_tesloose", true, CVar.SERVER);

/// <summary>
/// When true, bypass the normal checks to determine delam type, and instead use the type chosen by supermatter.forced_delam_type
/// </summary>
public static readonly CVarDef<bool> DoForceDelam =
CVarDef.Create("supermatter.do_force_delam", false, CVar.SERVER);

/// <summary>
/// If supermatter.do_force_delam is true, this determines the delamination type, bypassing the normal checks.
/// </summary>
public static readonly CVarDef<DelamType> ForcedDelamType =
CVarDef.Create("supermatter.forced_delam_type", DelamType.Singulo, CVar.SERVER);

/// <summary>
/// Directly multiplies the amount of rads put out by the supermatter. Be VERY conservative with this.
/// </summary>
public static readonly CVarDef<float> SupermatterRadsModifier =
CVarDef.Create("supermatter.rads_modifier", 1f, CVar.SERVER);

#endregion
}
Expand Down

0 comments on commit 45dc2de

Please sign in to comment.