mirror of
https://gitgud.io/c0ffeeeeeeee/coffees-rjw-ideology-addons.git
synced 2024-08-14 23:57:38 +00:00
Induce lactation
This commit is contained in:
parent
616d83ba08
commit
f21812a3eb
11 changed files with 382 additions and 0 deletions
131
CRIALactation/Source/Comps/CompInduceLactation.cs
Normal file
131
CRIALactation/Source/Comps/CompInduceLactation.cs
Normal file
|
@ -0,0 +1,131 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
using rjw;
|
||||
using Milk;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CRIALactation
|
||||
{
|
||||
public class CompInduceLactation : ThingComp
|
||||
{
|
||||
private readonly int OneDayInTicks = 60000;
|
||||
private int TicksSinceLastMassage = -60000;
|
||||
|
||||
private float InductionCompletionPercent = 0f;
|
||||
public bool isActive = false;
|
||||
public bool CanMassage = true;
|
||||
|
||||
public override void CompTick()
|
||||
{
|
||||
base.CompTick();
|
||||
Pawn p = this.parent as Pawn;
|
||||
|
||||
if (!isActive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!p.IsHashIntervalTick(100))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (LactationUtility.IsLactating(p))
|
||||
{
|
||||
isActive = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if(TicksSinceLastMassage + OneDayInTicks / Props.TimesMassagedADay < GenTicks.TicksGame)
|
||||
{
|
||||
CanMassage = true;
|
||||
}
|
||||
|
||||
if(InductionCompletionPercent >= 1)
|
||||
{
|
||||
string main = p.Name.ToStringShort + "'s breasts have been stimulated enough to induce lactation! They can now begin producing milk for their colony's consumption.";
|
||||
|
||||
var letter = LetterMaker.MakeLetter(p.Name.ToStringShort + " induced lactation", main, LetterDefOf.PositiveEvent);
|
||||
Find.LetterStack.ReceiveLetter(letter);
|
||||
|
||||
LactationUtility.StartLactating(p, true);
|
||||
isActive = false;
|
||||
InductionCompletionPercent = 0.6f; //start at 60% in case they ever lose lactating again
|
||||
}
|
||||
}
|
||||
|
||||
public void MassageBreasts()
|
||||
{
|
||||
InductionCompletionPercent += (float)1 / (Props.DaysToLactating * (Props.TimesMassagedADay + Rand.Value));
|
||||
TicksSinceLastMassage = GenTicks.TicksGame;
|
||||
CanMassage = false;
|
||||
}
|
||||
|
||||
public CompProperties_InduceLactation Props
|
||||
{
|
||||
get
|
||||
{
|
||||
return (CompProperties_InduceLactation)props;
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<FloatMenuOption> CompFloatMenuOptions(Pawn pawn)
|
||||
{
|
||||
if (pawn != this.parent as Pawn) yield break;
|
||||
if (LactationUtility.IsLactating(pawn)) yield break;
|
||||
if(LactationUtility.HasMilkableBreasts(this.parent as Pawn))
|
||||
{
|
||||
if(isActive)
|
||||
{
|
||||
//stop trying to induce lactation
|
||||
yield return new FloatMenuOption("Undesignate induce lactation", () =>
|
||||
{
|
||||
isActive = false;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
//induce lactation
|
||||
yield return new FloatMenuOption("Designate induce lactation", () =>
|
||||
{
|
||||
isActive = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return new FloatMenuOption("Designate induce lactation (no milkable breasts)", null);
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
public override void PostExposeData()
|
||||
{
|
||||
base.PostExposeData();
|
||||
Scribe_Values.Look<float>(ref this.InductionCompletionPercent, "InductionCompletionPercent", 0f);
|
||||
Scribe_Values.Look<int>(ref this.TicksSinceLastMassage, "TicksSinceLastMassage", -60000);
|
||||
|
||||
Scribe_Values.Look<bool>(ref this.isActive, "IsActive", false);
|
||||
Scribe_Values.Look<bool>(ref this.CanMassage, "CanMassage", false);
|
||||
|
||||
}
|
||||
|
||||
public override string CompInspectStringExtra()
|
||||
{
|
||||
if (!isActive) return null;
|
||||
|
||||
string result = "Induce lactation completion: " + InductionCompletionPercent.ToStringPercent();
|
||||
|
||||
if(CanMassage)
|
||||
{
|
||||
result += "\nReady to massage.";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue