Danimineiro / BundleOfTraits

A Rimworld Mod that adds new traits
https://steamcommunity.com/sharedfiles/filedetails/?id=2600986277
MIT License
0 stars 2 forks source link

[BUG] Another error: System.ArgumentNullException: Value cannot be null. #4

Closed Taranchuk closed 2 years ago

Taranchuk commented 2 years ago

Describe the bug After resubbing to the mod to fetch new update, got this error on the same error

System.ArgumentNullException: Value cannot be null.
Parameter name: key
  at System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) [0x00008] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].ContainsKey (TKey key) [0x00000] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at More_Traits.BOTTraitsManager.ManageFleeing (System.Int32 whenTicksDivisibleBy, System.Collections.Generic.HashSet`1[T] hashSet) [0x0004e] in <ea0db61a3c9445dda0a6d7fb5bf88cea>:0 
  at More_Traits.BOTTraitsManager.GameComponentTick () [0x00008] in <ea0db61a3c9445dda0a6d7fb5bf88cea>:0 
  at Verse.GameComponentUtility.GameComponentTick () [0x00017] in <34cd8c64c0e04e56a196186f1b4f7089>:0 
UnityEngine.StackTraceUtility:ExtractStackTrace ()
(wrapper dynamic-method) Verse.Log:Verse.Log.Error_Patch4 (string)
Verse.GameComponentUtility:GameComponentTick ()
(wrapper dynamic-method) Verse.TickManager:Verse.TickManager.DoSingleTick_Patch5 (Verse.TickManager)
Verse.TickManager:TickManagerUpdate ()
(wrapper dynamic-method) Verse.Game:Verse.Game.UpdatePlay_Patch3 (Verse.Game)
Verse.Root_Play:Update ()

Logs https://gist.github.com/a536c466c83ae3d853a8568c2d955317

Taranchuk commented 2 years ago

Just out of curiousity, I took a look at the code and it seems that you need to inverse the logic here https://github.com/Danimineiro/BundleOfTraits/blob/master/src/More%20Traits/More%20Traits/BOTTraitsManager.cs#L182 so: foreach (Pawn pawn in hashSet.Where(pawn => ShouldSkipFleeingForPawn(pawn))) becomes foreach (Pawn pawn in hashSet.Where(pawn => ShouldSkipFleeingForPawn(pawn) == false))

Danimineiro commented 2 years ago

nah it's inside the thing, I moved the Map null check in there, but it should return false instead of true here: if (pawn?.Map == null || !pawn.Spawned) return true;

Coding at 1 am be like, is all I can say in my defence to that

Danimineiro commented 2 years ago

No you are right, I'm so dumb

Danimineiro commented 2 years ago

Okay, reversed that thingy like you mentioned, I'm really sorry about the bugs, I'll be sleeping now though