Пример #1
0
 public static void Postfix(ThingOwner __instance, bool __result, Thing thing)
 {
     if (__result == true && thing is SurvivalTool tool && thing != null)
     {
         Pawn pawn = null;
         if (__instance.Owner is Pawn_EquipmentTracker eq)
         {
             pawn = eq.pawn;
         }
         if (__instance.Owner is Pawn_InventoryTracker inv)
         {
             pawn = inv.pawn;
         }
         if (pawn?.CanUseSurvivalTools() == true)
         {
             tool.Forced = false;
             tool.InUse  = false;
             Pawn_SurvivalToolAssignmentTracker tracker = pawn.TryGetComp <Pawn_SurvivalToolAssignmentTracker>();
             if (tracker != null)
             {
                 if (tracker.ToolsInUse?.Contains(tool) == true)
                 {
                     tracker.ToolsInUse.Remove(tool);
                 }
                 if (tracker.forcedHandler?.ForcedTools?.Contains(tool) == true)
                 {
                     tracker.forcedHandler.ForcedTools.Remove(tool);
                 }
             }
         }
     }
 }
Пример #2
0
 public static void Postfix(ThingOwner <Thing> __instance, bool __result, Thing item)
 {
     if (__result == true && item is SurvivalTool tool && item != null)
     {
         Pawn pawn = null;
         if (__instance.Owner is Pawn_EquipmentTracker eq)
         {
             pawn = eq.pawn;
         }
         if (__instance.Owner is Pawn_InventoryTracker inv)
         {
             pawn = inv.pawn;
         }
         if (pawn?.CanUseSurvivalTools() == true)
         {
             Pawn_SurvivalToolAssignmentTracker tracker = pawn.TryGetComp <Pawn_SurvivalToolAssignmentTracker>();
             if (pawn.CurJob?.playerForced == true && tool.toBeForced)
             {
                 tool.Forced = true;
             }
             if (tracker != null)
             {
                 if (tool.Forced)
                 {
                     tracker.forcedHandler.ForcedTools.AddDistinct(tool);
                 }
                 tool.CheckIfUsed(tracker, true);
             }
         }
     }
 }