1
0

PerishableComponent.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using Robust.Shared.GameStates;
  2. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  3. namespace Content.Shared.Atmos.Rotting;
  4. /// <summary>
  5. /// This makes mobs eventually start rotting when they die.
  6. /// It may be expanded to food at some point, but it's just for mobs right now.
  7. /// </summary>
  8. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState, AutoGenerateComponentPause]
  9. [Access(typeof(SharedRottingSystem))]
  10. public sealed partial class PerishableComponent : Component
  11. {
  12. /// <summary>
  13. /// How long it takes after death to start rotting.
  14. /// </summary>
  15. [DataField]
  16. public TimeSpan RotAfter = TimeSpan.FromMinutes(10);
  17. /// <summary>
  18. /// How much rotting has occured
  19. /// </summary>
  20. [DataField]
  21. public TimeSpan RotAccumulator = TimeSpan.Zero;
  22. /// <summary>
  23. /// Gasses are released, this is when the next gas release update will be.
  24. /// </summary>
  25. [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
  26. [AutoPausedField]
  27. public TimeSpan RotNextUpdate = TimeSpan.Zero;
  28. /// <summary>
  29. /// How often the rotting ticks.
  30. /// Feel free to tweak this if there are perf concerns.
  31. /// </summary>
  32. [DataField]
  33. public TimeSpan PerishUpdateRate = TimeSpan.FromSeconds(5);
  34. /// <summary>
  35. /// How many moles of gas released per second, per unit of mass.
  36. /// </summary>
  37. [DataField]
  38. public float MolsPerSecondPerUnitMass = 0.0025f;
  39. [DataField, AutoNetworkedField]
  40. public int Stage;
  41. /// <summary>
  42. /// If true, rot will always progress.
  43. /// </summary>
  44. [DataField, AutoNetworkedField]
  45. public bool ForceRotProgression;
  46. }
  47. [ByRefEvent]
  48. public record struct IsRottingEvent(bool Handled = false);