public override bool IsPossible()
        {
            worker     = new IncidentWorker_HerdMigration();
            worker.def = IncidentDef.Named("HerdMigration");

            parms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.Misc, target);

            return(worker.CanFireNow(parms));
        }
示例#2
0
 static bool Prefix(IncidentWorker_HerdMigration __instance, ref bool __result, IncidentParms parms)
 {
     if (IncidentInterceptorUtility.isIntercepting_HerdMigration == WorkerPatchType.ExecuteOrigin)
     {
         return(true);
     }
     if (IncidentInterceptorUtility.isIntercepting_HerdMigration == WorkerPatchType.Forestall)
     {
         IncidentInterceptorUtility.CreateIncidentCaravan_Animal <InterceptedIncident_AnimalHerd_HerdMigration>(parms);
         __result = true;
     }
     else
     {
         __result = IncidentInterceptorUtility.tmpIncident.SubstituionWorkerExecution();
     }
     return(false);
 }
 public static bool TryFindStartAndEndCells(this IncidentWorker_HerdMigration hm, Map map, PawnKindDef kind, out IntVec3 start, out IntVec3 end)
 {
     if (!RCellFinderExtended.TryFindRandomPawnEntryCell(out start, map, kind, CellFinder.EdgeRoadChance_Animal))
     {
         end = IntVec3.Invalid;
         return(false);
     }
     end = IntVec3.Invalid;
     for (int i = 0; i < 8; i++)
     {
         IntVec3 startLocal = start;
         if (!CellFinderExtended.TryFindRandomEdgeCellWith((IntVec3 x) => map.reachability.CanReach(startLocal, x, PathEndMode.OnCell, TraverseMode.NoPassClosedDoors, Danger.Deadly), map, kind, CellFinder.EdgeRoadChance_Ignore, out IntVec3 result))
         {
             break;
         }
         if (!end.IsValid || result.DistanceToSquared(start) > end.DistanceToSquared(start))
         {
             end = result;
         }
     }
     return(end.IsValid);
 }
        static bool Prefix(IncidentWorker_HerdMigration __instance, ref bool __result, IncidentParms parms)
        {
            if (PES_Settings.DebugModeOn)
            {
                Log.Message("-=PS=- Patch_IncidentWorker_HerdMigration_TryExecuteWorker Prefix", false);
                IncidentInterceptorUtility.DebugParms(parms, __instance.ToString());
            }

            if (IncidentInterceptorUtility.isIntercepting_HerdMigration == WorkerPatchType.ExecuteOrigin)
            {
                return(true);
            }
            if (IncidentInterceptorUtility.isIntercepting_HerdMigration == WorkerPatchType.Forestall)
            {
                IncidentInterceptorUtility.CreateIncidentCaravan_Animal <InterceptedIncident_AnimalHerd_HerdMigration>(__instance.def, parms);
                __result = true;
            }
            else
            {
                __result = IncidentInterceptorUtility.tmpIncident.SubstituionWorkerExecution();
            }
            return(false);
        }