This commit is contained in:
Leon Friedrich
2021-12-04 21:11:48 +13:00
committed by GitHub
parent 55cad57f96
commit c33d06c544
2 changed files with 12 additions and 13 deletions

View File

@@ -50,7 +50,7 @@ public class LungSystem : EntitySystem
Inhale(uid, lung.CycleDelay);
}
public void UpdateLung(EntityUid uid, float frameTime,
public void UpdateLung(EntityUid uid,
LungComponent? lung=null,
SharedMechanismComponent? mech=null)
{
@@ -69,8 +69,8 @@ public class LungSystem : EntitySystem
lung.AccumulatedFrametime += lung.Status switch
{
LungStatus.Inhaling => frameTime,
LungStatus.Exhaling => -frameTime,
LungStatus.Inhaling => 1,
LungStatus.Exhaling => -1,
_ => throw new ArgumentOutOfRangeException()
};

View File

@@ -36,37 +36,36 @@ namespace Content.Server.Body.Systems
if (!EntityManager.TryGetComponent<MobStateComponent>(uid, out var state) ||
state.IsDead())
{
return;
continue;
}
respirator.AccumulatedFrametime += frameTime;
if (respirator.AccumulatedFrametime < 1)
{
return;
continue;
}
ProcessGases(uid, respirator, frameTime, blood, body);
ProcessGases(uid, respirator, blood, body);
respirator.AccumulatedFrametime -= 1;
if (SuffocatingPercentage(respirator) > 0)
{
TakeSuffocationDamage(uid, respirator);
return;
continue;
}
StopSuffocation(uid, respirator);
}
}
private Dictionary<Gas, float> NeedsAndDeficit(RespiratorComponent respirator, float frameTime)
private Dictionary<Gas, float> NeedsAndDeficit(RespiratorComponent respirator)
{
var needs = new Dictionary<Gas, float>(respirator.NeedsGases);
foreach (var (gas, amount) in respirator.DeficitGases)
{
var newAmount = (needs.GetValueOrDefault(gas) + amount) * frameTime;
var newAmount = (needs.GetValueOrDefault(gas) + amount);
needs[gas] = newAmount;
}
@@ -130,7 +129,7 @@ namespace Content.Server.Body.Systems
return respirator.ProducesGases.ToDictionary(pair => pair.Key, pair => GasProducedMultiplier(respirator, pair.Key, usedAverage));
}
private void ProcessGases(EntityUid uid, RespiratorComponent respirator, float frameTime,
private void ProcessGases(EntityUid uid, RespiratorComponent respirator,
BloodstreamComponent? bloodstream,
SharedBodyComponent? body)
{
@@ -139,12 +138,12 @@ namespace Content.Server.Body.Systems
var lungs = _bodySystem.GetComponentsOnMechanisms<LungComponent>(uid, body).ToArray();
var needs = NeedsAndDeficit(respirator, frameTime);
var needs = NeedsAndDeficit(respirator);
var used = 0f;
foreach (var (lung, mech) in lungs)
{
_lungSystem.UpdateLung(lung.OwnerUid, frameTime, lung, mech);
_lungSystem.UpdateLung(lung.OwnerUid, lung, mech);
}
foreach (var (gas, amountNeeded) in needs)