@@ -164,6 +164,43 @@ static void Prefix(ref Func<string> textGetter)
164164        } 
165165    } 
166166
167+     // Patch to remove endless (every tick!) condition duplicates from the condition causers 
168+     [ HarmonyPatch ( typeof ( CompCauseGameCondition ) ,  nameof ( CompCauseGameCondition . GetConditionInstance ) ) ] 
169+     public  static class  Patch_CompCauseGameCondition_GetConditionInstance 
170+     { 
171+         public  static void  Postfix ( Map  map ,  CompCauseGameCondition  __instance ,  ref  GameCondition  __result ) 
172+         { 
173+             // Sanity and MP checks. We only checking for conditions that are able to stack 
174+             if  ( Multiplayer . Client  ==  null 
175+                     ||  __instance . Props . preventConditionStacking 
176+                     ||  __result  !=  null 
177+                     ||  map  ==  null ) 
178+                 return ; 
179+ 
180+             // Look for an existing active condition on this map that matches both def and causer 
181+             var  active  =  map . GameConditionManager . ActiveConditions 
182+                 . FirstOrDefault ( c => 
183+                     c . def  ==  __instance . Props . conditionDef  && 
184+                     c . conditionCauser  ==  __instance . parent ) ; 
185+ 
186+             if  ( active  !=  null ) 
187+                 __result  =  active ; 
188+         } 
189+     } 
190+ 
191+     // This exists purely to fix load issues. Some fake ticks cause condition duplication on load. 
192+     [ HarmonyPatch ( typeof ( CompCauseGameCondition ) ,  nameof ( CompCauseGameCondition . CompTick ) ) ] 
193+     public  static class  Patch_CompCauseGameCondition_CompTick 
194+     { 
195+         public  static bool  Prefix ( ) 
196+         { 
197+             if  ( Multiplayer . Client  ==  null  ||  ! Multiplayer . GameComp . asyncTime ) 
198+                 return  true ;  // vanilla 
199+ 
200+             return  Multiplayer . LocalServer . FullyStarted ; 
201+         } 
202+     } 
203+ 
167204    [ HarmonyPatch ( typeof ( CompCauseGameCondition ) ,  nameof ( CompCauseGameCondition . EnforceConditionOn ) ) ] 
168205    static class  MapConditionCauserMapTime 
169206    { 
0 commit comments