Refactor genital size ThoughtWorkers to use ThoughtDefExtension_StageFromValue

This commit is contained in:
amevarashi 2022-10-14 21:09:19 +05:00
parent 5db34c0c1f
commit 8da97c4833
8 changed files with 124 additions and 129 deletions

View File

@ -63,7 +63,7 @@
<ThoughtDef>
<defName>GenitalSize_Approved</defName>
<thoughtClass>Thought_Situational</thoughtClass>
<workerClass>RJWSexperience.Ideology.ThoughtWorker_Precept_GenitalSize_Approved</workerClass>
<workerClass>RJWSexperience.Ideology.PreceptWorkers.ThoughtWorker_Precept_GenitalSize</workerClass>
<stages>
<li>
<label>Despised Genitalsize</label>
@ -91,11 +91,24 @@
<baseMoodEffect>+10</baseMoodEffect>
</li>
</stages>
<modExtensions>
<li Class="RJWSexperience.Ideology.ThoughtDefExtension_StageFromValue">
<!-- We have 5 stages, which map directly to genitalia severity:
Micro(<0.2), Small(>0.2&&<0.4), Normal(>0.4&&<0.6), Big(>0.6&&<0.8), Huge(>0.8) -->
<minimumValueforStage>
<li>0</li>
<li>0.2</li>
<li>0.4</li>
<li>0.6</li>
<li>0.8</li>
</minimumValueforStage>
</li>
</modExtensions>
</ThoughtDef>
<ThoughtDef>
<defName>GenitalSize_Disapproved</defName>
<workerClass>RJWSexperience.Ideology.ThoughtWorker_Precept_GenitalSize_Disapproved</workerClass>
<workerClass>RJWSexperience.Ideology.PreceptWorkers.ThoughtWorker_Precept_GenitalSize</workerClass>
<thoughtClass>Thought_Situational</thoughtClass>
<stages>
<li>
@ -124,13 +137,26 @@
<baseMoodEffect>-10</baseMoodEffect>
</li>
</stages>
<modExtensions>
<li Class="RJWSexperience.Ideology.ThoughtDefExtension_StageFromValue">
<!-- We have 5 stages, which map directly to genitalia severity:
Micro(<0.2), Small(>0.2&&<0.4), Normal(>0.4&&<0.6), Big(>0.6&&<0.8), Huge(>0.8) -->
<minimumValueforStage>
<li>0</li>
<li>0.2</li>
<li>0.4</li>
<li>0.6</li>
<li>0.8</li>
</minimumValueforStage>
</li>
</modExtensions>
</ThoughtDef>
<!-- Social-Thoughts (Opinion)-->
<ThoughtDef>
<defName>GenitalSize_Approved_Social</defName>
<workerClass>RJWSexperience.Ideology.ThoughtWorker_Precept_GenitalSize_Approved_Social</workerClass>
<workerClass>RJWSexperience.Ideology.PreceptWorkers.ThoughtWorker_Precept_GenitalSize_Social</workerClass>
<thoughtClass>Thought_SituationalSocial</thoughtClass>
<stages>
<li>
@ -146,12 +172,23 @@
<baseOpinionOffset>+5</baseOpinionOffset>
</li>
</stages>
<modExtensions>
<li Class="RJWSexperience.Ideology.ThoughtDefExtension_StageFromValue">
<!-- We have 3 stages, which map directly to genitalia severity:
Unfavorable(<0.4), Normal(>0.4&&<0.6), Favorable(>0.6) -->
<minimumValueforStage>
<li>0</li>
<li>0.4</li>
<li>0.6</li>
</minimumValueforStage>
</li>
</modExtensions>
</ThoughtDef>
<ThoughtDef>
<defName>GenitalSize_Disapproved_Social</defName>
<workerClass>RJWSexperience.Ideology.ThoughtWorker_Precept_GenitalSize_Disapproved_Social</workerClass>
<workerClass>RJWSexperience.Ideology.PreceptWorkers.ThoughtWorker_Precept_GenitalSize_Social</workerClass>
<thoughtClass>Thought_SituationalSocial</thoughtClass>
<stages>
<li>
@ -167,6 +204,17 @@
<baseOpinionOffset>+5</baseOpinionOffset>
</li>
</stages>
<modExtensions>
<li Class="RJWSexperience.Ideology.ThoughtDefExtension_StageFromValue">
<!-- We have 3 stages, which map directly to genitalia severity:
Unfavorable(<0.4), Normal(>0.4&&<0.6), Favorable(>0.6) -->
<minimumValueforStage>
<li>0</li>
<li>0.4</li>
<li>0.6</li>
</minimumValueforStage>
</li>
</modExtensions>
</ThoughtDef>
</Defs>

View File

@ -0,0 +1,34 @@
using RimWorld;
using rjw;
using Verse;
namespace RJWSexperience.Ideology.PreceptWorkers
{
public class ThoughtWorker_Precept_GenitalSize : ThoughtWorker_Precept
{
private ThoughtDefExtension_StageFromValue stageFromValue;
protected ThoughtDefExtension_StageFromValue StageFromValue
{
get
{
if (stageFromValue == null)
{
stageFromValue = def.GetModExtension<ThoughtDefExtension_StageFromValue>();
}
return stageFromValue;
}
}
protected override ThoughtState ShouldHaveThought(Pawn p)
{
if (p != null && Genital_Helper.get_AllPartsHediffList(p).Count > 0)
{
float bestSize = IdeoUtility.getGenitalSize(p);
return ThoughtState.ActiveAtStage(StageFromValue.GetStageIndex(bestSize));
}
// This might can happen if the pawn has no genitalia ... maybe?
return ThoughtState.Inactive;
}
}
}

View File

@ -1,31 +0,0 @@
using RimWorld;
using rjw;
using Verse;
namespace RJWSexperience.Ideology
{
public class ThoughtWorker_Precept_GenitalSize_Approved : ThoughtWorker_Precept
{
protected override ThoughtState ShouldHaveThought(Pawn p)
{
// We have 5 stages, which map directly to genitalia severity:
// Micro(<0.2), Small(>0.2&&<0.4), Normal(>0.4&&<0.6), Big(>0.6&&<0.8), Huge(>0.8)
if (p != null && Genital_Helper.get_AllPartsHediffList(p).Count > 0)
{
float best_size = IdeoUtility.getGenitalSize(p);
if (best_size < 0.2f)
return ThoughtState.ActiveAtStage(0);
else if (best_size < 0.4f)
return ThoughtState.ActiveAtStage(1);
else if (best_size < 0.6f)
return ThoughtState.ActiveAtStage(2);
else if (best_size < 0.8f)
return ThoughtState.ActiveAtStage(3);
else if (best_size > 0.8f)
return ThoughtState.ActiveAtStage(4);
}
// This might can happen if the pawn has no genitalia ... maybe?
return ThoughtState.Inactive;
}
}
}

View File

@ -1,29 +0,0 @@
using RimWorld;
using rjw;
using Verse;
namespace RJWSexperience.Ideology
{
public class ThoughtWorker_Precept_GenitalSize_Approved_Social : ThoughtWorker_Precept_Social
{
// Important Note: For the Social Worker, we measure otherPawns genitalia
protected override ThoughtState ShouldHaveThought(Pawn p, Pawn otherPawn)
{
// We have 3 stages, which map directly to genitalia severity:
// Unfavorable(<0.4), Normal(>0.4&&<0.6), Favorable(>0.6)
if (otherPawn != null && Genital_Helper.get_AllPartsHediffList(otherPawn).Count > 0)
{
float best_size = IdeoUtility.getGenitalSize(otherPawn);
if (best_size < 0.4f)
return ThoughtState.ActiveAtStage(0);
else if (best_size < 0.6f)
return ThoughtState.ActiveAtStage(1);
else if (best_size > 0.6f)
return ThoughtState.ActiveAtStage(2);
}
// This might can happen if the pawn has no genitalia ... maybe?
return ThoughtState.Inactive;
}
}
}

View File

@ -1,32 +0,0 @@
using RimWorld;
using rjw;
using Verse;
namespace RJWSexperience.Ideology
{
public class ThoughtWorker_Precept_GenitalSize_Disapproved : ThoughtWorker_Precept
{
protected override ThoughtState ShouldHaveThought(Pawn p)
{
// We have 5 stages, which map directly to genitalia severity:
// Micro(<0.2), Small(>0.2&&<0.4), Normal(>0.4&&<0.6), Big(>0.6&&<0.8), Huge(>0.8)
if (p != null && Genital_Helper.get_AllPartsHediffList(p).Count > 0)
{
float best_size = IdeoUtility.getGenitalSize(p);
if (best_size < 0.2f)
return ThoughtState.ActiveAtStage(0);
else if (best_size < 0.4f)
return ThoughtState.ActiveAtStage(1);
else if (best_size < 0.6f)
return ThoughtState.ActiveAtStage(2);
else if (best_size < 0.8f)
return ThoughtState.ActiveAtStage(3);
else if (best_size > 0.8f)
return ThoughtState.ActiveAtStage(4);
}
// This might can happen if the pawn has no genitalia ... maybe?
return ThoughtState.Inactive;
}
}
}

View File

@ -1,28 +0,0 @@
using RimWorld;
using rjw;
using Verse;
namespace RJWSexperience.Ideology
{
public class ThoughtWorker_Precept_GenitalSize_Disapproved_Social : ThoughtWorker_Precept_Social
{
// Important Note: For the Social Worker, we measure otherPawns genitalia
protected override ThoughtState ShouldHaveThought(Pawn p, Pawn otherPawn)
{
// We have 3 stages, which map directly to genitalia severity:
// Unfavorable(<0.4), Normal(>0.4&&<0.6), Favorable(>0.6)
if (otherPawn != null && Genital_Helper.get_AllPartsHediffList(otherPawn).Count > 0)
{
float best_size = IdeoUtility.getGenitalSize(otherPawn);
if (best_size < 0.4f)
return ThoughtState.ActiveAtStage(0);
else if (best_size < 0.6f)
return ThoughtState.ActiveAtStage(1);
else if (best_size > 0.6f)
return ThoughtState.ActiveAtStage(2);
}
// This might can happen if the pawn has no genitalia ... maybe?
return ThoughtState.Inactive;
}
}
}

View File

@ -0,0 +1,35 @@
using RimWorld;
using rjw;
using Verse;
namespace RJWSexperience.Ideology.PreceptWorkers
{
public class ThoughtWorker_Precept_GenitalSize_Social : ThoughtWorker_Precept_Social
{
private ThoughtDefExtension_StageFromValue stageFromValue;
protected ThoughtDefExtension_StageFromValue StageFromValue
{
get
{
if (stageFromValue == null)
{
stageFromValue = def.GetModExtension<ThoughtDefExtension_StageFromValue>();
}
return stageFromValue;
}
}
// Important Note: For the Social Worker, we measure otherPawns genitalia
protected override ThoughtState ShouldHaveThought(Pawn p, Pawn otherPawn)
{
if (otherPawn != null && Genital_Helper.get_AllPartsHediffList(otherPawn).Count > 0)
{
float bestSize = IdeoUtility.getGenitalSize(otherPawn);
return ThoughtState.ActiveAtStage(StageFromValue.GetStageIndex(bestSize));
}
// This might can happen if the pawn has no genitalia ... maybe?
return ThoughtState.Inactive;
}
}
}

View File

@ -52,10 +52,8 @@
<Compile Include="Harmony.cs" />
<Compile Include="Ideology\HistoryEvents\ArgsNamesCustom.cs" />
<Compile Include="Ideology\Keyed.cs" />
<Compile Include="Ideology\PreceptWorkers\ThoughtWorker_Precept_GenitalSize_Approved.cs" />
<Compile Include="Ideology\PreceptWorkers\ThoughtWorker_Precept_GenitalSize_Approved_Social.cs" />
<Compile Include="Ideology\PreceptWorkers\ThoughtWorker_Precept_GenitalSize_Disapproved.cs" />
<Compile Include="Ideology\PreceptWorkers\ThoughtWorker_Precept_GenitalSize_Disapproved_Social.cs" />
<Compile Include="Ideology\PreceptWorkers\ThoughtWorker_Precept_GenitalSize.cs" />
<Compile Include="Ideology\PreceptWorkers\ThoughtWorker_Precept_GenitalSize_Social.cs" />
<Compile Include="Ideology\PreceptWorkers\ThoughtWorker_Precept_NonPregnant.cs" />
<Compile Include="Ideology\PreceptWorkers\ThoughtWorker_Precept_NonPregnant_Social.cs" />
<Compile Include="Ideology\PreceptWorkers\ThoughtWorker_Precept_Pregnant.cs" />
@ -89,7 +87,7 @@
<Compile Include="Ideology\StatParts.cs" />
<Compile Include="Ideology\IdeoUtility.cs" />
<Compile Include="Thoughts\ThoughtDefExtension_IncreaseRecord.cs" />
<Compile Include="Thoughts\ThoughtDefExtension_StageFromOpinion.cs" />
<Compile Include="Thoughts\ThoughtDefExtension_StageFromValue.cs" />
<Compile Include="Thoughts\Thought_IncreaseRecord.cs" />
<Compile Include="Thoughts\Thought_Opinionbased.cs" />
<Compile Include="Ideology\VariousDefOf.cs" />