Refactor ThoughtDefExtension_StageFromOpinion

This commit is contained in:
amevarashi 2022-10-14 20:57:17 +05:00
parent eda7261968
commit 5db34c0c1f
3 changed files with 26 additions and 23 deletions

View file

@ -1,22 +1,21 @@
using RimWorld;
using System.Collections.Generic;
using Verse;
namespace RJWSexperience
namespace RJWSexperience.Ideology
{
public class Thought_Opinionbased : Thought_Memory
{
private List<float> minimumValueforStage;
private ThoughtDefExtension_StageFromValue stageFromValue;
protected List<float> MinimumValueforStage
protected ThoughtDefExtension_StageFromValue StageFromValue
{
get
{
if (minimumValueforStage == null)
if (stageFromValue == null)
{
minimumValueforStage = def.GetModExtension<ThoughtDefExtension_StageFromOpinion>().minimumValueforStage;
stageFromValue = def.GetModExtension<ThoughtDefExtension_StageFromValue>();
}
return minimumValueforStage;
return stageFromValue;
}
}
@ -47,16 +46,7 @@ namespace RJWSexperience
}
float value = pawn.relations?.OpinionOf(otherPawn) ?? 0f;
for (int i = MinimumValueforStage.Count - 1; i > 0; i--)
{
if (MinimumValueforStage[i] < value)
{
SetForcedStage(i);
return;
}
}
SetForcedStage(0);
SetForcedStage(StageFromValue.GetStageIndex(value));
}
}
}