emipa606 / GradualRomance

A relationship mod for Rimworld
MIT License
1 stars 1 forks source link

Error in tooltip creation for social opinion between non-humanlikes #3

Closed thailyn closed 10 months ago

thailyn commented 10 months ago

There are two slightly different errors that have the same fundamental cause. The errors happen in these two cases:

  1. Viewing the tooltip for an animal pawn's social opinion of another pawn (e.g., its bonded human pawn or an animal family member).
  2. Viewing the tooltip for a humanoid pawn's social opinion of an animal pawn.

See below for example errors.

In short, some of the AttractionCalculator classes are essentially assuming the pawn or pawns in question are humanlike, as only they have certain fields or mod extensions, and not animals. The RimWorld.SocialCardUtility.GetPawnRowTooltip method gets both secondary lovin' and romance chance factors, and both of those are patched by this mod to include these additional calculations.


Example error for case (1):

System.NullReferenceException: Object reference not set to an instance of an object
  at Gradual_Romance.AttractionUtility.CalculateAttraction (Verse.Pawn observer, Verse.Pawn assessed, System.Boolean attractionOnly, System.Boolean formalRelationship, System.Collections.Generic.List`1[Gradual_Romance.AttractionFactorDef]& veryLowFactors, System.Collections.Generic.List`1[Gradual_Romance.AttractionFactorDef]& lowFactors, System.Collections.Generic.List`1[Gradual_Romance.AttractionFactorDef]& highFactors, System.Collections.Generic.List`1[Gradual_Romance.AttractionFactorDef]& veryHighFactors, Gradual_Romance.AttractionFactorDef& reasonForInstantFailure) [0x0002b] in <4cb17cbfe7fa40d6be7cdf2c99206c61>:0 
  at Gradual_Romance.AttractionUtility.CalculateAttraction (Verse.Pawn observer, Verse.Pawn assessed, System.Boolean attractionOnly, System.Boolean formalRelationship) [0x00001] in <4cb17cbfe7fa40d6be7cdf2c99206c61>:0 
  at Gradual_Romance.Harmony.GRSecondaryLovinChanceFactorPatch.GRSecondaryLovinChanceFactor (RimWorld.Pawn_RelationsTracker __instance, System.Single& __result, Verse.Pawn& ___pawn, Verse.Pawn otherPawn) [0x00001] in <4cb17cbfe7fa40d6be7cdf2c99206c61>:0 
  at (wrapper dynamic-method) RimWorld.Pawn_RelationsTracker.RimWorld.Pawn_RelationsTracker.SecondaryLovinChanceFactor_Patch2(RimWorld.Pawn_RelationsTracker,Verse.Pawn)
  at (wrapper dynamic-method) RimWorld.Pawn_RelationsTracker.RimWorld.Pawn_RelationsTracker.SecondaryRomanceChanceFactor_Patch1(RimWorld.Pawn_RelationsTracker,Verse.Pawn)
  at RimWorld.SocialCardUtility.GetPawnRowTooltip (RimWorld.SocialCardUtility+CachedSocialTabEntry entry, Verse.Pawn selPawnForSocialInfo) [0x0014c] in <95de19971c5d40878d8742747904cdcd>:0 
  at RimWorld.SocialCardUtility+<>c__DisplayClass50_0.<DrawPawnRow>b__0 () [0x00000] in <95de19971c5d40878d8742747904cdcd>:0 
  at (wrapper dynamic-method) Verse.ActiveTip.Verse.ActiveTip.get_FinalText_Patch0(Verse.ActiveTip)
UnityEngine.StackTraceUtility:ExtractStackTrace ()
(wrapper dynamic-method) Verse.Log:Verse.Log.Error_Patch0 (string)
(wrapper dynamic-method) Verse.ActiveTip:Verse.ActiveTip.get_FinalText_Patch0 (Verse.ActiveTip)
Verse.ActiveTip:get_TipRect ()
Verse.TooltipHandler:CalculateInitialTipPosition (System.Collections.Generic.List`1<Verse.ActiveTip>)
Verse.TooltipHandler:DrawActiveTips ()
(wrapper dynamic-method) Verse.TooltipHandler:Verse.TooltipHandler.DoTooltipGUI_Patch1 ()
(wrapper dynamic-method) Verse.UIRoot:Verse.UIRoot.UIRootOnGUI_Patch2 (Verse.UIRoot)
RimWorld.UIRoot_Play:UIRootOnGUI ()
(wrapper dynamic-method) Verse.Root:Verse.Root.OnGUI_Patch1 (Verse.Root)

Example error for case (2):

System.NullReferenceException: Object reference not set to an instance of an object
  at Gradual_Romance.AttractionCalculator_Beauty.Check (Verse.Pawn observer, Verse.Pawn assessed) [0x0001c] in <3146e24e6706404284b4577f0ae30dcf>:0 
  at Gradual_Romance.AttractionUtility.CalculateAttractionCategory (Gradual_Romance.AttractionFactorCategoryDef category, Verse.Pawn observer, Verse.Pawn assessed, System.Collections.Generic.List`1[Gradual_Romance.AttractionFactorDef]& veryLowFactors, System.Collections.Generic.List`1[Gradual_Romance.AttractionFactorDef]& lowFactors, System.Collections.Generic.List`1[Gradual_Romance.AttractionFactorDef]& highFactors, System.Collections.Generic.List`1[Gradual_Romance.AttractionFactorDef]& veryHighFactors, Gradual_Romance.AttractionFactorDef& reasonForInstantFailure) [0x0006b] in <3146e24e6706404284b4577f0ae30dcf>:0 
  at Gradual_Romance.GRPawnComp+AttractionRecord..ctor (Verse.Pawn pawn, Verse.Pawn other) [0x00085] in <3146e24e6706404284b4577f0ae30dcf>:0 
  at Gradual_Romance.GRPawnComp.PullRecord (Verse.Pawn other, System.Boolean noUpdate) [0x00021] in <3146e24e6706404284b4577f0ae30dcf>:0 
  at Gradual_Romance.GRPawnComp.RetrieveAttractionAndFactors (Verse.Pawn other, System.Collections.Generic.List`1[Gradual_Romance.AttractionFactorDef]& veryLowFactors, System.Collections.Generic.List`1[Gradual_Romance.AttractionFactorDef]& lowFactors, System.Collections.Generic.List`1[Gradual_Romance.AttractionFactorDef]& highFactors, System.Collections.Generic.List`1[Gradual_Romance.AttractionFactorDef]& veryHighFactors, System.Boolean romantic, System.Boolean chanceOnly) [0x00001] in <3146e24e6706404284b4577f0ae30dcf>:0 
  at Gradual_Romance.AttractionUtility.CalculateAttraction (Verse.Pawn observer, Verse.Pawn assessed, System.Boolean attractionOnly, System.Boolean formalRelationship, System.Collections.Generic.List`1[Gradual_Romance.AttractionFactorDef]& veryLowFactors, System.Collections.Generic.List`1[Gradual_Romance.AttractionFactorDef]& lowFactors, System.Collections.Generic.List`1[Gradual_Romance.AttractionFactorDef]& highFactors, System.Collections.Generic.List`1[Gradual_Romance.AttractionFactorDef]& veryHighFactors, Gradual_Romance.AttractionFactorDef& reasonForInstantFailure) [0x0002b] in <3146e24e6706404284b4577f0ae30dcf>:0 
  at Gradual_Romance.AttractionUtility.CalculateAttraction (Verse.Pawn observer, Verse.Pawn assessed, System.Boolean attractionOnly, System.Boolean formalRelationship) [0x00001] in <3146e24e6706404284b4577f0ae30dcf>:0 
  at Gradual_Romance.Harmony.GRSecondaryLovinChanceFactorPatch.GRSecondaryLovinChanceFactor (RimWorld.Pawn_RelationsTracker __instance, System.Single& __result, Verse.Pawn& ___pawn, Verse.Pawn otherPawn) [0x00001] in <3146e24e6706404284b4577f0ae30dcf>:0 
  at (wrapper dynamic-method) RimWorld.Pawn_RelationsTracker.RimWorld.Pawn_RelationsTracker.SecondaryLovinChanceFactor_Patch2(RimWorld.Pawn_RelationsTracker,Verse.Pawn)
  at (wrapper dynamic-method) RimWorld.Pawn_RelationsTracker.RimWorld.Pawn_RelationsTracker.SecondaryRomanceChanceFactor_Patch1(RimWorld.Pawn_RelationsTracker,Verse.Pawn)
  at RimWorld.SocialCardUtility.GetPawnRowTooltip (RimWorld.SocialCardUtility+CachedSocialTabEntry entry, Verse.Pawn selPawnForSocialInfo) [0x0014c] in <95de19971c5d40878d8742747904cdcd>:0 
  at RimWorld.SocialCardUtility+<>c__DisplayClass50_0.<DrawPawnRow>b__0 () [0x00000] in <95de19971c5d40878d8742747904cdcd>:0 
  at (wrapper dynamic-method) Verse.ActiveTip.Verse.ActiveTip.get_FinalText_Patch0(Verse.ActiveTip)
UnityEngine.StackTraceUtility:ExtractStackTrace ()
(wrapper dynamic-method) Verse.Log:Verse.Log.Error_Patch0 (string)
(wrapper dynamic-method) Verse.ActiveTip:Verse.ActiveTip.get_FinalText_Patch0 (Verse.ActiveTip)
Verse.ActiveTip:get_TipRect ()
Verse.TooltipHandler:CalculateInitialTipPosition (System.Collections.Generic.List`1<Verse.ActiveTip>)
Verse.TooltipHandler:DrawActiveTips ()
(wrapper dynamic-method) Verse.TooltipHandler:Verse.TooltipHandler.DoTooltipGUI_Patch1 ()
(wrapper dynamic-method) Verse.UIRoot:Verse.UIRoot.UIRootOnGUI_Patch2 (Verse.UIRoot)
RimWorld.UIRoot_Play:UIRootOnGUI ()
(wrapper dynamic-method) Verse.Root:Verse.Root.OnGUI_Patch1 (Verse.Root)