Adding new Cryogenics Reagent - Opporozidone (Attempt 2) (#24074)

* Fixing mistakes

* How did I make the same mistake twice

---------

Co-authored-by: Kara <lunarautomaton6@gmail.com>
This commit is contained in:
Gotimanga
2024-04-29 05:13:14 +01:00
committed by GitHub
parent 5f216ef1ee
commit eb41f1da5f
6 changed files with 97 additions and 0 deletions

View File

@@ -149,6 +149,29 @@ public sealed class RottingSystem : SharedRottingSystem
args.Handled = component.CurrentTemperature < Atmospherics.T0C + 0.85f;
}
public void ReduceAccumulator(EntityUid uid, TimeSpan time)
{
if (!TryComp<PerishableComponent>(uid, out var perishable))
return;
if (!TryComp<RottingComponent>(uid, out var rotting))
{
perishable.RotAccumulator -= time;
return;
}
var total = (rotting.TotalRotTime + perishable.RotAccumulator) - time;
if (total < perishable.RotAfter)
{
RemCompDeferred(uid, rotting);
perishable.RotAccumulator = total;
}
else
rotting.TotalRotTime = total - perishable.RotAfter;
}
/// <summary>
/// Is anything speeding up the decay?
/// e.g. buried in a grave

View File

@@ -0,0 +1,31 @@
using Content.Shared.Chemistry.Reagent;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
using Content.Server.Atmos.Rotting;
namespace Content.Server.Chemistry.ReagentEffects
{
/// <summary>
/// Reduces the rotting accumulator on the patient, making them revivable.
/// </summary>
[UsedImplicitly]
public sealed partial class ReduceRotting : ReagentEffect
{
[DataField("seconds")]
public double RottingAmount = 10;
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
=> Loc.GetString("reagent-effect-guidebook-reduce-rotting",
("chance", Probability),
("time", RottingAmount));
public override void Effect(ReagentEffectArgs args)
{
if (args.Scale != 1f)
return;
var rottingSys = args.EntityManager.EntitySysManager.GetEntitySystem<RottingSystem>();
rottingSys.ReduceAccumulator(args.SolutionEntity, TimeSpan.FromSeconds(RottingAmount));
}
}
}