Merge branch 'Thoughts'

This commit is contained in:
c0ffee 2021-11-17 13:03:44 -08:00
commit 80627f18eb
12 changed files with 301 additions and 19 deletions

View File

@ -74,12 +74,15 @@
<Compile Include="Source\CompProperties\CompProperties_InduceLactation.cs" />
<Compile Include="Source\Comps\CompAbilityEffects\CompAbilityEffect_ConvertHucow.cs" />
<Compile Include="Source\Comps\CompInduceLactation.cs" />
<Compile Include="Source\HarmonyPatches\HarmonyPatch_FoodUtility.cs" />
<Compile Include="Source\HarmonyPatches\HarmonyPatch_Ideo.cs" />
<Compile Include="Source\HarmonyPatches\HarmonyPatch_Thing.cs" />
<Compile Include="Source\HarmonyPatches\Harmony_PatchAll.cs" />
<Compile Include="Source\HarmonyPatches\RJW\HarmonyPatch_Milk_HumanCompHasGatherableBodyResource.cs" />
<Compile Include="Source\HediffDefOf\HediffDefOf_Milk.cs" />
<Compile Include="Source\Hediffs\HediffCompProperties_StopOnceNotLactating.cs" />
<Compile Include="Source\Hediffs\HediffComp_StopOnceNotLactating.cs" />
<Compile Include="Source\HistoryEventDefOf\HistoryEventDefOf_Milk.cs" />
<Compile Include="Source\JobDefOf\JobDefOf_CRIALactation.cs" />
<Compile Include="Source\JobDrivers\JobDriver_MassageBreasts.cs" />
<Compile Include="Source\LactationUtility.cs" />
@ -88,14 +91,19 @@
<Compile Include="Source\RoleEffects\RoleEffect_Hucow.cs" />
<Compile Include="Source\RoleRequirements\RoleRequirement_Lactating.cs" />
<Compile Include="Source\StatDefOf\StatDefOf_Lactation.cs" />
<Compile Include="Source\ThingDefOf\ThingDefOf_Milk.cs" />
<Compile Include="Source\Thoughts\ThoughtWorker_Precept_Lactating_Essential.cs" />
<Compile Include="Source\Thoughts\ThoughtWorker_Precept_Lactating_Essential_Social.cs" />
<Compile Include="Source\Thoughts\ThoughtWorker_Precept_NoRecentHumanMilk.cs" />
<Compile Include="Source\WorkGivers\WorkGiver_MassageBreasts.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Folder Include="Defs\Thingdef\" />
</ItemGroup>
<ItemGroup>
<Content Include="Defs\AbilityDefs\Abilities_Hucow.xml" />
<Content Include="Defs\HediffDefs\Hediffs_Hucow.xml" />
<Content Include="Defs\HistoryEventDefs\HistoryEventDefs.xml" />
<Content Include="Defs\JobDefs\Jobs_CRIALactation.xml" />
<Content Include="Defs\MemeDefs\Memes_Hucow.xml" />
<Content Include="Defs\PreceptDefs\Precepts_Lactating.xml" />

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<HistoryEventDef>
<defName>DrankMilkRaw</defName>
<label>Drank milk Raw</label>
</HistoryEventDef>
<HistoryEventDef>
<defName>DrankMilkMeal</defName>
<label>Drank milk with meal</label>
</HistoryEventDef>
<HistoryEventDef>
<defName>DrankNonMilkMeal</defName>
<label>Ate meal without milk</label>
</HistoryEventDef>
</Defs>

View File

@ -16,9 +16,8 @@
<impact>High</impact>
<displayOrderInIssue>20</displayOrderInIssue>
<displayOrderInImpact>100</displayOrderInImpact>
<description>Milk from breasts is creamy and delicious. It should be produced and consumed on a regular basis. Lactating colonists will produce double the normal amount of milk.</description>
<description>Milk from breasts is creamy and delicious. It should be produced and consumed on a regular basis. Lactating colonists can be converted to hucow, which will produce double the normal amount of milk.</description>
<comps>
<li Class="CRIALactation.PreceptComp_Lactation" />
<li Class="PreceptComp_SituationalThought">
<thought>Lactating_Essential</thought>
<description>Sizeable breasts must produce milk</description>
@ -28,6 +27,18 @@
<thought>Lactating_Essential_Social</thought>
<tooltipShowMoodRange>true</tooltipShowMoodRange>
</li>
<li Class="PreceptComp_SelfTookMemoryThought">
<eventDef>DrankNonMilkMeal</eventDef>
<thought>DrankNonMilkMeal_Essential</thought>
</li>
<li Class="PreceptComp_SelfTookMemoryThought">
<eventDef>DrankMilkRaw</eventDef>
<thought>DrankMilkRaw_Essential</thought>
</li>
<li Class="PreceptComp_SelfTookMemoryThought">
<eventDef>DrankMilkMeal</eventDef>
<thought>DrankMilkMeal_Essential</thought>
</li>
</comps>
</PreceptDef>
@ -36,9 +47,15 @@
<thoughtClass>Thought_Situational</thoughtClass>
<workerClass>CRIALactation.ThoughtWorker_Precept_Lactating_Essential</workerClass>
<stages>
<li>
<label>producing milk (hucow)</label>
<description>I'm a good cow to be producing milk. Moo!</description>
<baseMoodEffect>7</baseMoodEffect>
</li>
<li>
<label>producing milk</label>
<description>Expressing milk fills me with maternal pride.</description>
<description>I'm glad I can support my colony by producing some milk.</description>
<baseMoodEffect>3</baseMoodEffect>
</li>
@ -62,8 +79,6 @@
</stages>
</ThoughtDef>
<ThoughtDef>
<defName>Lactating_Essential_Social</defName>
<thoughtClass>Thought_SituationalSocial</thoughtClass>
@ -79,14 +94,63 @@
</li>
<li>
<label>not producing milk (moderate expectations)</label>
<baseOpinionOffset>-20</baseOpinionOffset>
<baseOpinionOffset>-10</baseOpinionOffset>
</li>
<li>
<label>not producing milk (high expectations)</label>
<baseOpinionOffset>-40</baseOpinionOffset>
<baseOpinionOffset>-15</baseOpinionOffset>
</li>
</stages>
</ThoughtDef>
<ThoughtDef>
<defName>DrankMilkRaw_Essential</defName>
<durationDays>1</durationDays>
<stages>
<li>
<label>Drank human milk</label>
<description>The taste of fresh breast milk is sweet, fulfilling, and intimate.</description>
<baseMoodEffect>6</baseMoodEffect>
</li>
</stages>
</ThoughtDef>
<ThoughtDef>
<defName>DrankMilkMeal_Essential</defName>
<durationDays>1</durationDays>
<stages>
<li>
<label>Ate meal with human milk</label>
<description>The breast milk accentuated my meal beautifully.</description>
<baseMoodEffect>2</baseMoodEffect>
</li>
</stages>
</ThoughtDef>
<ThoughtDef>
<defName>DrankNonMilkMeal_Essential</defName>
<durationDays>1</durationDays>
<stages>
<li>
<label>Ate non-human milk food</label>
<description>I had to eat food that wasn't produced from a person's breasts. My beliefs strictly forbid such things.</description>
<baseMoodEffect>-2</baseMoodEffect>
</li>
</stages>
</ThoughtDef>
<ThoughtDef>
<defName>NoRecentHumanMilk_Essential</defName>
<thoughtClass>Thought_Situational</thoughtClass>
<workerClass>CRIALactation.ThoughtWorker_Precept_NoRecentHumanMilk</workerClass>
<doNotApplyToQuestLodgers>True</doNotApplyToQuestLodgers>
<stages>
<li>
<label>want human milk</label>
<description>It's been so long since I've tasted the milk of a woman's breasts. I should have had some by now.</description>
<baseMoodEffect>-6</baseMoodEffect>
</li>
</stages>
</ThoughtDef>
</Defs>

View File

@ -16,9 +16,12 @@ namespace CRIALactation
private int TicksSinceLastMassage = -60000;
private float InductionCompletionPercent = 0f;
public bool isActive = false;
public bool CanMassage = true;
public int lastHumanLactationIngestedTick = 0;
public override void CompTick()
{
base.CompTick();
@ -107,6 +110,7 @@ namespace CRIALactation
base.PostExposeData();
Scribe_Values.Look<float>(ref this.InductionCompletionPercent, "InductionCompletionPercent", 0f);
Scribe_Values.Look<int>(ref this.TicksSinceLastMassage, "TicksSinceLastMassage", -60000);
Scribe_Values.Look<int>(ref this.lastHumanLactationIngestedTick, "lastHumanLactationIngestedTick", 0);
Scribe_Values.Look<bool>(ref this.isActive, "IsActive", false);
Scribe_Values.Look<bool>(ref this.CanMassage, "CanMassage", false);

View File

@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using RimWorld;
using Verse;
namespace CRIALactation
{
[HarmonyPatch]
public static class HarmonyPatch_FoodUtility
{
[HarmonyReversePatch(HarmonyReversePatchType.Snapshot)]
[HarmonyPatch(typeof(FoodUtility), "AddThoughtsFromIdeo")]
public static void AddThoughtsFromIdeo_Patch(HistoryEventDef eventDef, Pawn ingester, ThingDef foodDef, MeatSourceCategory meatSourceCategory)
{
throw new NotImplementedException("thoughts from ideo wasn't implemented!");
}
[HarmonyPatch(typeof(FoodUtility), "ThoughtsFromIngesting")]
public static void Postfix(ref List<FoodUtility.ThoughtFromIngesting> __result, ref List<FoodUtility.ThoughtFromIngesting> ___ingestThoughts, Pawn ingester, Thing foodSource, ThingDef foodDef)
{
/**
* checks if food has milk or not
*/
if (ingester.Ideo != null)
{
CompIngredients ingredients = foodSource.TryGetComp<CompIngredients>();
if (foodDef == ThingDefOf_Milk.HumanMilk || foodDef == ThingDefOf_Milk.HumanoidMilk)
{
AddThoughtsFromIdeo_Patch(HistoryEventDefOf_Milk.DrankMilkRaw, ingester, foodDef, FoodUtility.GetMeatSourceCategory(foodDef));
__result = ___ingestThoughts;
}
else if (ingredients == null
|| !(ingredients.ingredients.Contains(ThingDefOf_Milk.HumanMilk) || (ingredients.ingredients.Contains(ThingDefOf_Milk.HumanoidMilk)))) {
AddThoughtsFromIdeo_Patch(HistoryEventDefOf_Milk.DrankNonMilkMeal, ingester, foodDef, FoodUtility.GetMeatSourceCategory(foodDef));
__result = ___ingestThoughts;
}
}
}
[HarmonyPatch(typeof(FoodUtility), "AddIngestThoughtsFromIngredient")]
public static void Postfix(ThingDef ingredient, Pawn ingester) {
MeatSourceCategory meatSourceCategory = FoodUtility.GetMeatSourceCategory(ingredient);
if (ingester.Ideo != null)
{
if (ingredient == ThingDefOf_Milk.HumanoidMilk || ingredient == ThingDefOf_Milk.HumanMilk)
{
AddThoughtsFromIdeo_Patch(HistoryEventDefOf_Milk.DrankMilkMeal, ingester, ingredient, meatSourceCategory);
}
}
}
[HarmonyPatch(typeof(FoodUtility), "GenerateGoodIngredients")]
public static void Postfix(Thing meal, Ideo ideo)
{
CompIngredients compIngredients = meal.TryGetComp<CompIngredients>();
if(ideo.HasPrecept(PreceptDefOf_Lactation.Lactating_Essential))
{
compIngredients.ingredients.Add(ThingDefOf_Milk.HumanMilk);
compIngredients.ingredients.Add(ThingDefOf_Milk.HumanoidMilk);
}
}
}
}

View File

@ -0,0 +1,25 @@
using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using RimWorld;
namespace CRIALactation
{
[HarmonyPatch(typeof(Thing), "Ingested")]
public static class HarmonyPatch_Thing
{
public static void Prefix(Thing __instance, Pawn ingester)
{
if(__instance.def == ThingDefOf_Milk.HumanMilk || __instance.def == ThingDefOf_Milk.HumanoidMilk)
{
ingester.TryGetComp<CompInduceLactation>().lastHumanLactationIngestedTick = Find.TickManager.TicksGame;
}
}
}
}

View File

@ -0,0 +1,24 @@
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CRIALactation
{
[DefOf]
public static class HistoryEventDefOf_Milk
{
static HistoryEventDefOf_Milk()
{
DefOfHelper.EnsureInitializedInCtor(typeof(HistoryEventDefOf_Milk));
}
public static HistoryEventDef DrankMilkRaw;
public static HistoryEventDef DrankMilkMeal;
public static HistoryEventDef DrankNonMilkMeal;
}
}

View File

@ -0,0 +1,24 @@
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace CRIALactation
{
[DefOf]
public static class ThingDefOf_Milk
{
static ThingDefOf_Milk()
{
DefOfHelper.EnsureInitializedInCtor(typeof(ThingDefOf_Milk));
}
public static ThingDef HumanMilk;
public static ThingDef HumanoidMilk;
}
}

View File

@ -23,28 +23,30 @@ namespace CRIALactation
return false;
}
if(!LactationUtility.HasMilkableBreasts(p))
{
return false;
}
if(LactationUtility.IsLactating(p))
if (LactationUtility.IsHucow(p))
{
return ThoughtState.ActiveAtStage(0);
}
if (LactationUtility.IsLactating(p))
{
return ThoughtState.ActiveAtStage(1);
}
if(ExpectationsUtility.CurrentExpectationFor(p).order <= ExpectationDefOf.VeryLow.order)
{
return ThoughtState.ActiveAtStage(1);
return ThoughtState.ActiveAtStage(2);
}
else if(ExpectationsUtility.CurrentExpectationFor(p).order <= ExpectationDefOf.Moderate.order)
{
return ThoughtState.ActiveAtStage(2);
return ThoughtState.ActiveAtStage(3);
}
else
{
return ThoughtState.ActiveAtStage(3);
return ThoughtState.ActiveAtStage(4);
}
}
}

View File

@ -17,24 +17,27 @@ namespace CRIALactation
if (!LactationUtility.HasMilkableBreasts(otherPawn)) return false;
if(LactationUtility.IsLactating(otherPawn))
if (LactationUtility.IsHucow(otherPawn))
{
return ThoughtState.ActiveAtStage(0);
}
else if (LactationUtility.IsLactating(otherPawn))
{
return ThoughtState.ActiveAtStage(1);
}
if (ExpectationsUtility.CurrentExpectationFor(p).order <= ExpectationDefOf.VeryLow.order)
{
return ThoughtState.ActiveAtStage(1);
return ThoughtState.ActiveAtStage(2);
}
else if (ExpectationsUtility.CurrentExpectationFor(p).order <= ExpectationDefOf.Moderate.order)
{
return ThoughtState.ActiveAtStage(2);
return ThoughtState.ActiveAtStage(3);
}
else
{
return ThoughtState.ActiveAtStage(3);
return ThoughtState.ActiveAtStage(4);
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using RimWorld;
using UnityEngine;
namespace CRIALactation
{
public class ThoughtWorker_Precept_NoRecentHumanMilk : ThoughtWorker_Precept, IPreceptCompDescriptionArgs
{
public IEnumerable<NamedArgument> GetDescriptionArgs()
{
yield return MinDaysSinceLastHumanMeatForThought.Named("HUMANMILKREQUIREDINTERVAL");
}
protected override ThoughtState ShouldHaveThought(Pawn p)
{
int num = Mathf.Max(0, p.TryGetComp<CompInduceLactation>().lastHumanLactationIngestedTick);
return Find.TickManager.TicksGame - num > 480000;
}
public const int MinDaysSinceLastHumanMeatForThought = 8;
}
}