[fix] Fix rotting (#16039)

* Fix rotting

* empty
This commit is contained in:
Nemanja
2023-05-03 00:57:47 -04:00
committed by GitHub
parent 6a9742a656
commit b16eba534a
12 changed files with 381 additions and 417 deletions

View File

@@ -0,0 +1,11 @@
namespace Content.Shared.Atmos.Miasma;
/// <summary>
/// Entities inside this container will not rot.
/// </summary>
[RegisterComponent]
public sealed class AntiRottingContainerComponent : Component
{
}

View File

@@ -0,0 +1,46 @@
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared.Atmos.Miasma;
/// <summary>
/// This makes mobs eventually start rotting when they die.
/// It may be expanded to food at some point, but it's just for mobs right now.
/// </summary>
[RegisterComponent]
public sealed class PerishableComponent : Component
{
/// <summary>
/// How long it takes after death to start rotting.
/// </summary>
[DataField("rotAfter"), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan RotAfter = TimeSpan.FromMinutes(5);
/// <summary>
/// How much rotting has occured
/// </summary>
[DataField("rotAccumulator"), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan RotAccumulator = TimeSpan.Zero;
/// <summary>
/// Gasses are released, this is when the next gas release update will be.
/// </summary>
[DataField("rotNextUpdate", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan NextPerishUpdate = TimeSpan.Zero;
/// <summary>
/// How often the rotting ticks.
/// Feel free to weak this if there are perf concerns.
/// </summary>
[DataField("perishUpdateRate"), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan PerishUpdateRate = TimeSpan.FromSeconds(5);
/// <summary>
/// How many moles of gas released per second, per unit of mass.
/// </summary>
[DataField("molsPerSecondPerUnitMass"), ViewVariables(VVAccess.ReadWrite)]
public float MolsPerSecondPerUnitMass = 0.0025f;
}
[ByRefEvent]
public record struct IsRottingEvent(bool Handled = false);

View File

@@ -0,0 +1,49 @@
using Content.Shared.Damage;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared.Atmos.Miasma;
/// <summary>
/// Tracking component for stuff that has started to rot.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed class RottingComponent : Component
{
/// <summary>
/// Whether or not the rotting should deal damage
/// </summary>
[DataField("dealDamage"), ViewVariables(VVAccess.ReadWrite)]
public bool DealDamage = true;
/// <summary>
/// When the next check will happen for rot progression + effects like damage and miasma
/// </summary>
[DataField("nextRotUpdate", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan NextRotUpdate = TimeSpan.Zero;
/// <summary>
/// How long in between each rot update.
/// </summary>
[DataField("rotUpdateRate"), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan RotUpdateRate = TimeSpan.FromSeconds(5);
/// <summary>
/// How long has this thing been rotting?
/// </summary>
[DataField("totalRotTime"), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan TotalRotTime = TimeSpan.Zero;
/// <summary>
/// The damage dealt by rotting.
/// </summary>
[DataField("damage")]
public DamageSpecifier Damage = new()
{
DamageDict = new()
{
{ "Blunt", 0.06 },
{ "Cellular", 0.06 }
}
};
}