resimmed offmed

This commit is contained in:
Janet Blackquill
2025-10-06 01:55:42 -04:00
parent 847154b320
commit 173f24590f
84 changed files with 1210 additions and 1004 deletions

View File

@@ -20,6 +20,7 @@ using Content.Shared.Mobs.Systems;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Content.Shared._Offbrand.Wounds; // Offbrand
namespace Content.Server.Body.Systems;
@@ -49,6 +50,7 @@ public sealed class RespiratorSystem : EntitySystem
UpdatesAfter.Add(typeof(MetabolizerSystem));
SubscribeLocalEvent<RespiratorComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<RespiratorComponent, ApplyMetabolicMultiplierEvent>(OnApplyMetabolicMultiplier);
SubscribeLocalEvent<RespiratorComponent, ApplyRespiratoryRateModifiersEvent>(OnApplyRespiratoryRateModifiers);
// BodyComp stuff
SubscribeLocalEvent<BodyComponent, InhaledGasEvent>(OnGasInhaled);
@@ -60,7 +62,7 @@ public sealed class RespiratorSystem : EntitySystem
private void OnMapInit(Entity<RespiratorComponent> ent, ref MapInitEvent args)
{
ent.Comp.NextUpdate = _gameTiming.CurTime + ent.Comp.AdjustedUpdateInterval;
ent.Comp.NextUpdate = _gameTiming.CurTime + ent.Comp.OverallAdjustedUpdateInterval;
}
public override void Update(float frameTime)
@@ -73,14 +75,14 @@ public sealed class RespiratorSystem : EntitySystem
if (_gameTiming.CurTime < respirator.NextUpdate)
continue;
respirator.NextUpdate += respirator.AdjustedUpdateInterval;
respirator.NextUpdate += respirator.OverallAdjustedUpdateInterval; // Offbrand
if (_mobState.IsDead(uid))
continue;
UpdateSaturation(uid, -(float)respirator.UpdateInterval.TotalSeconds, respirator);
UpdateSaturation(uid, -(float)respirator.BodyAdjustedUpdateInterval.TotalSeconds, respirator); // Offbrand
if (!_mobState.IsIncapacitated(uid)) // cannot breathe in crit.
if (!_mobState.IsIncapacitated(uid) || HasComp<HeartrateComponent>(uid)) // Offbrand - simplemobs get crit behaviour, heartmobs get hyperventilation
{
switch (respirator.Status)
{
@@ -95,10 +97,10 @@ public sealed class RespiratorSystem : EntitySystem
}
}
// Begin Offbrand - Respirators gasp when their heart has stopped
// Begin Offbrand - Respirators gasp when hyperventilating
var isSuffocating = respirator.Saturation < respirator.SuffocationThreshold;
var shouldGaspFromHeart = TryComp<Content.Shared._Offbrand.Wounds.HeartrateComponent>(uid, out var heartrate) && !heartrate.Running;
if (isSuffocating || shouldGaspFromHeart)
var hyperventilation = respirator.BreathRateMultiplier <= respirator.HyperventilationThreshold;
if (isSuffocating || hyperventilation)
{
if (_gameTiming.CurTime >= respirator.LastGaspEmoteTime + respirator.GaspEmoteCooldown)
{
@@ -116,7 +118,7 @@ public sealed class RespiratorSystem : EntitySystem
continue;
}
}
// End Offbrand - Respirators gasp when their heart has stopped
// End Offbrand - Respirators gasp when hyperventilating
StopSuffocation((uid, respirator));
respirator.SuffocationCycles = 0;
@@ -141,7 +143,7 @@ public sealed class RespiratorSystem : EntitySystem
return;
// Begin Offbrand
var breathEv = new Content.Shared._Offbrand.Wounds.BeforeBreathEvent(entity.Comp.BreathVolume);
var breathEv = new Content.Shared._Offbrand.Wounds.BeforeBreathEvent(entity.Comp.AdjustedBreathVolume); // Offbrand - modify breath volume
RaiseLocalEvent(entity, ref breathEv);
var gas = ev.Gas.RemoveVolume(breathEv.BreathVolume);
@@ -299,6 +301,7 @@ public sealed class RespiratorSystem : EntitySystem
public void RemoveGasFromBody(Entity<BodyComponent> ent, GasMixture gas)
{
var outGas = new GasMixture(gas.Volume);
var respirator = Comp<RespiratorComponent>(ent); // Offbrand
var organs = _bodySystem.GetBodyOrganEntityComps<LungComponent>((ent, ent.Comp));
if (organs.Count == 0)
@@ -306,8 +309,7 @@ public sealed class RespiratorSystem : EntitySystem
foreach (var (organUid, lung, _) in organs)
{
_atmosSys.Merge(outGas, lung.Air);
lung.Air.Clear();
_atmosSys.Merge(outGas, lung.Air.RemoveRatio(respirator.ExhaleEfficacyModifier * 1.1f)); // Offbrand - efficacy, 1.1 magic constant is to unstuck 0.01u of exhalants if the body is imperfect
if (_solutionContainerSystem.ResolveSolution(organUid, lung.SolutionName, ref lung.Solution))
_solutionContainerSystem.RemoveAllSolution(lung.Solution.Value);
@@ -434,6 +436,14 @@ public sealed class RespiratorSystem : EntitySystem
ent.Comp.UpdateIntervalMultiplier = args.Multiplier;
}
// Begin Offbrand
private void OnApplyRespiratoryRateModifiers(Entity<RespiratorComponent> ent, ref ApplyRespiratoryRateModifiersEvent args)
{
ent.Comp.BreathRateMultiplier = args.BreathRate;
ent.Comp.ExhaleEfficacyModifier = args.PurgeRate;
}
// End Offbrand
private void OnGasInhaled(Entity<BodyComponent> entity, ref InhaledGasEvent args)
{
if (args.Handled)