lung fix (#5697)
This commit is contained in:
@@ -50,7 +50,7 @@ public class LungSystem : EntitySystem
|
|||||||
Inhale(uid, lung.CycleDelay);
|
Inhale(uid, lung.CycleDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateLung(EntityUid uid, float frameTime,
|
public void UpdateLung(EntityUid uid,
|
||||||
LungComponent? lung=null,
|
LungComponent? lung=null,
|
||||||
SharedMechanismComponent? mech=null)
|
SharedMechanismComponent? mech=null)
|
||||||
{
|
{
|
||||||
@@ -69,8 +69,8 @@ public class LungSystem : EntitySystem
|
|||||||
|
|
||||||
lung.AccumulatedFrametime += lung.Status switch
|
lung.AccumulatedFrametime += lung.Status switch
|
||||||
{
|
{
|
||||||
LungStatus.Inhaling => frameTime,
|
LungStatus.Inhaling => 1,
|
||||||
LungStatus.Exhaling => -frameTime,
|
LungStatus.Exhaling => -1,
|
||||||
_ => throw new ArgumentOutOfRangeException()
|
_ => throw new ArgumentOutOfRangeException()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -36,37 +36,36 @@ namespace Content.Server.Body.Systems
|
|||||||
if (!EntityManager.TryGetComponent<MobStateComponent>(uid, out var state) ||
|
if (!EntityManager.TryGetComponent<MobStateComponent>(uid, out var state) ||
|
||||||
state.IsDead())
|
state.IsDead())
|
||||||
{
|
{
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
respirator.AccumulatedFrametime += frameTime;
|
respirator.AccumulatedFrametime += frameTime;
|
||||||
|
|
||||||
if (respirator.AccumulatedFrametime < 1)
|
if (respirator.AccumulatedFrametime < 1)
|
||||||
{
|
{
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessGases(uid, respirator, frameTime, blood, body);
|
ProcessGases(uid, respirator, blood, body);
|
||||||
|
|
||||||
respirator.AccumulatedFrametime -= 1;
|
respirator.AccumulatedFrametime -= 1;
|
||||||
|
|
||||||
if (SuffocatingPercentage(respirator) > 0)
|
if (SuffocatingPercentage(respirator) > 0)
|
||||||
{
|
{
|
||||||
TakeSuffocationDamage(uid, respirator);
|
TakeSuffocationDamage(uid, respirator);
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
StopSuffocation(uid, respirator);
|
StopSuffocation(uid, respirator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Dictionary<Gas, float> NeedsAndDeficit(RespiratorComponent respirator)
|
||||||
private Dictionary<Gas, float> NeedsAndDeficit(RespiratorComponent respirator, float frameTime)
|
|
||||||
{
|
{
|
||||||
var needs = new Dictionary<Gas, float>(respirator.NeedsGases);
|
var needs = new Dictionary<Gas, float>(respirator.NeedsGases);
|
||||||
foreach (var (gas, amount) in respirator.DeficitGases)
|
foreach (var (gas, amount) in respirator.DeficitGases)
|
||||||
{
|
{
|
||||||
var newAmount = (needs.GetValueOrDefault(gas) + amount) * frameTime;
|
var newAmount = (needs.GetValueOrDefault(gas) + amount);
|
||||||
needs[gas] = newAmount;
|
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));
|
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,
|
BloodstreamComponent? bloodstream,
|
||||||
SharedBodyComponent? body)
|
SharedBodyComponent? body)
|
||||||
{
|
{
|
||||||
@@ -139,12 +138,12 @@ namespace Content.Server.Body.Systems
|
|||||||
|
|
||||||
var lungs = _bodySystem.GetComponentsOnMechanisms<LungComponent>(uid, body).ToArray();
|
var lungs = _bodySystem.GetComponentsOnMechanisms<LungComponent>(uid, body).ToArray();
|
||||||
|
|
||||||
var needs = NeedsAndDeficit(respirator, frameTime);
|
var needs = NeedsAndDeficit(respirator);
|
||||||
var used = 0f;
|
var used = 0f;
|
||||||
|
|
||||||
foreach (var (lung, mech) in lungs)
|
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)
|
foreach (var (gas, amountNeeded) in needs)
|
||||||
|
|||||||
Reference in New Issue
Block a user