static IIncidentTarget GetDefaultTarget(IncidentDef d) { if (d.TargetAllowed(Find.CurrentMap)) { return(Find.CurrentMap); } if (d.TargetAllowed(Find.World)) { return(Find.World); } return(null); }
public bool CanFireNow(IncidentParms parms, bool forced = false) { if (!parms.forced) { if (!def.TargetAllowed(parms.target)) { return(false); } if (GenDate.DaysPassed < def.earliestDay) { return(false); } if (!Find.Storyteller.difficultyValues.AllowedBy(def.disabledWhen) || (def.category == IncidentCategoryDefOf.ThreatBig && !Find.Storyteller.difficultyValues.allowBigThreats)) { return(false); } if (parms.points >= 0f && parms.points < def.minThreatPoints) { return(false); } if (def.allowedBiomes != null) { BiomeDef biome = Find.WorldGrid[parms.target.Tile].biome; if (!def.allowedBiomes.Contains(biome)) { return(false); } } Scenario scenario = Find.Scenario; for (int i = 0; i < scenario.parts.Count; i++) { ScenPart_DisableIncident scenPart_DisableIncident = scenario.parts[i] as ScenPart_DisableIncident; if (scenPart_DisableIncident != null && scenPart_DisableIncident.Incident == def) { return(false); } } if (def.minPopulation > 0 && PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonists.Count() < def.minPopulation) { return(false); } if (FiredTooRecently(parms.target)) { return(false); } if (def.minGreatestPopulation > 0 && Find.StoryWatcher.statsRecord.greatestPopulation < def.minGreatestPopulation) { return(false); } } if (!CanFireNowSub(parms)) { return(false); } return(true); }
public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target) { if (this.IntervalsPassed == 840) { IncidentDef inc = IncidentDefOf.Quest_JourneyOffer; if (inc.TargetAllowed(target)) { FiringIncident fi = new FiringIncident(inc, this, this.GenerateParms(inc.category, target)); yield return(fi); } } }
public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target) { if (target != Find.Maps.Find((Map x) => x.IsPlayerHome)) { yield break; } if (IntervalsPassed == 150) { IncidentDef visitorGroup = IncidentDefOf.VisitorGroup; if (visitorGroup.TargetAllowed(target)) { FiringIncident firingIncident = new FiringIncident(visitorGroup, this); firingIncident.parms.target = target; firingIncident.parms.points = Rand.Range(40, 100); yield return(firingIncident); } } if (IntervalsPassed == 204) { IncidentCategoryDef threatCategory = (Find.Storyteller.difficultyValues.allowIntroThreats ? IncidentCategoryDefOf.ThreatSmall : IncidentCategoryDefOf.Misc); if (DefDatabase <IncidentDef> .AllDefs.Where((IncidentDef def) => def.TargetAllowed(target) && def.category == threatCategory).TryRandomElementByWeight(base.IncidentChanceFinal, out var result)) { FiringIncident firingIncident2 = new FiringIncident(result, this); firingIncident2.parms = StorytellerUtility.DefaultParmsNow(result.category, target); yield return(firingIncident2); } } if (IntervalsPassed == 264 && DefDatabase <IncidentDef> .AllDefs.Where((IncidentDef def) => def.TargetAllowed(target) && def.category == IncidentCategoryDefOf.Misc).TryRandomElementByWeight(base.IncidentChanceFinal, out var result2)) { FiringIncident firingIncident3 = new FiringIncident(result2, this); firingIncident3.parms = StorytellerUtility.DefaultParmsNow(result2.category, target); yield return(firingIncident3); } if (IntervalsPassed != 324) { yield break; } IncidentDef incidentDef = IncidentDefOf.RaidEnemy; if (!Find.Storyteller.difficultyValues.allowIntroThreats) { incidentDef = DefDatabase <IncidentDef> .AllDefs.Where((IncidentDef def) => def.TargetAllowed(target) && def.category == IncidentCategoryDefOf.Misc).RandomElementByWeightWithFallback(base.IncidentChanceFinal); } if (incidentDef != null && incidentDef.TargetAllowed(target)) { FiringIncident firingIncident4 = new FiringIncident(incidentDef, this); firingIncident4.parms = GenerateParms(incidentDef.category, target); firingIncident4.parms.points = 40f; firingIncident4.parms.raidForceOneIncap = true; firingIncident4.parms.raidNeverFleeIndividual = true; yield return(firingIncident4); } }
public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target) { if (IntervalsPassed == 840) { IncidentDef inc = IncidentDefOf.Quest_JourneyOffer; if (inc.TargetAllowed(target)) { FiringIncident fi = new FiringIncident(inc, this, GenerateParms(inc.category, target)); yield return(fi); /*Error: Unable to find new state assignment for yield return*/; } } }
public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target) { int num = IntervalsPassed; if (Props.minColonistCount > 0) { if (target.StoryState.lastFireTicks.ContainsKey(Props.incident) || PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonists.Count < Props.minColonistCount) { yield break; } num -= target.StoryState.GetTicksFromColonistCount(Props.minColonistCount) / 1000; } if (num != Props.fireAfterDaysPassed * 60) { yield break; } if (Props.skipIfColonistHasMinTitle != null) { List <Pawn> allMapsCaravansAndTravelingTransportPods_Alive_FreeColonists = PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonists; for (int i = 0; i < allMapsCaravansAndTravelingTransportPods_Alive_FreeColonists.Count; i++) { if (allMapsCaravansAndTravelingTransportPods_Alive_FreeColonists[i].royalty != null && allMapsCaravansAndTravelingTransportPods_Alive_FreeColonists[i].royalty.AllTitlesForReading.Any() && allMapsCaravansAndTravelingTransportPods_Alive_FreeColonists[i].royalty.MainTitle().seniority >= Props.skipIfColonistHasMinTitle.seniority) { yield break; } } } Map anyPlayerHomeMap = Find.AnyPlayerHomeMap; if (!Props.skipIfOnExtremeBiome || (anyPlayerHomeMap != null && !anyPlayerHomeMap.Biome.isExtremeBiome)) { IncidentDef incident = Props.incident; if (incident.TargetAllowed(target)) { yield return(new FiringIncident(incident, this, GenerateParms(incident.category, target))); } } }
public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target) { _003CMakeIntervalIncidents_003Ec__Iterator0 _003CMakeIntervalIncidents_003Ec__Iterator = (_003CMakeIntervalIncidents_003Ec__Iterator0) /*Error near IL_003e: stateMachine*/; if (target == Find.Maps.Find((Map x) => x.IsPlayerHome)) { if (this.IntervalsPassed == 150) { IncidentDef inc2 = IncidentDefOf.VisitorGroup; if (inc2.TargetAllowed(target)) { yield return(new FiringIncident(inc2, this, null) { parms = { target = target, points = (float)Rand.Range(40, 100) } }); /*Error: Unable to find new state assignment for yield return*/; } } if (this.IntervalsPassed == 204) { _003CMakeIntervalIncidents_003Ec__Iterator0 _003CMakeIntervalIncidents_003Ec__Iterator2 = (_003CMakeIntervalIncidents_003Ec__Iterator0) /*Error near IL_015f: stateMachine*/; IncidentCategory threatCategory = (IncidentCategory)((!Find.Storyteller.difficulty.allowIntroThreats) ? 1 : 2); IncidentDef incDef2; if ((from def in DefDatabase <IncidentDef> .AllDefs where def.TargetAllowed(target) && def.category == threatCategory select def).TryRandomElementByWeight <IncidentDef>((Func <IncidentDef, float>)base.IncidentChanceFinal, out incDef2)) { yield return(new FiringIncident(incDef2, this, null) { parms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, incDef2.category, target) }); /*Error: Unable to find new state assignment for yield return*/; } } IncidentDef incDef; if (this.IntervalsPassed == 264 && (from def in DefDatabase <IncidentDef> .AllDefs where def.TargetAllowed(target) && def.category == IncidentCategory.Misc select def).TryRandomElementByWeight <IncidentDef>((Func <IncidentDef, float>)base.IncidentChanceFinal, out incDef)) { yield return(new FiringIncident(incDef, this, null) { parms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, incDef.category, target) }); /*Error: Unable to find new state assignment for yield return*/; } if (this.IntervalsPassed != 324) { yield break; } IncidentDef inc = IncidentDefOf.RaidEnemy; if (!Find.Storyteller.difficulty.allowIntroThreats) { inc = (from def in DefDatabase <IncidentDef> .AllDefs where def.TargetAllowed(target) && def.category == IncidentCategory.Misc select def).RandomElementByWeightWithFallback(base.IncidentChanceFinal, null); } if (inc == null) { yield break; } if (!inc.TargetAllowed(target)) { yield break; } yield return(new FiringIncident(inc, this, null) { parms = this.GenerateParms(inc.category, target) }); /*Error: Unable to find new state assignment for yield return*/; } }
public override IEnumerable<FiringIncident> MakeIntervalIncidents(IIncidentTarget target) { _003CMakeIntervalIncidents_003Ec__Iterator0 _003CMakeIntervalIncidents_003Ec__Iterator = (_003CMakeIntervalIncidents_003Ec__Iterator0)/*Error near IL_003e: stateMachine*/; if (target == Find.Maps.Find((Map x) => x.IsPlayerHome)) { if (IntervalsPassed == 150) { IncidentDef inc2 = IncidentDefOf.VisitorGroup; if (inc2.TargetAllowed(target)) { yield return new FiringIncident(inc2, this) { parms = { target = target, points = (float)Rand.Range(40, 100) } }; /*Error: Unable to find new state assignment for yield return*/; } } if (IntervalsPassed == 204) { _003CMakeIntervalIncidents_003Ec__Iterator0 _003CMakeIntervalIncidents_003Ec__Iterator2 = (_003CMakeIntervalIncidents_003Ec__Iterator0)/*Error near IL_015f: stateMachine*/; IncidentCategoryDef threatCategory = (!Find.Storyteller.difficulty.allowIntroThreats) ? IncidentCategoryDefOf.Misc : IncidentCategoryDefOf.ThreatSmall; if ((from def in DefDatabase<IncidentDef>.AllDefs where def.TargetAllowed(target) && def.category == threatCategory select def).TryRandomElementByWeight(base.IncidentChanceFinal, out IncidentDef incDef2)) { yield return new FiringIncident(incDef2, this) { parms = StorytellerUtility.DefaultParmsNow(incDef2.category, target) }; /*Error: Unable to find new state assignment for yield return*/; } } if (IntervalsPassed == 264 && (from def in DefDatabase<IncidentDef>.AllDefs where def.TargetAllowed(target) && def.category == IncidentCategoryDefOf.Misc select def).TryRandomElementByWeight(base.IncidentChanceFinal, out IncidentDef incDef)) { yield return new FiringIncident(incDef, this) { parms = StorytellerUtility.DefaultParmsNow(incDef.category, target) }; /*Error: Unable to find new state assignment for yield return*/; } if (IntervalsPassed == 324) { IncidentDef inc = IncidentDefOf.RaidEnemy; if (!Find.Storyteller.difficulty.allowIntroThreats) { inc = (from def in DefDatabase<IncidentDef>.AllDefs where def.TargetAllowed(target) && def.category == IncidentCategoryDefOf.Misc select def).RandomElementByWeightWithFallback(base.IncidentChanceFinal); } if (inc != null && inc.TargetAllowed(target)) { FiringIncident fi = new FiringIncident(inc, this); fi.parms = GenerateParms(inc.category, target); fi.parms.points = 40f; fi.parms.raidForceOneIncap = true; fi.parms.raidNeverFleeIndividual = true; yield return fi; /*Error: Unable to find new state assignment for yield return*/; } } } }
public bool CanFireNow(IncidentParms parms, bool forced = false) { if (!parms.forced) { if (!def.TargetAllowed(parms.target)) { return(false); } if (GenDate.DaysPassed < def.earliestDay) { return(false); } if (Find.Storyteller.difficulty.difficulty < def.minDifficulty) { return(false); } if (def.allowedBiomes != null) { BiomeDef biome = Find.WorldGrid[parms.target.Tile].biome; if (!def.allowedBiomes.Contains(biome)) { return(false); } } Scenario scenario = Find.Scenario; for (int i = 0; i < scenario.parts.Count; i++) { ScenPart_DisableIncident scenPart_DisableIncident = scenario.parts[i] as ScenPart_DisableIncident; if (scenPart_DisableIncident != null && scenPart_DisableIncident.Incident == def) { return(false); } } if (def.minPopulation > 0 && PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonists.Count() < def.minPopulation) { return(false); } Dictionary <IncidentDef, int> lastFireTicks = parms.target.StoryState.lastFireTicks; int ticksGame = Find.TickManager.TicksGame; if (lastFireTicks.TryGetValue(def, out int value)) { float num = (float)(ticksGame - value) / 60000f; if (num < def.minRefireDays) { return(false); } } List <IncidentDef> refireCheckIncidents = def.RefireCheckIncidents; if (refireCheckIncidents != null) { for (int j = 0; j < refireCheckIncidents.Count; j++) { if (lastFireTicks.TryGetValue(refireCheckIncidents[j], out value)) { float num2 = (float)(ticksGame - value) / 60000f; if (num2 < def.minRefireDays) { return(false); } } } } if (def.minGreatestPopulation > 0 && Find.StoryWatcher.statsRecord.greatestPopulation < def.minGreatestPopulation) { return(false); } } if (!CanFireNowSub(parms)) { return(false); } return(true); }
public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target) { if (target == Find.Maps.Find((Map x) => x.IsPlayerHome)) { if (this.IntervalsPassed == 150) { IncidentDef inc = IncidentDefOf.VisitorGroup; if (inc.TargetAllowed(target)) { yield return(new FiringIncident(inc, this, null) { parms = { target = target, points = (float)Rand.Range(40, 100) } }); } } if (this.IntervalsPassed == 204) { IncidentCategory threatCategory = (!Find.Storyteller.difficulty.allowIntroThreats) ? IncidentCategory.Misc : IncidentCategory.ThreatSmall; IncidentDef incDef; if ((from def in DefDatabase <IncidentDef> .AllDefs where def.TargetAllowed(target) && def.category == threatCategory select def).TryRandomElementByWeight(new Func <IncidentDef, float>(base.IncidentChanceFinal), out incDef)) { yield return(new FiringIncident(incDef, this, null) { parms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, incDef.category, target) }); } } IncidentDef incDef2; if (this.IntervalsPassed == 264 && (from def in DefDatabase <IncidentDef> .AllDefs where def.TargetAllowed(target) && def.category == IncidentCategory.Misc select def).TryRandomElementByWeight(new Func <IncidentDef, float>(base.IncidentChanceFinal), out incDef2)) { yield return(new FiringIncident(incDef2, this, null) { parms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, incDef2.category, target) }); } if (this.IntervalsPassed == 324) { IncidentDef inc2 = IncidentDefOf.RaidEnemy; if (!Find.Storyteller.difficulty.allowIntroThreats) { inc2 = (from def in DefDatabase <IncidentDef> .AllDefs where def.TargetAllowed(target) && def.category == IncidentCategory.Misc select def).RandomElementByWeightWithFallback(new Func <IncidentDef, float>(base.IncidentChanceFinal), null); } if (inc2 != null && inc2.TargetAllowed(target)) { yield return(new FiringIncident(inc2, this, null) { parms = this.GenerateParms(inc2.category, target) }); } } } }