Rotting fixes (#9338)

This commit is contained in:
Rane
2022-07-02 22:46:24 -04:00
committed by GitHub
parent 2d027faa3c
commit b7e9e95567
2 changed files with 42 additions and 4 deletions

View File

@@ -0,0 +1,11 @@
namespace Content.Server.Atmos.Miasma
{
[RegisterComponent]
/// <summary>
/// Way for natural sources of rotting to tell if there are more unnatural preservation forces at play.
/// </summary>
public sealed class BodyPreservedComponent : Component
{
public int PreservationSources = 0;
}
}

View File

@@ -5,6 +5,7 @@ using Content.Server.Atmos.EntitySystems;
using Content.Server.Temperature.Systems; using Content.Server.Temperature.Systems;
using Content.Server.Body.Components; using Content.Server.Body.Components;
using Content.Shared.Examine; using Content.Shared.Examine;
using Content.Shared.Tag;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.Random; using Robust.Shared.Random;
@@ -145,6 +146,8 @@ namespace Content.Server.Atmos.Miasma
private void OnTempChange(EntityUid uid, RottingComponent component, OnTemperatureChangeEvent args) private void OnTempChange(EntityUid uid, RottingComponent component, OnTemperatureChangeEvent args)
{ {
if (HasComp<BodyPreservedComponent>(uid))
return;
bool decompose = (args.CurrentTemperature > 274f); bool decompose = (args.CurrentTemperature > 274f);
ToggleDecomposition(uid, decompose); ToggleDecomposition(uid, decompose);
} }
@@ -184,12 +187,18 @@ namespace Content.Server.Atmos.Miasma
private void OnEntInserted(EntityUid uid, AntiRottingContainerComponent component, EntInsertedIntoContainerMessage args) private void OnEntInserted(EntityUid uid, AntiRottingContainerComponent component, EntInsertedIntoContainerMessage args)
{ {
if (TryComp<PerishableComponent>(args.Entity, out var perishable)) if (TryComp<PerishableComponent>(args.Entity, out var perishable))
{
ModifyPreservationSource(args.Entity, true);
ToggleDecomposition(args.Entity, false, perishable); ToggleDecomposition(args.Entity, false, perishable);
}
} }
private void OnEntRemoved(EntityUid uid, AntiRottingContainerComponent component, EntRemovedFromContainerMessage args) private void OnEntRemoved(EntityUid uid, AntiRottingContainerComponent component, EntRemovedFromContainerMessage args)
{ {
if (TryComp<PerishableComponent>(args.Entity, out var perishable)) if (TryComp<PerishableComponent>(args.Entity, out var perishable))
{
ModifyPreservationSource(args.Entity, false);
ToggleDecomposition(args.Entity, true, perishable); ToggleDecomposition(args.Entity, true, perishable);
}
} }
@@ -216,23 +225,41 @@ namespace Content.Server.Atmos.Miasma
if (decompose == perishable.Progressing) // Saved a few cycles if (decompose == perishable.Progressing) // Saved a few cycles
return; return;
if (!HasComp<RottingComponent>(uid)) perishable.Progressing = decompose;
return;
if (!perishable.Rotting) if (!perishable.Rotting)
return; return;
if (decompose) if (decompose)
{ {
perishable.Progressing = true;
EnsureComp<FliesComponent>(uid); EnsureComp<FliesComponent>(uid);
return; return;
} }
perishable.Progressing = false;
RemComp<FliesComponent>(uid); RemComp<FliesComponent>(uid);
} }
/// <summary>
/// Add or remove a preservation source.
/// Remove is just "add = false"
/// If we have 0 we remove the whole component.
/// </summary>
public void ModifyPreservationSource(EntityUid uid, bool add)
{
var component = EnsureComp<BodyPreservedComponent>(uid);
if (add)
{
component.PreservationSources++;
return;
}
component.PreservationSources--;
if (component.PreservationSources == 0)
RemCompDeferred(uid, component);
}
public string RequestPoolDisease() public string RequestPoolDisease()
{ {
// We reset the current time on this outbreak so people don't get unlucky at the transition time // We reset the current time on this outbreak so people don't get unlucky at the transition time