Miasma update (#8943)

This commit is contained in:
Rane
2022-06-19 01:51:55 -04:00
committed by GitHub
parent 003bf74a42
commit a527658f6d
12 changed files with 143 additions and 42 deletions

View File

@@ -4,7 +4,10 @@ using Content.Shared.Atmos;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Temperature.Components;
using Content.Server.Body.Components;
using Content.Server.Popups;
using Content.Shared.Examine;
using Robust.Shared.Containers;
using Robust.Shared.Player;
namespace Content.Server.Atmos.Miasma
{
@@ -13,6 +16,8 @@ namespace Content.Server.Atmos.Miasma
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
public override void Update(float frameTime)
{
base.Update(frameTime);
@@ -35,8 +40,8 @@ namespace Content.Server.Atmos.Miasma
perishable.RotAccumulator -= 1f;
DamageSpecifier damage = new();
damage.DamageDict.Add("Blunt", 0.25); // Slowly accumulate enough to gib after like half an hour
damage.DamageDict.Add("Cellular", 0.25); // Cloning rework might use this eventually
damage.DamageDict.Add("Blunt", 0.3); // Slowly accumulate enough to gib after like half an hour
damage.DamageDict.Add("Cellular", 0.3); // Cloning rework might use this eventually
_damageableSystem.TryChangeDamage(perishable.Owner, damage, true, true);
@@ -56,6 +61,7 @@ namespace Content.Server.Atmos.Miasma
base.Initialize();
SubscribeLocalEvent<PerishableComponent, MobStateChangedEvent>(OnMobStateChanged);
SubscribeLocalEvent<PerishableComponent, BeingGibbedEvent>(OnGibbed);
SubscribeLocalEvent<PerishableComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<AntiRottingContainerComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
SubscribeLocalEvent<AntiRottingContainerComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
}
@@ -71,10 +77,24 @@ namespace Content.Server.Atmos.Miasma
if (!TryComp<PhysicsComponent>(uid, out var physics))
return;
if (component.DeathAccumulator <= component.RotAfter.TotalSeconds)
return;
var molsToDump = (component.MolsPerSecondPerUnitMass * physics.FixturesMass) * component.DeathAccumulator;
var tileMix = _atmosphereSystem.GetTileMixture(Transform(uid).Coordinates);
if (tileMix != null)
tileMix.AdjustMoles(Gas.Miasma, molsToDump);
foreach (var part in args.GibbedParts)
{
EntityManager.QueueDeleteEntity(part);
}
}
private void OnExamined(EntityUid uid, PerishableComponent component, ExaminedEvent args)
{
if (component.DeathAccumulator >= component.RotAfter.TotalSeconds)
args.PushMarkup(Loc.GetString("miasma-rotting"));
}
private void OnEntInserted(EntityUid uid, AntiRottingContainerComponent component, EntInsertedIntoContainerMessage args)

View File

@@ -23,7 +23,7 @@ namespace Content.Server.Atmos.Miasma
/// <summary>
/// When DeathAccumulator is greater than this, start rotting.
/// </summary>
public TimeSpan RotAfter = TimeSpan.FromMinutes(3);
public TimeSpan RotAfter = TimeSpan.FromMinutes(5);
/// <summary>
/// Gasses are released every second.
@@ -32,11 +32,10 @@ namespace Content.Server.Atmos.Miasma
public float RotAccumulator = 0f;
/// <summary>
/// How many moles of gas released per second, adjusted for mass.
/// Humans have a mass of 70. I am aiming for ten mols a minute, so
/// 1/6 of a minute, divided by 70 as a baseline.
/// How many moles of gas released per second, per unit of mass.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public float MolsPerSecondPerUnitMass = 0.0025f;
[DataField("molsPerSecondPerUnitMass")]
public float MolsPerSecondPerUnitMass = 0.0035f;
}
}