mirror of
https://github.com/amevarashi/RJW-Sexperience.git
synced 2024-08-14 23:54:08 +00:00
Optimized Ate Cum thought
This commit is contained in:
parent
cdc79acfa3
commit
8a48d2e463
5 changed files with 61 additions and 56 deletions
|
@ -1,39 +1,28 @@
|
|||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
using Verse;
|
||||
|
||||
namespace RJWSexperience
|
||||
{
|
||||
/// <summary>
|
||||
/// Thought class using record.
|
||||
/// Thought class that uses record to select active stage
|
||||
/// </summary>
|
||||
public class Thought_Recordbased : Thought_Memory
|
||||
{
|
||||
private ThoughtDefExtension_StageFromRecord extension;
|
||||
protected ThoughtDefExtension_StageFromRecord Extension => extension ?? (extension = def.GetModExtension<ThoughtDefExtension_StageFromRecord>());
|
||||
|
||||
protected ThoughtDefExtension_StageFromRecord Extension
|
||||
/// <summary>
|
||||
/// This method is called for every thought right after the pawn is assigned
|
||||
/// </summary>
|
||||
public override bool TryMergeWithExistingMemory(out bool showBubble)
|
||||
{
|
||||
get
|
||||
{
|
||||
if (extension == null)
|
||||
extension = def.GetModExtension<ThoughtDefExtension_StageFromRecord>();
|
||||
return extension;
|
||||
}
|
||||
UpdateCurStage();
|
||||
return base.TryMergeWithExistingMemory(out showBubble);
|
||||
}
|
||||
|
||||
protected RecordDef RecordDef => Extension.recordDef;
|
||||
protected List<float> MinimumValueforStage => Extension.minimumValueforStage;
|
||||
|
||||
public override int CurStageIndex
|
||||
protected virtual void UpdateCurStage()
|
||||
{
|
||||
get
|
||||
{
|
||||
float value = pawn?.records?.GetValue(RecordDef) ?? 0f;
|
||||
for (int i = MinimumValueforStage.Count - 1; i > 0; i--)
|
||||
{
|
||||
if (MinimumValueforStage[i] < value) return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
SetForcedStage(Extension.GetStageIndex(pawn));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue