mirror of
https://gitgud.io/amevarashi/rjw-sexperience-ideology.git
synced 2024-08-15 00:43:19 +00:00
Initial commit
This commit is contained in:
commit
8c960f3d15
182 changed files with 10200 additions and 0 deletions
|
@ -0,0 +1,14 @@
|
|||
using RimWorld;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Verse;
|
||||
|
||||
namespace RJWSexperience
|
||||
{
|
||||
public class ThoughtDefExtension_IncreaseRecord : DefModExtension
|
||||
{
|
||||
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
|
||||
public RecordDef recordDef;
|
||||
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
|
||||
public float increment;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Verse;
|
||||
|
||||
namespace RJWSexperience
|
||||
{
|
||||
public class ThoughtDefExtension_StageFromOpinion : DefModExtension
|
||||
{
|
||||
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
|
||||
public List<float> minimumValueforStage = new List<float>();
|
||||
}
|
||||
}
|
70
Source/IdeologyAddon/Thoughts/Thought_IncreaseRecord.cs
Normal file
70
Source/IdeologyAddon/Thoughts/Thought_IncreaseRecord.cs
Normal file
|
@ -0,0 +1,70 @@
|
|||
using RimWorld;
|
||||
using Verse;
|
||||
|
||||
namespace RJWSexperience
|
||||
{
|
||||
public class Thought_IncreaseRecord : Thought_Memory
|
||||
{
|
||||
private ThoughtDefExtension_IncreaseRecord extension;
|
||||
|
||||
protected ThoughtDefExtension_IncreaseRecord Extension
|
||||
{
|
||||
get
|
||||
{
|
||||
if (extension == null)
|
||||
extension = def.GetModExtension<ThoughtDefExtension_IncreaseRecord>();
|
||||
return extension;
|
||||
}
|
||||
}
|
||||
|
||||
protected RecordDef RecordDef => Extension.recordDef;
|
||||
protected float Increment => Extension.increment;
|
||||
|
||||
protected float recordIncrement;
|
||||
|
||||
public override void ExposeData()
|
||||
{
|
||||
base.ExposeData();
|
||||
Scribe_Values.Look(ref recordIncrement, "recordIncrement", recordIncrement, true);
|
||||
}
|
||||
|
||||
public override void ThoughtInterval()
|
||||
{
|
||||
base.ThoughtInterval();
|
||||
if (recordIncrement != 0)
|
||||
{
|
||||
pawn.records.AddTo(RecordDef, recordIncrement);
|
||||
recordIncrement = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool TryMergeWithExistingMemory(out bool showBubble)
|
||||
{
|
||||
ThoughtHandler thoughts = pawn.needs.mood.thoughts;
|
||||
if (thoughts.memories.NumMemoriesInGroup(this) >= def.stackLimit)
|
||||
{
|
||||
Thought_IncreaseRecord thought_Memory = (Thought_IncreaseRecord)thoughts.memories.OldestMemoryInGroup(this);
|
||||
if (thought_Memory != null)
|
||||
{
|
||||
showBubble = (thought_Memory.age > thought_Memory.def.DurationTicks / 2);
|
||||
thought_Memory.Merged();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
showBubble = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
recordIncrement = Increment;
|
||||
}
|
||||
|
||||
protected virtual void Merged()
|
||||
{
|
||||
age = 0;
|
||||
recordIncrement += Increment;
|
||||
}
|
||||
}
|
||||
}
|
36
Source/IdeologyAddon/Thoughts/Thought_Opinionbased.cs
Normal file
36
Source/IdeologyAddon/Thoughts/Thought_Opinionbased.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RJWSexperience
|
||||
{
|
||||
public class Thought_Opinionbased : Thought_Memory
|
||||
{
|
||||
private ThoughtDefExtension_StageFromOpinion extension;
|
||||
|
||||
protected ThoughtDefExtension_StageFromOpinion Extension
|
||||
{
|
||||
get
|
||||
{
|
||||
if (extension == null)
|
||||
extension = def.GetModExtension<ThoughtDefExtension_StageFromOpinion>();
|
||||
return extension;
|
||||
}
|
||||
}
|
||||
|
||||
protected List<float> MinimumValueforStage => Extension.minimumValueforStage;
|
||||
|
||||
public override int CurStageIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
float value = 0f;
|
||||
if (otherPawn != null) value = pawn.relations?.OpinionOf(otherPawn) ?? 0f;
|
||||
for (int i = MinimumValueforStage.Count - 1; i > 0; i--)
|
||||
{
|
||||
if (MinimumValueforStage[i] < value) return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue