2022-07-26 03:55:56 +00:00
|
|
|
|
using RimWorld;
|
2022-08-01 14:21:13 +00:00
|
|
|
|
using Verse;
|
2022-07-26 03:55:56 +00:00
|
|
|
|
|
2022-10-14 15:57:17 +00:00
|
|
|
|
namespace RJWSexperience.Ideology
|
2022-07-26 03:55:56 +00:00
|
|
|
|
{
|
|
|
|
|
public class Thought_Opinionbased : Thought_Memory
|
|
|
|
|
{
|
2022-10-14 15:57:17 +00:00
|
|
|
|
private ThoughtDefExtension_StageFromValue stageFromValue;
|
2022-07-26 03:55:56 +00:00
|
|
|
|
|
2022-10-14 15:57:17 +00:00
|
|
|
|
protected ThoughtDefExtension_StageFromValue StageFromValue
|
2022-07-26 03:55:56 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2022-10-14 15:57:17 +00:00
|
|
|
|
if (stageFromValue == null)
|
2022-08-01 14:21:13 +00:00
|
|
|
|
{
|
2022-10-14 15:57:17 +00:00
|
|
|
|
stageFromValue = def.GetModExtension<ThoughtDefExtension_StageFromValue>();
|
2022-08-01 14:21:13 +00:00
|
|
|
|
}
|
2022-10-14 15:57:17 +00:00
|
|
|
|
return stageFromValue;
|
2022-07-26 03:55:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 14:21:13 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// This method is called for every thought right after the pawn is assigned
|
|
|
|
|
/// </summary>
|
|
|
|
|
public override bool TryMergeWithExistingMemory(out bool showBubble)
|
|
|
|
|
{
|
|
|
|
|
UpdateCurStage();
|
|
|
|
|
return base.TryMergeWithExistingMemory(out showBubble);
|
|
|
|
|
}
|
2022-07-26 03:55:56 +00:00
|
|
|
|
|
2022-08-01 14:21:13 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Called every 150 ticks
|
|
|
|
|
/// </summary>
|
|
|
|
|
public override void ThoughtInterval()
|
2022-07-26 03:55:56 +00:00
|
|
|
|
{
|
2022-08-01 14:21:13 +00:00
|
|
|
|
UpdateCurStage();
|
|
|
|
|
base.ThoughtInterval();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void UpdateCurStage()
|
|
|
|
|
{
|
|
|
|
|
if (otherPawn == null)
|
|
|
|
|
{
|
|
|
|
|
Log.Warning($"[RSI] Thought_Opinionbased {def.defName} for pawn {pawn.NameShortColored} lacks otherPawn");
|
|
|
|
|
SetForcedStage(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float value = pawn.relations?.OpinionOf(otherPawn) ?? 0f;
|
2022-10-14 15:57:17 +00:00
|
|
|
|
SetForcedStage(StageFromValue.GetStageIndex(value));
|
2022-07-26 03:55:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|