protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; IntVec3 intVec; if (!RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal, false, null)) { Helper.Log($"Cant fire custom manhunter. No edge road chance entry cell"); return(false); } int count = ManhunterPackIncidentUtility.GetAnimalsCount(PawnKindDef, parms.points); ToolkitPatchLogger.Log(LOGGER_NAME, $"Spawning {count} beasts based {parms.points}"); for (int i = 0; i < count; i++) { var loc = CellFinder.RandomClosewalkCellNear(intVec, map, 12, null); var pawn = PawnGenerator.GeneratePawn(PawnKindDef, null); GenSpawn.Spawn(pawn, loc, map, Rot4.Random, WipeMode.Vanish, false); pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Manhunter); } var text = "CustomManhunterEnteringLabel".Translate(PawnKindDef.GetLabelPlural(-1)); Find.LetterStack.ReceiveLetter("CustomManhunterStoriesLetterLabel".Translate(), text, LetterDefOf.NegativeEvent, new TargetInfo(intVec, map, false), null, null); return(true); }
public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false) { this.separateChannel = separateChannel; this.Viewer = viewer; string[] command = message.Split(' '); if (command.Length < 3) { VariablesHelpers.ViewerDidWrongSyntax(viewer.username, storeIncident.syntax, separateChannel); return(false); } if (!VariablesHelpers.PointsWagerIsValid( command[2], viewer, ref pointsWager, ref storeIncident, separateChannel )) { ToolkitPatchLogger.Log(LOGGER_NAME, "Cannot fire custom manhunter. No valid points wagered"); return(false); } target = Current.Game.AnyPlayerHomeMap; if (target == null) { ToolkitPatchLogger.Log(LOGGER_NAME, "Cannot fire custom manhunter. No valid tile"); return(false); } parms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.RaidBeacon, target); parms.points = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, parms.points); IEnumerable <string> animals = Settings.AnimalMap.Where(x => x.Value).Select(x => x.Key); ToolkitPatchLogger.Log(LOGGER_NAME, $"{animals.Count()}/{Settings.AnimalMap.Count} animals for selection."); string animal = animals.RandomElement(); ToolkitPatchLogger.Log(LOGGER_NAME, $"Chose animal {animal} for the attack beast"); ThingDef def = ThingDef.Named(animal); worker = new CustomManhunterIncidentWorker(PawnKindDef.Named(animal)); worker.def = IncidentDef.Named("BeastAttack"); bool success = worker.CanFireNow(parms); if (!success) { WorkerCanFireCheck.CheckDefaultFireNowConditions(worker, parms, worker.def); } return(success); }
protected override bool CanFireNowSub(IncidentParms parms) { if (!base.CanFireNowSub(parms)) { ToolkitPatchLogger.Log(LOGGER_NAME, "Cannot fire custom manhunter from base fire now sub..."); return(false); } var map = (Map)parms.target; IntVec3 intVec; bool success = RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal, false, null); ToolkitPatchLogger.Log(LOGGER_NAME, $"Looking for edge chance animal cell: {success}"); return(success); }
public override bool IsPossible() { ToolkitPatchLogger.Log(incidentDef.defName, "Checking if possible.."); worker = Activator.CreateInstance <T>(); worker.def = incidentDef; parms = StorytellerUtility.DefaultParmsNow(category, 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); }
public override void ExposeData() { Scribe_Collections.Look(ref AnimalMap, "AnimalMap", LookMode.Value); if (AnimalMap != null) { ToolkitPatchLogger.Log("Mod", $"Loaded/Saved AnimalMap {AnimalMap.Count}"); } else { ToolkitPatchLogger.Log("Mod", $"Loaded/Saved AnimalMap null"); } if (AnimalMap == null || !AnimalMap.Any()) { AnimalMap = DefDatabase <ThingDef> .AllDefs.Where(x => x.race?.Animal ?? false).ToDictionary(x => x.defName, y => false); if (AnimalMap.ContainsKey("Thrumbo")) { AnimalMap["Thrumbo"] = true; } } }
public override void DoSettingsWindowContents(Rect inRect) { Listing_Standard listing = new Listing_Standard(); ToolkitPatchLogger.Log("Mod", $"SettingsLoading"); IEnumerable <ThingDef> AllAnimals = DefDatabase <ThingDef> .AllDefs.Where(x => x.race?.Animal ?? false).OrderByDescending(x => x.defName); Rect outRect = new Rect(0, 0, inRect.width, inRect.height - 50f); Rect viewRect = new Rect(0f, 0f, outRect.width - 20, AllAnimals.Count() * 31f); listing.Begin(inRect); listing.BeginScrollView(outRect, ref scrollPosition, ref viewRect); listing.Label("Assign animals to show up in the manhunter event"); listing.Gap(12); foreach (ThingDef animal in AllAnimals) { bool shouldUse = false; if (Settings.AnimalMap.ContainsKey(animal.defName)) { shouldUse = Settings.AnimalMap[animal.defName]; } listing.CheckboxLabeled($"{animal.defName}", ref shouldUse, animal.description); Settings.AnimalMap[animal.defName] = shouldUse; listing.Gap(6); } listing.EndScrollView(ref viewRect); listing.End(); base.DoSettingsWindowContents(inRect); }
public override void WriteSettings() { ToolkitPatchLogger.Log("Mod", "WriteSettings??"); base.WriteSettings(); }
public override void TryExecute() { bool success = worker.TryExecute(parms); ToolkitPatchLogger.Log(incidentDef.defName, $"Executed. Result: {success}"); }