public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            Log("Checking if possible..");
            this.separateChannel = separateChannel;
            this.Viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                Toolkit.client.SendMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}", separateChannel);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[2],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            Log($"Got the points wager of '{pointsWager}' and incident of '{storeIncident.abbreviation}:{storeIncident.defName}'");

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                return(false);
            }

            Log($"Target found '{target.Tile}'");

            parms        = StorytellerUtility.DefaultParmsNow(categoryDef, target);
            parms.points = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, parms.points);
            if (raidStratDef != null)
            {
                parms.raidStrategy = raidStratDef;
            }
            if (pawnArrivalModeDef != null)
            {
                parms.raidArrivalMode = pawnArrivalModeDef;
            }

            worker     = Activator.CreateInstance <T>();
            worker.def = incidentDef;

            bool success = worker.CanFireNow(parms);

            Log($"Can fire with params '{parms.ToString()}' on worker {worker.ToString()}? {success}");

            return(success);
        }
        static bool Prefix(IncidentWorker __instance, ref bool __result, IncidentParms parms)
        {
            if (PES_Settings.DebugModeOn)
            {
                Messages.Message("-=PS=- Caught Patch_IncidentWorker_TryExecute Prefix", MessageTypeDefOf.NeutralEvent, true);
                Log.Message("-=PS=- Patch_IncidentWorker_TryExecute Prefix", false);
                IncidentInterceptorUtility.DebugParms(parms, __instance.ToString());
            }
            if (parms.quest != null || parms.questScriptDef != null)
            {
                Log.Message("-=PS=- It's a quest! Bailout! MAYDAY!", false);
                return(true);
            }
            if (__instance.def == null)
            {
                Log.Error("-=PS=- __instance.def=NULL", false);
                Log.Error("   PS=- Returning true", false);
                return(true);
            }
            Log.Message("   PS=- __instance.def= " + __instance.def.ToString(), false);
            if (__instance.def.ToString() == "RRY_PowerCut_Xenomorph")              //Lt.Bob - Handling for AvP powercut event
            {
                Log.Message("-=PS=- AVP PowerCut event", false);
                Log.Message("   PS=- Returning true", false);
                return(true);
            }

            //TODO: This is for the ship part incident
            //I have no choice but do the patch like this
            //'cause the incidentworker for shippart is an internal class
            //and manual patching doesn't work
            var def = __instance.def;

            if (def != DefDatabase <IncidentDef> .GetNamed("PsychicEmanatorShipPartCrash") && def != DefDatabase <IncidentDef> .GetNamed("DefoliatorShipPartCrash"))            //Lt. Bob: 1.1 - Replaced PoisonShipPartCrash with DefoliatorShipPartCrash
            {
                return(true);
            }
            if (IncidentInterceptorUtility.IsIntercepting_ShipPart == WorkerPatchType.ExecuteOrigin)
            {
                return(true);
            }
            else
            {
                if (!IncidentInterceptorUtility.Intercept_SkyFaller <InterceptedIncident_SkyFaller_ShipPartCrash>(__instance.def, parms))
                {
                    return(true);
                }
                __result = true;
                return(false);
            }
        }
        public static bool Prefix(IncidentWorker __instance, ref bool __result, IncidentParms parms)
        {
            if (PES_Settings.DebugModeOn)
            {
                Log.Message("-=PS=- Patch_IncidentWorker_Alphabeavers_TryExecuteWorker Prefix", false);
                IncidentInterceptorUtility.DebugParms(parms, __instance.ToString());
            }

            if (IncidentInterceptorUtility.isIntercepting_Alphabeavers == WorkerPatchType.ExecuteOrigin)
            {
                return(true);
            }
            if (IncidentInterceptorUtility.isIntercepting_Alphabeavers == WorkerPatchType.Forestall)
            {
                IncidentInterceptorUtility.CreateIncidentCaravan_Animal <InterceptedIncident_AnimalHerd_Alphabeavers>(__instance.def, parms);
                __result = true;
            }
            else
            {
                __result = IncidentInterceptorUtility.tmpIncident.SubstituionWorkerExecution();
            }
            return(false);
        }
        public override bool IsPossible()
        {
            ToolkitPatchLogger.Log(incidentDef.defName, "Checking if possible..");
            worker     = GetWorker();
            worker.def = incidentDef;

            if (target != null)
            {
                parms        = StorytellerUtility.DefaultParmsNow(incidentCategoryDef, target);
                parms.forced = shouldForceFire;

                bool success = worker.CanFireNow(parms);
                if (!success)
                {
                    WorkerCanFireCheck.CheckDefaultFireNowConditions(worker, parms, incidentDef);
                }
                ToolkitPatchLogger.Log(incidentDef.defName, $"Can fire with params '{parms.ToString()}' on worker {worker.ToString()}? {success}");
                return(success);
            }

            ToolkitPatchLogger.ErrorLog(incidentDef.defName, $"Failed to get target. Cannot fire");
            return(false);
        }
示例#5
0
        public override bool IsPossible()
        {
            ToolkitPatchLogger.Log(incidentDef.defName, "Checking if possible..");
            worker     = GetWorker();
            worker.def = incidentDef;

            float points = StorytellerUtility.DefaultThreatPointsNow(target);

            parms        = StorytellerUtility.DefaultParmsNow(category, target);
            parms.forced = shouldForceFire;
            parms.points = points;

            bool success = worker.CanFireNow(parms);

            if (!success)
            {
                WorkerCanFireCheck.CheckDefaultFireNowConditions(worker, parms, incidentDef);
            }

            ToolkitPatchLogger.Log(incidentDef.defName, $"Can fire with params '{parms.ToString()}' on worker {worker.ToString()}? {success}");

            return(success);
        }