diff --git a/Source/AllModdingComponents/ThinkNodes/ThinkNode_ConditionalDelay.cs b/Source/AllModdingComponents/ThinkNodes/ThinkNode_ConditionalDelay.cs new file mode 100644 index 00000000..8c68654f --- /dev/null +++ b/Source/AllModdingComponents/ThinkNodes/ThinkNode_ConditionalDelay.cs @@ -0,0 +1,42 @@ +using System.Collections.Generic; +using Verse; +using Verse.AI; + +namespace ThinkNodes +{ + public class ThinkNode_ConditionalDelay : ThinkNode_Conditional + { + public int min = 1000, max= 2000; + + private Dictionary delays = new Dictionary(); + protected override bool Satisfied(Pawn pawn) + { + var key = GetKey(pawn); + if (delays.TryGetValue(key, out var tick)) + { + var tik = Find.TickManager.TicksGame; + + if (tik > tick) + { + AddDelay(key); + return true; + } + } + else + { + AddDelay(key); + } + return false; + } + + public virtual string GetKey(Pawn pawn) + { + return pawn.GetUniqueLoadID(); + } + + public virtual void AddDelay(string key) + { + delays[key] = Find.TickManager.TicksGame + Rand.Range(min, max); + } + } +} \ No newline at end of file diff --git a/Source/AllModdingComponents/ThinkNodes/ThinkNode_ConditionalHunter.cs b/Source/AllModdingComponents/ThinkNodes/ThinkNode_ConditionalHunter.cs new file mode 100644 index 00000000..ec48e858 --- /dev/null +++ b/Source/AllModdingComponents/ThinkNodes/ThinkNode_ConditionalHunter.cs @@ -0,0 +1,21 @@ +using RimWorld; +using Verse; +using Verse.AI; + +namespace ThinkNodes +{ + public class ThinkNode_ConditionalHunter : ThinkNode_Conditional + { + public bool allowBrawlers = false; + + protected override bool Satisfied(Pawn pawn) + { + return AmHunter(pawn) && (allowBrawlers || !pawn.story.traits.HasTrait(TraitDefOf.Brawler)); + } + + public static bool AmHunter(Pawn pawn) + { + return pawn.workSettings.WorkIsActive(WorkTypeDefOf.Hunting); + } + } +} \ No newline at end of file diff --git a/Source/AllModdingComponents/ThinkNodes/ThinkNode_ConditionalMissingWeapon.cs b/Source/AllModdingComponents/ThinkNodes/ThinkNode_ConditionalMissingWeapon.cs new file mode 100644 index 00000000..f46e1ab5 --- /dev/null +++ b/Source/AllModdingComponents/ThinkNodes/ThinkNode_ConditionalMissingWeapon.cs @@ -0,0 +1,14 @@ +using RimWorld; +using Verse; +using Verse.AI; + +namespace ThinkNodes +{ + public class ThinkNode_ConditionalMissingHuntingWeapon : ThinkNode_Conditional + { + protected override bool Satisfied(Pawn pawn) + { + return !WorkGiver_HunterHunt.HasHuntingWeapon(pawn); + } + } +} \ No newline at end of file diff --git a/Source/AllModdingComponents/ThinkNodes/ThinkNodes.csproj b/Source/AllModdingComponents/ThinkNodes/ThinkNodes.csproj index 17f31ccf..0d4c1965 100644 --- a/Source/AllModdingComponents/ThinkNodes/ThinkNodes.csproj +++ b/Source/AllModdingComponents/ThinkNodes/ThinkNodes.csproj @@ -49,7 +49,10 @@ + + +