rjw-std/1.3/Source/STD/std_updater.cs
Ed86 bc8368af15 split off rjw stds in separate mod for rjw 5.0+
split stds into separate xml/cs files
2022-05-26 14:37:23 +03:00

45 lines
1.2 KiB
C#

//using Multiplayer.API;
using RimWorld;
using Verse;
using rjw;
namespace STD
{
/// <summary>
/// Responsible for handling the periodic effects of having an STD hediff.
/// Not technically tied to the infection vector itself,
/// but some of the STD effects are weird and complicated.
/// </summary>
public static class std_updater
{
public const float UpdatesPerDay = GenDate.TicksPerDay / 150f / (float)Need_Sex.needsex_tick_timer;
public static void update(Pawn p)
{
// Check if any infections are below the autocure threshold and cure them if so
foreach (std_def sd in std.all)
{
Hediff inf = std.get_infection(p, sd);
if (inf != null && (inf.Severity < sd.autocure_below_severity || std.IsImmune(p)))
{
p.health.RemoveHediff(inf);
if (sd.cohediff_def != null)
{
Hediff coinf = p.health.hediffSet.GetFirstHediffOfDef(sd.cohediff_def);
if (coinf != null)
p.health.RemoveHediff(coinf);
}
}
}
}
/// <summary>
/// For meanDays = 1.0, will return true on average once per day. For 2.0, will return true on average once every two days.
/// </summary>
//[SyncMethod]
static bool RollFor(float meanDays)
{
return Rand.Chance(1.0f / meanDays / UpdatesPerDay);
}
}
}