Exemplo n.º 1
0
        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));
            });
        }
Exemplo n.º 2
0
        public IEnumerable <FiringIncident> MakeIncidentsForInterval(StorytellerComp comp, IIncidentTarget targ)
        {
            if (GenDate.DaysPassedFloat <= comp.props.minDaysPassed)
            {
                yield break;
            }
            bool flag  = false;
            bool flag2 = comp.props.allowedTargetTags.NullOrEmpty();

            foreach (IncidentTargetTagDef item in targ.IncidentTargetTags())
            {
                if (!comp.props.disallowedTargetTags.NullOrEmpty() && comp.props.disallowedTargetTags.Contains(item))
                {
                    flag = true;
                    break;
                }
                if (!flag2 && comp.props.allowedTargetTags.Contains(item))
                {
                    flag2 = true;
                }
            }
            if (!flag && flag2)
            {
                foreach (FiringIncident fi in comp.MakeIntervalIncidents(targ))
                {
                    if (Find.Storyteller.difficulty.allowBigThreats || (fi.def.category != IncidentCategoryDefOf.ThreatBig))
                    {
                        yield return(fi);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void GenerateScoutInfo()
        {
            StringBuilder          builder          = new StringBuilder();
            List <StorytellerComp> storytellerComps = Find.Storyteller.storytellerComps;

            for (int i = 0; i < storytellerComps.Count; i++)
            {
                StorytellerComp comp = storytellerComps[i];
                if (comp is StorytellerComp_OnOffCycle onOffCycle)
                {
                    StorytellerCompProperties_OnOffCycle prop = (StorytellerCompProperties_OnOffCycle)onOffCycle.props;
                    GetFutureIncidentsLight(scoutDays, Find.AnyPlayerHomeMap, out List <Pair <IncidentDef, IncidentParms> > allIncidents, out List <float> daysToEvents);
                    bool foundOne = false;
                    if (allIncidents.Count > 0)
                    {
                        builder.Append("ScoutingComp_InfoTitle".Translate());
                        for (int i2 = 0; i2 < allIncidents.Count; i2++)
                        {
                            Pair <IncidentDef, IncidentParms> pair = allIncidents[i2];

                            if (!allowedCategories.Contains(pair.First.category))
                            {
                                continue;
                            }

                            foundOne = true;

                            builder.Append($"- {pair.First.LabelCap} ");
                            if (pair.Second.points > 0f && Rand.Chance(0.10f * (int)Faction.def.techLevel))
                            {
                                builder.Append("ScoutingComp_ThreatKnown".Translate(pair.Second.points.ToString("f2")));
                            }
                            else
                            {
                                builder.Append("ScoutingComp_ThreatUnknown".Translate());
                            }

                            float time = Rand.Range(daysToEvents[i2] * 1.02f, daysToEvents[i2] * 1.05f);
                            builder.Append("ScoutingComp_CommingTime".Translate(time.ToString("f2")));
                            builder.Append("\n");
                        }
                    }
                    else
                    {
                        builder.Append("ScoutingComp_NoThreatsInfoTitle".Translate());
                    }

                    if (!foundOne)
                    {
                        builder.Append("ScoutingComp_NoThreatsInfoTitle".Translate());
                    }

                    EmailMessage emailMessage = QuestsManager.Communications.PlayerBox.FormMessageFrom(Faction, builder.ToString(), "ScoutingComp_Subject".Translate());
                    QuestsManager.Communications.PlayerBox.SendMessage(emailMessage);

                    return;
                }
            }
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 private void InitializeStorytellerComps()
 {
     storytellerComps = new List <StorytellerComp>();
     for (int i = 0; i < AllianceGoalDef.comps.Count; i++)
     {
         StorytellerComp storytellerComp = (StorytellerComp)Activator.CreateInstance(AllianceGoalDef.comps[i].compClass);
         storytellerComp.props = AllianceGoalDef.comps[i];
         storytellerComps.Add(storytellerComp);
     }
 }
 public VoteIncidentDef(Dictionary <int, IncidentDef> incidents, StorytellerComp source, IncidentParms parms = null) : base(new List <int>(incidents.Keys))
 {
     this.parms = parms;
     try
     {
         this.incidents = incidents;
         this.source    = source;
     }
     catch (InvalidCastException e)
     {
         Log.Error("Invalid VoteIncidentDef. " + e.Message);
     }
 }
Exemplo n.º 7
0
        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));
        }
Exemplo n.º 8
0
        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);
            }
        }
Exemplo n.º 9
0
 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();
        }
Exemplo n.º 11
0
        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));
        }
Exemplo n.º 12
0
        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);
                }
            }
        }
Exemplo n.º 13
0
 public Vote_RaidStrategy(Dictionary <int, RaidStrategyDef> allStrategies, StorytellerPack pack, IncidentWorker worker, StorytellerComp comp, IncidentParms parms, string title = null) : base(new List <int>(allStrategies.Keys))
 {
     this.title         = title;
     this.allStrategies = allStrategies;
     this.pack          = pack;
     this.worker        = worker;
     this.parms         = parms;
     this.comp          = comp;
 }
Exemplo n.º 14
0
        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);
                }
            }
        }
Exemplo n.º 15
0
        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();
            }
        }
Exemplo n.º 16
0
        public Vote_Mercurius(Dictionary <int, IncidentDef> incidents, StorytellerComp source, IncidentParms parms = null, string title = null) : base(incidents, source, parms)
        {
            this.pack = DefDatabase <StorytellerPack> .GetNamed("Mercurius");

            this.title = title;
        }
Exemplo n.º 17
0
        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));
        }
Exemplo n.º 18
0
        public static void GetFutureIncidentsLight(int numDays, Map forMap, out List <Pair <IncidentDef, IncidentParms> > allIncidents, out List <float> daysToEvents, StorytellerComp onlyThisComp = null)
        {
            int ticksGame = Find.TickManager.TicksGame;

            daysToEvents = new List <float>();
            IncidentQueue          incidentQueue      = Find.Storyteller.incidentQueue;
            List <IIncidentTarget> allIncidentTargets = Find.Storyteller.AllIncidentTargets;

            tmpOldStoryStates.Clear();
            for (int i = 0; i < allIncidentTargets.Count; i++)
            {
                IIncidentTarget incidentTarget = allIncidentTargets[i];
                tmpOldStoryStates.Add(incidentTarget, incidentTarget.StoryState);
                new StoryState(incidentTarget).CopyTo(incidentTarget.StoryState);
            }
            Find.Storyteller.incidentQueue = new IncidentQueue();
            int num = numDays * 60;

            allIncidents = new List <Pair <IncidentDef, IncidentParms> >();
            for (int j = 0; j < num; j++)
            {
                IEnumerable <FiringIncident> enumerable = (onlyThisComp == null) ? Find.Storyteller.MakeIncidentsForInterval() : Find.Storyteller.MakeIncidentsForInterval(onlyThisComp, Find.Storyteller.AllIncidentTargets);
                foreach (FiringIncident item in enumerable)
                {
                    if (item == null)
                    {
                        Log.Error("Null incident generated.");
                        continue;
                    }
                    if (item.parms.target == forMap)
                    {
                        item.parms.target.StoryState.Notify_IncidentFired(item);
                        allIncidents.Add(new Pair <IncidentDef, IncidentParms>(item.def, item.parms));
                        item.parms.target.StoryState.Notify_IncidentFired(item);
                        int num2 = Find.Storyteller.storytellerComps.IndexOf(item.source);
                        daysToEvents.Add(Find.TickManager.TicksGame.TicksToDays());
                    }
                }
                Find.TickManager.DebugSetTicksGame(Find.TickManager.TicksGame + 1000);
            }
            Find.TickManager.DebugSetTicksGame(ticksGame);
            Find.Storyteller.incidentQueue = incidentQueue;
            for (int k = 0; k < allIncidentTargets.Count; k++)
            {
                tmpOldStoryStates[allIncidentTargets[k]].CopyTo(allIncidentTargets[k].StoryState);
            }
            tmpOldStoryStates.Clear();
        }
Exemplo n.º 19
0
        public static void GetFutureIncidents(int numDays, Map forMap, out Dictionary <IIncidentTarget, int> incCountsForTarget, out int[] incCountsForComp, out List <Pair <IncidentDef, IncidentParms> > allIncidents, out int threatBigCount, out List <float> daysToEvents, StringBuilder outputSb = null, StorytellerComp onlyThisComp = null)
        {
            int ticksGame = Find.TickManager.TicksGame;

            daysToEvents = new List <float>();
            IncidentQueue          incidentQueue      = Find.Storyteller.incidentQueue;
            List <IIncidentTarget> allIncidentTargets = Find.Storyteller.AllIncidentTargets;

            tmpOldStoryStates.Clear();
            for (int i = 0; i < allIncidentTargets.Count; i++)
            {
                IIncidentTarget incidentTarget = allIncidentTargets[i];
                tmpOldStoryStates.Add(incidentTarget, incidentTarget.StoryState);
                new StoryState(incidentTarget).CopyTo(incidentTarget.StoryState);
            }
            Find.Storyteller.incidentQueue = new IncidentQueue();
            int num = numDays * 60;

            incCountsForComp   = new int[Find.Storyteller.storytellerComps.Count];
            incCountsForTarget = new Dictionary <IIncidentTarget, int>();
            allIncidents       = new List <Pair <IncidentDef, IncidentParms> >();
            threatBigCount     = 0;
            for (int j = 0; j < num; j++)
            {
                IEnumerable <FiringIncident> enumerable = (onlyThisComp == null) ? Find.Storyteller.MakeIncidentsForInterval() : Find.Storyteller.MakeIncidentsForInterval(onlyThisComp, Find.Storyteller.AllIncidentTargets);
                foreach (FiringIncident item in enumerable)
                {
                    if (item == null)
                    {
                        Log.Error("Null incident generated.");
                    }
                    if (item.parms.target == forMap)
                    {
                        item.parms.target.StoryState.Notify_IncidentFired(item);
                        allIncidents.Add(new Pair <IncidentDef, IncidentParms>(item.def, item.parms));
                        item.parms.target.StoryState.Notify_IncidentFired(item);
                        if (!incCountsForTarget.ContainsKey(item.parms.target))
                        {
                            incCountsForTarget[item.parms.target] = 0;
                        }
                        Dictionary <IIncidentTarget, int> dictionary;
                        IIncidentTarget target;
                        (dictionary = incCountsForTarget)[target = item.parms.target] = dictionary[target] + 1;
                        if (item.def.category == IncidentCategoryDefOf.ThreatBig)
                        {
                            threatBigCount++;
                        }
                        int num2 = Find.Storyteller.storytellerComps.IndexOf(item.source);
                        incCountsForComp[num2]++;
                        daysToEvents.Add(Find.TickManager.TicksGame.TicksToDays());
                    }
                }
                Find.TickManager.DebugSetTicksGame(Find.TickManager.TicksGame + 1000);
            }
            Find.TickManager.DebugSetTicksGame(ticksGame);
            Find.Storyteller.incidentQueue = incidentQueue;
            for (int k = 0; k < allIncidentTargets.Count; k++)
            {
                tmpOldStoryStates[allIncidentTargets[k]].CopyTo(allIncidentTargets[k].StoryState);
            }
            tmpOldStoryStates.Clear();
        }