diff --git a/RJWSexperience/RJWSexperience/RJWSexperience.csproj b/RJWSexperience/RJWSexperience/RJWSexperience.csproj index 6ccae5f..4b54328 100644 --- a/RJWSexperience/RJWSexperience/RJWSexperience.csproj +++ b/RJWSexperience/RJWSexperience/RJWSexperience.csproj @@ -88,8 +88,12 @@ - - + + + + + + diff --git a/RJWSexperience/RJWSexperience/Thought_Opinionbased.cs b/RJWSexperience/RJWSexperience/Thought_Opinionbased.cs deleted file mode 100644 index 7442e35..0000000 --- a/RJWSexperience/RJWSexperience/Thought_Opinionbased.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Verse; -using RimWorld; - - -namespace RJWSexperience -{ - /// - /// ThoughtDef using opinion - /// - public class ThoughtDef_Opinionbased : ThoughtDef - { - public List minimumValueforStage = new List(); - } - - /// - /// Thought class using record. - /// - public class Thought_Opinionbased : Thought_Memory - { - protected ThoughtDef_Opinionbased Def => (ThoughtDef_Opinionbased)def; - protected List minimumValueforStage => Def.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; - } - } - } -} diff --git a/RJWSexperience/RJWSexperience/Thought_Recordbased.cs b/RJWSexperience/RJWSexperience/Thought_Recordbased.cs deleted file mode 100644 index 6080e86..0000000 --- a/RJWSexperience/RJWSexperience/Thought_Recordbased.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Verse; -using RimWorld; - - -namespace RJWSexperience -{ - /// - /// ThoughtDef using record - /// - public class ThoughtDef_Recordbased : ThoughtDef - { - public RecordDef recordDef; - public List minimumValueforStage = new List(); - public float increment; - } - - /// - /// Thought class using record. - /// - public class Thought_Recordbased : Thought_Memory - { - protected ThoughtDef_Recordbased Def => (ThoughtDef_Recordbased)def; - protected RecordDef recordDef => Def.recordDef; - protected List minimumValueforStage => Def.minimumValueforStage; - protected float increment => Def.increment; - - public override int CurStageIndex - { - get - { - float value = pawn?.records?.GetValue(recordDef) ?? 0f; - for (int i = minimumValueforStage.Count - 1; i > 0; i--) - { - if (minimumValueforStage[i] < value) return i + 1; - } - return 0; - } - } - } - - public class Thought_AteCum : Thought_Recordbased - { - public override int CurStageIndex - { - get - { - if (pawn?.health?.hediffSet?.HasHediff(VariousDefOf.CumAddiction) ?? false) return minimumValueforStage.Count; - return base.CurStageIndex; - } - } - - public override bool TryMergeWithExistingMemory(out bool showBubble) - { - ThoughtHandler thoughts = pawn.needs.mood.thoughts; - if (thoughts.memories.NumMemoriesInGroup(this) >= def.stackLimit) - { - Thought_AteCum thought_Memory = (Thought_AteCum)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; - } - - protected virtual void Merged() - { - age = 0; - } - } - - public class Thought_IncreaseRecord : Thought_Recordbased - { - 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; - } - } - - -} diff --git a/RJWSexperience/RJWSexperience/Thoughts/ThoughtDef_Opinionbased.cs b/RJWSexperience/RJWSexperience/Thoughts/ThoughtDef_Opinionbased.cs new file mode 100644 index 0000000..6283437 --- /dev/null +++ b/RJWSexperience/RJWSexperience/Thoughts/ThoughtDef_Opinionbased.cs @@ -0,0 +1,15 @@ +using RimWorld; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace RJWSexperience +{ + /// + /// ThoughtDef using opinion + /// + public class ThoughtDef_Opinionbased : ThoughtDef + { + [SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")] + public List minimumValueforStage = new List(); + } +} diff --git a/RJWSexperience/RJWSexperience/Thoughts/ThoughtDef_Recordbased.cs b/RJWSexperience/RJWSexperience/Thoughts/ThoughtDef_Recordbased.cs new file mode 100644 index 0000000..b4702ad --- /dev/null +++ b/RJWSexperience/RJWSexperience/Thoughts/ThoughtDef_Recordbased.cs @@ -0,0 +1,19 @@ +using RimWorld; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace RJWSexperience +{ + /// + /// ThoughtDef using record + /// + public class ThoughtDef_Recordbased : ThoughtDef + { + [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 List minimumValueforStage = new List(); + [SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")] + public float increment; + } +} diff --git a/RJWSexperience/RJWSexperience/Thoughts/Thought_AteCum.cs b/RJWSexperience/RJWSexperience/Thoughts/Thought_AteCum.cs new file mode 100644 index 0000000..36303d5 --- /dev/null +++ b/RJWSexperience/RJWSexperience/Thoughts/Thought_AteCum.cs @@ -0,0 +1,38 @@ +using RimWorld; + +namespace RJWSexperience +{ + public class Thought_AteCum : Thought_Recordbased + { + public override int CurStageIndex + { + get + { + if (pawn?.health?.hediffSet?.HasHediff(VariousDefOf.CumAddiction) ?? false) return MinimumValueforStage.Count; + return base.CurStageIndex; + } + } + + public override bool TryMergeWithExistingMemory(out bool showBubble) + { + ThoughtHandler thoughts = pawn.needs.mood.thoughts; + if (thoughts.memories.NumMemoriesInGroup(this) >= def.stackLimit) + { + Thought_AteCum thought_Memory = (Thought_AteCum)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; + } + + protected virtual void Merged() + { + age = 0; + } + } +} diff --git a/RJWSexperience/RJWSexperience/Thoughts/Thought_IncreaseRecord.cs b/RJWSexperience/RJWSexperience/Thoughts/Thought_IncreaseRecord.cs new file mode 100644 index 0000000..b5f59c4 --- /dev/null +++ b/RJWSexperience/RJWSexperience/Thoughts/Thought_IncreaseRecord.cs @@ -0,0 +1,55 @@ +using RimWorld; +using Verse; + +namespace RJWSexperience +{ + public class Thought_IncreaseRecord : Thought_Recordbased + { + 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; + } + } +} diff --git a/RJWSexperience/RJWSexperience/Thoughts/Thought_Opinionbased.cs b/RJWSexperience/RJWSexperience/Thoughts/Thought_Opinionbased.cs new file mode 100644 index 0000000..afa06aa --- /dev/null +++ b/RJWSexperience/RJWSexperience/Thoughts/Thought_Opinionbased.cs @@ -0,0 +1,28 @@ +using RimWorld; +using System.Collections.Generic; + +namespace RJWSexperience +{ + /// + /// Thought class using record. + /// + public class Thought_Opinionbased : Thought_Memory + { + protected ThoughtDef_Opinionbased Def => (ThoughtDef_Opinionbased)def; + protected List MinimumValueforStage => Def.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; + } + } + } +} diff --git a/RJWSexperience/RJWSexperience/Thoughts/Thought_Recordbased.cs b/RJWSexperience/RJWSexperience/Thoughts/Thought_Recordbased.cs new file mode 100644 index 0000000..d7ccd37 --- /dev/null +++ b/RJWSexperience/RJWSexperience/Thoughts/Thought_Recordbased.cs @@ -0,0 +1,29 @@ +using RimWorld; +using System.Collections.Generic; + +namespace RJWSexperience +{ + /// + /// Thought class using record. + /// + public class Thought_Recordbased : Thought_Memory + { + protected ThoughtDef_Recordbased Def => (ThoughtDef_Recordbased)def; + protected RecordDef RecordDef => Def.recordDef; + protected List MinimumValueforStage => Def.minimumValueforStage; + protected float Increment => Def.increment; + + public override int CurStageIndex + { + get + { + float value = pawn?.records?.GetValue(RecordDef) ?? 0f; + for (int i = MinimumValueforStage.Count - 1; i > 0; i--) + { + if (MinimumValueforStage[i] < value) return i + 1; + } + return 0; + } + } + } +}