private static void DoIncidentDebugAction(Dialog_DebugActionsMenu menu, IIncidentTarget target) { menu.DebugAction($"Incident on {target}", () => { var list = new List <DebugMenuOption>(); foreach (var localDef2 in DefDatabase <IncidentDef> .AllDefs.Where(d => d.TargetAllowed(target)).OrderBy(d => d.defName)) { IncidentDef localDef = localDef2; string text = localDef.defName; IncidentParms parms = StorytellerUtility.DefaultParmsNow(localDef.category, target); if (!localDef.Worker.CanFireNow(parms, false)) { text += " [NO]"; } list.Add(new DebugMenuOption(text, DebugMenuOptionMode.Action, () => { if (localDef.pointsScaleable) { StorytellerComp storytellerComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain); parms = storytellerComp.GenerateParms(localDef.category, parms.target); } ExecuteIncident(localDef, parms, target as Map); })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }); }
public static bool DoExecuteIncidentDebugAction_PreFix(Dialog_DebugActionsMenu __instance, IIncidentTarget target, IIncidentTarget altTarget) { //Log.Message("1"); if (Find.Storyteller?.storytellerComps?.FirstOrDefault(x => x is StorytellerComp_OmenThreatCycle) != null) { //Log.Message("2"); AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DebugAction").Invoke(__instance, new object[] { "Execute incident...", new Action(delegate { //Log.Message("3"); List <DebugMenuOption> list = new List <DebugMenuOption>(); foreach (IncidentDef current in from d in DefDatabase <IncidentDef> .AllDefs where d.TargetAllowed(target) || (altTarget != null && d.TargetAllowed(altTarget)) orderby !d.TargetAllowed(target), d.defName select d) { IIncidentTarget arg_98_1; if (current.TargetAllowed(target)) { IIncidentTarget target2 = target; arg_98_1 = target2; } else { arg_98_1 = altTarget; } var thisIncidentTarget = arg_98_1; string text = current.defName; if (!current.Worker.CanFireNow(thisIncidentTarget)) { text += " [NO]"; } if (thisIncidentTarget == altTarget) { text = text + " (" + altTarget.GetType().Name.Truncate(52f, null) + ")"; } list.Add(new DebugMenuOption(text, DebugMenuOptionMode.Action, delegate { IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, current.category, thisIncidentTarget); if (current.pointsScaleable) { StorytellerComp storytellerComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) => x is StorytellerComp_ThreatCycle || x is StorytellerComp_RandomMain || x is StorytellerComp_OmenThreatCycle); incidentParms = storytellerComp.GenerateParms(current.category, incidentParms.target); } current.Worker.TryExecute(incidentParms); })); } ; Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }) }); return(false); } return(true); }
private static void ExecuteRaidWithFaction() { StorytellerComp storytellerComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain); IncidentParms parms = storytellerComp.GenerateParms(IncidentCategoryDefOf.ThreatBig, Find.CurrentMap); List <DebugMenuOption> list = new List <DebugMenuOption>(); foreach (Faction localFac2 in Find.FactionManager.AllFactions) { Faction localFac = localFac2; list.Add(new DebugMenuOption(localFac.Name + " (" + localFac.def.defName + ")", DebugMenuOptionMode.Action, delegate() { parms.faction = localFac; List <DebugMenuOption> list2 = new List <DebugMenuOption>(); foreach (float num in DebugActionsUtility.PointsOptions(true)) { float localPoints = num; list2.Add(new DebugMenuOption(num + " points", DebugMenuOptionMode.Action, delegate() { parms.points = localPoints; IEnumerable <RaidStrategyDef> allDefs = DefDatabase <RaidStrategyDef> .AllDefs; Func <RaidStrategyDef, bool> predicate = ((RaidStrategyDef s) => s.Worker.CanUseWith(parms, PawnGroupKindDefOf.Combat)); List <RaidStrategyDef> source = allDefs.Where(predicate).ToList(); Log.Message("Available strategies: " + string.Join(", ", (from s in source select s.defName).ToArray <string>())); parms.raidStrategy = VehicleRaidStrategyDefOf.ArmoredAttack; if (parms.raidStrategy != null) { Log.Message("Strategy: " + parms.raidStrategy.defName); IEnumerable <PawnsArrivalModeDef> allDefs2 = DefDatabase <PawnsArrivalModeDef> .AllDefs; parms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn; //source2.RandomElement<PawnsArrivalModeDef>(); Log.Message("Arrival mode: " + parms.raidArrivalMode.defName); } IncidentDef incidentDef; if (parms.faction.HostileTo(Faction.OfPlayer)) { incidentDef = IncidentDefOf.RaidEnemy; } else { incidentDef = IncidentDefOf.RaidFriendly; } incidentDef.Worker.TryExecute(parms); })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list2)); })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }
public void DoEmpIncident(Thing thing) { if (operableNextTick < Find.TickManager.TicksGame) { operableNextTick = Find.TickManager.TicksGame + 60000; Find.LetterStack.ReceiveLetter("EMPExplode".Translate(), "EMPExplodeDesc".Translate(), LetterDefOf.ThreatBig); StorytellerComp storytellerComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain); IncidentParms parms = storytellerComp.GenerateParms(IncidentCategoryDefOf.ThreatBig, Find.CurrentMap); parms.faction = Find.FactionManager.FirstFactionOfDef(RatkinFactionDefOf.Rakinia); parms.points *= 0.4f; parms.raidStrategy = DefDatabase <RaidStrategyDef> .GetNamed("ImmediateAttackSappers"); parms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn; RatkinIncidentDefOf.RatkinFollowUpTroops.Worker.TryExecute(parms); GenExplosion.DoExplosion(thing.Position, thing.Map, 15, RatkinDamageDefOf.RK_EMP, thing); } }
public void Execute() { if (incident.TargetAllowed(target)) { // This is basically taken from Dialog_DebugActionMenu (debug menu source) IncidentParms parms = StorytellerUtility.DefaultParmsNow(incident.category, target); if (incident.pointsScaleable) { StorytellerComp stComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain); parms = stComp.GenerateParms(incident.category, parms.target); } incident.Worker.TryExecute(parms); } else { Utils.LogDebugWarning($"Event target was invalid"); } }
protected override void OpenBox(Pawn usedBy) { Map map = usedBy.Map; Rand.PushState(parent.HashOffset()); bool hostileActivity = GenHostility.AnyHostileActiveThreatToPlayer(map); KeyValuePair <List <IncidentCategoryDef>, IncidentGroupData> selectedGroup = incidentGroups.RandomElementByWeight(kvp => kvp.Value.chance); while (hostileActivity && selectedGroup.Key.Contains(IncidentCategoryDefOf.FactionArrival)) { selectedGroup = incidentGroups.RandomElementByWeight(kvp => kvp.Value.chance); } int count = Rand.RangeInclusive(selectedGroup.Value.countMin, Rand.RangeInclusive(selectedGroup.Value.countStep, selectedGroup.Value.countMax)); for (int i = 0; i < count; i++) { List <IncidentDef> validIncidents = new List <IncidentDef>(); foreach (IncidentDef incident in from def in DefDatabase <IncidentDef> .AllDefs where selectedGroup.Key.Contains(def.category) && def.TargetAllowed(map) select def) { IncidentParms parms = StorytellerUtility.DefaultParmsNow(incident.category, map); if (incident.Worker.CanFireNow(parms, false)) { validIncidents.Add(incident); } } IncidentDef selectedIncident = validIncidents.RandomElementByWeight(new Func <IncidentDef, float>(IncidentChanceFinal)); if (selectedIncident != null) { IncidentParms parms = StorytellerUtility.DefaultParmsNow(selectedIncident.category, map); if (selectedIncident.pointsScaleable) { StorytellerComp storytellerComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain); if (storytellerComp != null) { parms = storytellerComp.GenerateParms(selectedIncident.category, parms.target); } } selectedIncident.Worker.TryExecute(parms); } } Rand.PopState(); }
private static void ExecuteRaidWithFaction() { StorytellerComp storytellerComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain); IncidentParms parms = storytellerComp.GenerateParms(IncidentCategoryDefOf.ThreatBig, Find.CurrentMap); List <DebugMenuOption> list = new List <DebugMenuOption>(); foreach (Faction allFaction in Find.FactionManager.AllFactions) { Faction localFac = allFaction; list.Add(new DebugMenuOption(localFac.Name + " (" + localFac.def.defName + ")", DebugMenuOptionMode.Action, delegate { parms.faction = localFac; List <DebugMenuOption> list2 = new List <DebugMenuOption>(); float localPoints = default(float); foreach (float item in DebugActionsUtility.PointsOptions(extended: true)) { localPoints = item; list2.Add(new DebugMenuOption(item + " points", DebugMenuOptionMode.Action, delegate { parms.points = localPoints; List <RaidStrategyDef> source = DefDatabase <RaidStrategyDef> .AllDefs.Where((RaidStrategyDef s) => s.Worker.CanUseWith(parms, PawnGroupKindDefOf.Combat)).ToList(); Log.Message("Available strategies: " + string.Join(", ", source.Select((RaidStrategyDef s) => s.defName).ToArray())); parms.raidStrategy = source.RandomElement(); if (parms.raidStrategy != null) { Log.Message("Strategy: " + parms.raidStrategy.defName); List <PawnsArrivalModeDef> source2 = DefDatabase <PawnsArrivalModeDef> .AllDefs.Where((PawnsArrivalModeDef a) => a.Worker.CanUseWith(parms) && parms.raidStrategy.arriveModes.Contains(a)).ToList(); Log.Message("Available arrival modes: " + string.Join(", ", source2.Select((PawnsArrivalModeDef s) => s.defName).ToArray())); parms.raidArrivalMode = source2.RandomElement(); Log.Message("Arrival mode: " + parms.raidArrivalMode.defName); } DoRaid(parms); })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list2)); })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }
public override void DoWindowContents(Rect inRect) { var num = inRect.y; //if (!this.title.NullOrEmpty()) //{ Verse.Text.Font = GameFont.Medium; Widgets.Label(new Rect(0f, num, inRect.width, TitleHeight), title); num += TitleHeight; //} Verse.Text.Font = GameFont.Small; var outRect = new Rect(inRect.x, num, inRect.width, inRect.height - ButtonHeight - 5f - num); var width = outRect.width - 16f; var viewRect = new Rect(0f, 0f, width, CalcHeight(width) + CalcOptionsHeight(width)); Widgets.BeginScrollView(outRect, ref scrollPosition, viewRect, true); Widgets.Label(new Rect(0f, 0f, viewRect.width, viewRect.height - CalcOptionsHeight(width)), Text.AdjustedFor(questPawn.pawn)); if (questPawn.questsAndIncidents.Count == 0) { questPawn.GenerateQuestsAndIncidents(); } for (var index = 0; index < questPawn.questsAndIncidents.Count; index++) { string defname; string keyedName; object questDef = null; var questName = string.Empty; if (questPawn.questsAndIncidents[index] is QuestScriptDef questScriptDef) { defname = questScriptDef.defName; keyedName = "RimQuest_" + defname; if ((!Prefs.DevMode && keyedName.Translate() == keyedName) || (Prefs.DevMode && keyedName.Translate().ToString().Contains("RìṁQùèșṭ_"))) { if (defname.Contains("_")) { defname = questScriptDef.defName.Split('_')[1]; } if (questScriptDef.defName.Contains("Hospitality")) { defname = questScriptDef.defName.Replace("_", " "); } questName = Regex.Replace(defname, "(\\B[A-Z])", " $1"); } else { questName = keyedName.Translate(); } questDef = questScriptDef; } if (questPawn.questsAndIncidents[index] is IncidentDef incidentDef) { defname = incidentDef.defName; questName = incidentDef.LabelCap; questDef = incidentDef; } if (string.IsNullOrEmpty(questName)) { continue; } var rect6 = new Rect(24f, viewRect.height - CalcOptionsHeight(width) + ((Verse.Text.CalcHeight(questName, width) + 12f) * index) + 8f, viewRect.width / 2f, Verse.Text.CalcHeight(questName, width)); if (Mouse.IsOver(rect6)) { Widgets.DrawHighlight(rect6); } if (Widgets.RadioButtonLabeled(rect6, questName, selectedQuest == questDef)) { selectedQuest = questDef; } } Widgets.EndScrollView(); if (Widgets.ButtonText(new Rect(0f, inRect.height - ButtonHeight, (inRect.width / 2f) - 20f, ButtonHeight), "CancelButton".Translate(), true, false, true)) { Close(true); } if (actualPlayerSilver >= actualSilverCost) { if (selectedQuest != null && Widgets.ButtonText( new Rect((inRect.width / 2f) + 20f, inRect.height - ButtonHeight, (inRect.width / 2f) - 20f, ButtonHeight), "Confirm".Translate() + " (" + "RQ_SilverAmt".Translate(actualSilverCost) + ")", true, false, true)) { if (selectedQuest is QuestScriptDef questDef) { var incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.GiveQuest, Find.World); var storytellerComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain); incidentParms = storytellerComp.GenerateParms(IncidentCategoryDefOf.GiveQuest, incidentParms.target); QuestUtility.SendLetterQuestAvailable(QuestUtility.GenerateQuestAndMakeAvailable(questDef, incidentParms.points)); } if (selectedQuest is IncidentDef incidentDef) { IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(incidentDef.category, Find.World); if (incidentDef.pointsScaleable) { StorytellerComp storytellerComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain); incidentParms = storytellerComp.GenerateParms(incidentDef.category, incidentParms.target); } incidentDef.Worker.TryExecute(incidentParms); } var questPawns = Find.World.GetComponent <RimQuestTracker>().questPawns; if (questPawns != null && questPawns.Contains(questPawn)) { questPawns.Remove(questPawn); } SoundDefOf.ExecuteTrade.PlayOneShotOnCamera(null); ReceiveSilver(questPawn.pawn, actualSilverCost); Close(true); Find.WindowStack.Add(new Dialog_MessageBox( "RQ_QuestDialogTwo".Translate(questPawn.pawn.LabelShort, interactor.LabelShort) .AdjustedFor(questPawn.pawn), "OK".Translate(), null, null, null, title)); } } else { if (Widgets.ButtonText( new Rect((inRect.width / 2f) + 20f, inRect.height - ButtonHeight, (inRect.width / 2f) - 20f, ButtonHeight), "RQ_LackFunds".Translate(), true, false, true)) { SoundDefOf.ClickReject.PlayOneShotOnCamera(null); Messages.Message("RQ_LackFundsMessage".Translate(), MessageTypeDefOf.RejectInput); } } }
public override void Tick() { base.Tick(); if (Downed) { if (lastTakenDamageFrom is Pawn killer && killer.RaceProps.Humanlike && killer.story.traits.HasTrait(RWBYDefOf.Semblance_Weiss) && killer.TryGetComp <CompAbilityUserAura>() is CompAbilityUserAura compAbilityUserAura && compAbilityUserAura.IsInitialized) { if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Boarbatusk) { if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonBoar)) { compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonBoar); } } else if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Beowolf) { if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonBeowolf)) { compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonBeowolf); } } else if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Ursa) { if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonUrsa)) { compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonUrsa); } } else if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Griffon) { if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonGriffon)) { compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonGriffon); } } else if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Nevermore) { if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonNevermore)) { compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonNevermore); } } else if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Lancer) { if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonLancer)) { compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonLancer); } } else if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_LancerQueen) { if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonLancerQueen)) { compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonLancerQueen); } } else if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_DeathStalker) { if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonDeathStalker)) { compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonDeathStalker); } } else if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Nuckelavee) { if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonNuckelavee)) { compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonNuckelavee); } } else if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Apathy) { if (!compAbilityUserAura.AbilityData.AllPowers.Any(p => p.Def == RWBYDefOf.Weiss_SummonApathy)) { compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonApathy); } } } Kill(null); } attractGrimmTimer--; nuckelaveeTimer--; if (this.Map != null && this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Nuckelavee && nuckelaveeTimer > 0 && nuckelaveeTimer % 2500 == 0 && !this.InMentalState) // Nuckelavee spawn more Grimm { Pawn pawn = PawnGenerator.GeneratePawn(GrimmUtility.GetRandomGrimmBalanced(), FactionUtility.DefaultFactionFrom(RWBYDefOf.Creatures_of_Grimm)); IntVec3 loc = CellFinder.RandomClosewalkCellNear(this.Position, this.Map, 8, null); if (pawn is Pawn_Grimm pawn_Grimm) { pawn_Grimm.SetNuckelaveeTimer(nuckelaveeTimer); } GenSpawn.Spawn(pawn, loc, this.Map, this.Rotation, WipeMode.Vanish, false); } if (this.Map != null && this.IsHashIntervalTick(30000) && this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Apathy && !this.InMentalState && this.Map.mapPawns.AllPawnsSpawned.FindAll(p => p.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Apathy).Count() < this.Map.mapPawns.ColonistCount * 10) // Apathy spawn more Apathy { Pawn pawn = PawnGenerator.GeneratePawn(RWBYDefOf.Grimm_Apathy, FactionUtility.DefaultFactionFrom(RWBYDefOf.Creatures_of_Grimm)); IntVec3 loc = CellFinder.RandomClosewalkCellNear(this.Position, this.Map, 8, null); if (pawn is Pawn_Grimm pawn_Grimm) { pawn_Grimm.SetNuckelaveeTimer(nuckelaveeTimer); } GenSpawn.Spawn(pawn, loc, this.Map, this.Rotation, WipeMode.Vanish, false); } if (nuckelaveeTimer == 0) { if (this.RaceProps.AnyPawnKind == RWBYDefOf.Grimm_Nuckelavee && !this.InMentalState) { Messages.Message("MessageTextNuckelaveeTriggered".Translate().CapitalizeFirst(), this, MessageTypeDefOf.NegativeEvent); } TriggerAggro(); } if (attractGrimmTimer == 0) { IncidentDef localDef = IncidentDefOf.RaidEnemy; IncidentParms parms = StorytellerUtility.DefaultParmsNow(localDef.category, Map); StorytellerComp storytellerComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain); parms = storytellerComp.GenerateParms(localDef.category, parms.target); parms.faction = FactionUtility.DefaultFactionFrom(RWBYDefOf.Creatures_of_Grimm); parms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; localDef.Worker.TryExecute(parms); TriggerAggro(); } }
public override void DoWindowContents(Rect inRect) { float num = inRect.y; //if (!this.title.NullOrEmpty()) //{ Text.Font = GameFont.Medium; Widgets.Label(new Rect(0f, num, inRect.width, 42f), this.title); num += 42f; //} Text.Font = GameFont.Small; Rect outRect = new Rect(inRect.x, num, inRect.width, inRect.height - 35f - 5f - num); float width = outRect.width - 16f; Rect viewRect = new Rect(0f, 0f, width, CalcHeight(width) + CalcOptionsHeight(width)); Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect, true); Widgets.Label(new Rect(0f, 0f, viewRect.width, viewRect.height - CalcOptionsHeight(width)), this.text.AdjustedFor(questPawn.pawn)); for (var index = 0; index < questPawn.quests.Count; index++) { IncidentDef incidentDef = questPawn.quests[index]; Rect rect6 = new Rect(24f, (viewRect.height - CalcOptionsHeight(width)) + (Text.CalcHeight(incidentDef.LabelCap, width) + 12f) * index + 8f, viewRect.width / 2f, Text.CalcHeight(incidentDef.LabelCap, width)); if (Mouse.IsOver(rect6)) { Widgets.DrawHighlight(rect6); } ; if (Widgets.RadioButtonLabeled(rect6, incidentDef.LabelCap, selectedIncident == incidentDef)) { selectedIncident = incidentDef; } } Widgets.EndScrollView(); if (Widgets.ButtonText(new Rect(0f, inRect.height - 35f, inRect.width / 2f - 20f, 35f), "CancelButton".Translate(), true, false, true)) { this.Close(true); } if (actualPlayerSilver >= actualSilverCost) { if (selectedIncident != null && Widgets.ButtonText( new Rect(inRect.width / 2f + 20f, inRect.height - 35f, inRect.width / 2f - 20f, 35f), "Confirm".Translate() + " (" + "RQ_SilverAmt".Translate(actualSilverCost) + ")", true, false, true)) { IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(selectedIncident.category, Find.World); if (selectedIncident.pointsScaleable) { StorytellerComp storytellerComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain); incidentParms = storytellerComp.GenerateParms(selectedIncident.category, incidentParms.target); } selectedIncident.Worker.TryExecute(incidentParms); var questPawns = Find.World.GetComponent <RimQuestTracker>().questPawns; if (questPawns != null && questPawns.Contains(questPawn)) { questPawns.Remove(questPawn); } SoundDefOf.ExecuteTrade.PlayOneShotOnCamera(null); ReceiveSilver(questPawn.pawn, actualSilverCost); this.Close(true); Find.WindowStack.Add(new Dialog_MessageBox( "RQ_QuestDialogTwo".Translate(questPawn.pawn.LabelShort, interactor.LabelShort) .AdjustedFor(questPawn.pawn), "OK".Translate(), null, null, null, title)); } } else { if (Widgets.ButtonText( new Rect(inRect.width / 2f + 20f, inRect.height - 35f, inRect.width / 2f - 20f, 35f), "RQ_LackFunds".Translate(), true, false, true)) { SoundDefOf.ClickReject.PlayOneShotOnCamera(null); Messages.Message("RQ_LackFundsMessage".Translate(), MessageTypeDefOf.RejectInput); } } }
private static void ExecuteRaidWithSpecifics() { StorytellerComp storytellerComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain); IncidentParms parms = storytellerComp.GenerateParms(IncidentCategoryDefOf.ThreatBig, Find.CurrentMap); List <DebugMenuOption> list = new List <DebugMenuOption>(); foreach (Faction allFaction in Find.FactionManager.AllFactions) { Faction localFac = allFaction; float localPoints = default(float); RaidStrategyDef localStrat = default(RaidStrategyDef); PawnsArrivalModeDef localArrival = default(PawnsArrivalModeDef); list.Add(new DebugMenuOption(localFac.Name + " (" + localFac.def.defName + ")", DebugMenuOptionMode.Action, delegate { parms.faction = localFac; List <DebugMenuOption> list2 = new List <DebugMenuOption>(); foreach (float item in DebugActionsUtility.PointsOptions(extended: true)) { localPoints = item; list2.Add(new DebugMenuOption(item + " points", DebugMenuOptionMode.Action, delegate { parms.points = localPoints; List <DebugMenuOption> list3 = new List <DebugMenuOption>(); foreach (RaidStrategyDef allDef in DefDatabase <RaidStrategyDef> .AllDefs) { localStrat = allDef; string text = localStrat.defName; if (!localStrat.Worker.CanUseWith(parms, PawnGroupKindDefOf.Combat)) { text += " [NO]"; } list3.Add(new DebugMenuOption(text, DebugMenuOptionMode.Action, delegate { parms.raidStrategy = localStrat; List <DebugMenuOption> list4 = new List <DebugMenuOption> { new DebugMenuOption("-Random-", DebugMenuOptionMode.Action, delegate { DoRaid(parms); }) }; foreach (PawnsArrivalModeDef allDef2 in DefDatabase <PawnsArrivalModeDef> .AllDefs) { localArrival = allDef2; string text2 = localArrival.defName; if (!localArrival.Worker.CanUseWith(parms) || !localStrat.arriveModes.Contains(localArrival)) { text2 += " [NO]"; } list4.Add(new DebugMenuOption(text2, DebugMenuOptionMode.Action, delegate { parms.raidArrivalMode = localArrival; DoRaid(parms); })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list4)); })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list3)); })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list2)); })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }