public override void Cleanup()
        {
            base.Cleanup();             // there's nothing in the base call (at the moment), but just in case in the future there's something

            // get pawns that spawned from Reunion
            var listToReturn = pawns.FindAll((pawn) =>
            {
                return(pawn.Faction != Faction.OfPlayer && GameComponent.ListAllySpawned.Contains(pawn.GetUniqueLoadID()));
            });

            GameComponent.FlagNextEventReadyForScheduling();
            foreach (var pawn in listToReturn)
            {
                GameComponent.ReturnToAvailable(pawn, GameComponent.ListAllySpawned, GameComponent.ListAllyAvailable);
            }

            if (quest.State == QuestState.EndedOfferExpired)
            {
                saveByReference = true;
            }
            else
            {
                GameComponent.TryScheduleNextEvent(ScheduleMode.Forced);
            }
        }
        public static bool Do()
        {
            Map     map = Current.Game.RandomPlayerHomeMap;
            IntVec3 loc;

            if (!TryFindEntryCell(map, out loc))
            {
                return(false);
            }

            var pawn = GameComponent.GetRandomAllyForSpawning();

            if (pawn == null)
            {
                return(false);
            }

            pawn.SetFactionDirect(Faction.OfPlayer);
            GenSpawn.Spawn(pawn, loc, map, WipeMode.Vanish);

            var          def             = IncidentDefs.Reunion_AllyJoin;
            TaggedString baseLetterLabel = def.letterLabel.Formatted(pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN", true);
            TaggedString baseLetterText  = def.letterText.Formatted(pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN", true);

            Find.LetterStack.ReceiveLetter(baseLetterLabel, baseLetterText, def.letterDef, new LookTargets(pawn));

            GameComponent.TryScheduleNextEvent(ScheduleMode.Forced);

            return(true);
        }
Example #3
0
        public static void OnPostDestroyReschedule(SitePart sitePart)
        {
            // If recruited, will have been flagged on map generate: schedule will fire on DoRecruit
            // If abandoned but pawn alive, also will have been flagged on map generate: schedule will fire on PassToWorld

            // If quest failed without entering the map, flag here: schedule will fire on PassToWorld
            if (GameComponent.NextEventTick == -1)
            {
                GameComponent.FlagNextEventReadyForScheduling();
            }

            if (sitePart.things != null && sitePart.things.Any)
            {
                Pawn pawn = (Pawn)sitePart.things[0];
                // If pawn is dead on post destroy: schedule it HERE!
                if (pawn.Dead)
                {
                    GameComponent.TryScheduleNextEvent();
                }
            }
            // No "thing" in SitePart, pawn is recruited, or something else happened.
            // As mentioned above, if recruited, schedule will already have fired on DoRecruit.
            // If not recruited for whatever reason (likely dead, according to tests): schedule it HERE!
            else if (GameComponent.NextEventTick == 0)
            {
                GameComponent.TryScheduleNextEvent();
            }
        }
Example #4
0
 static void Postfix(InteractionWorker_RecruitAttempt __instance, Pawn recruiter, Pawn recruitee, float recruitChance, bool useAudiovisualEffects)
 {
     if (GameComponent.ListAllySpawned.Contains(recruitee.GetUniqueLoadID()))
     {
         GameComponent.TryScheduleNextEvent(true);
     }
 }
Example #5
0
        // Mod UI
        public override void DoSettingsWindowContents(UnityEngine.Rect inRect)
        {
            const float GAP_HEIGHT = 12f;

            Listing_Standard listingStandard = new Listing_Standard();

            listingStandard.Begin(inRect);

            var prevMin        = _settings.minDaysBetweenEvents;
            var strMinDaysBtwn = _settings.minDaysBetweenEvents.ToString();

            listingStandard.TextFieldNumericLabeled("Reunion.MinDaysBetweenEvents".Translate(), ref _settings.minDaysBetweenEvents, ref strMinDaysBtwn, INPUT_MIN_DAYS_BTWN_EVENTS, INPUT_MAX_DAYS_BTWN_EVENTS);
            _settings.minDaysBetweenEvents = UnityEngine.Mathf.RoundToInt(listingStandard.Slider(_settings.minDaysBetweenEvents, INPUT_MIN_DAYS_BTWN_EVENTS, INPUT_MAX_DAYS_BTWN_EVENTS));

            listingStandard.Gap(GAP_HEIGHT);

            var prevMax        = _settings.maxDaysBetweenEvents;
            var strMaxDaysBtwn = _settings.maxDaysBetweenEvents.ToString();

            listingStandard.TextFieldNumericLabeled("Reunion.MaxDaysBetweenEvents".Translate(), ref _settings.maxDaysBetweenEvents, ref strMaxDaysBtwn, INPUT_MIN_DAYS_BTWN_EVENTS + 1, INPUT_MAX_DAYS_BTWN_EVENTS);
            _settings.maxDaysBetweenEvents = UnityEngine.Mathf.RoundToInt(listingStandard.Slider(_settings.maxDaysBetweenEvents, INPUT_MIN_DAYS_BTWN_EVENTS + 1, INPUT_MAX_DAYS_BTWN_EVENTS));

            if (_settings.minDaysBetweenEvents >= _settings.maxDaysBetweenEvents)
            {
                _settings.minDaysBetweenEvents = _settings.maxDaysBetweenEvents - 1;
            }

            if (Current.Game != null && Current.Game.Info.RealPlayTimeInteracting > 0 &&
                (prevMin != _settings.minDaysBetweenEvents || prevMax != _settings.maxDaysBetweenEvents))
            {
                GameComponent.TryScheduleNextEvent(ScheduleMode.SettingsUpdated);
            }

            listingStandard.Gap(GAP_HEIGHT);

            foreach (Settings.Event evtType in Enum.GetValues(typeof(Settings.Event)))
            {
                var allow = _settings.EventAllow[evtType];
                listingStandard.CheckboxLabeled(Settings.CreateTranslationKey(evtType).Translate(), ref allow);
                _settings.EventAllow[evtType] = allow;
            }

            listingStandard.Gap(GAP_HEIGHT);

            listingStandard.CheckboxLabeled("Reunion.EnableHarderSolo".Translate(), ref _settings.enableHarderEventsWhenSolo);

            listingStandard.End();

            base.DoSettingsWindowContents(inRect);
        }
Example #6
0
        public static bool Do()
        {
            var pawn = GameComponent.GetRandomAllyForSpawning();

            if (pawn == null)
            {
                return(false);
            }

            HealthUtility.DamageUntilDowned(pawn, true);

            var          def    = IncidentDefs.Reunion_AllyRefugeePod;
            Map          map    = Current.Game.RandomPlayerHomeMap;
            List <Thing> things = new List <Thing>();

            things.Add(pawn);
            IntVec3 intVec = DropCellFinder.RandomDropSpot(map);

            pawn.guest.getRescuedThoughtOnUndownedBecauseOfPlayer = true;
            //pawn.mindState.WillJoinColonyIfRescued = true; // will trigger LetterRescueQuestFinished which is wrong. We want LetterRescueeJoins

            TaggedString baseLetterLabel = def.letterLabel.Formatted(pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN", true);
            TaggedString baseLetterText  = def.letterText.Formatted(pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN", true);

            Find.LetterStack.ReceiveLetter(baseLetterLabel, baseLetterText, def.letterDef, new LookTargets(pawn));

            ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();

            activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(things, true, false);
            activeDropPodInfo.openDelay = 180;
            activeDropPodInfo.leaveSlag = true;
            DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo);

            GameComponent.TryScheduleNextEvent(true);
            return(true);
        }
Example #7
0
            static void Postfix(Dialog_DebugActionsMenu __instance, ref List <Dialog_DebugActionsMenu.DebugActionOption> ___debugActions)
            {
                // *** Force Start Reunion Event ***
                var debugAddAlly = new Dialog_DebugActionsMenu.DebugActionOption();

                debugAddAlly.actionType = DebugActionType.Action;
                debugAddAlly.label      = "Force Start Reunion Event";
                debugAddAlly.category   = CATEGORY;
                debugAddAlly.action     = delegate
                {
                    GameComponent.DecideAndDoEvent();
                };
                ___debugActions.Add(debugAddAlly);                 // add to main list

                // *** Make world pawn "Ally" ***
                debugAddAlly            = new Dialog_DebugActionsMenu.DebugActionOption();
                debugAddAlly.actionType = DebugActionType.Action;
                debugAddAlly.label      = "Make world pawn \"Ally\"...";
                debugAddAlly.category   = CATEGORY;
                debugAddAlly.action     = delegate
                {
                    List <DebugMenuOption> list       = new List <DebugMenuOption>();
                    Action <Pawn>          actionPawn = delegate(Pawn p)
                    {
                        if (p != null && p.story != null)
                        {
                            GameComponent.TryRemoveTrait(p);
                            GameComponent.ListAllyAvailable.Add(p);
                            Find.WorldPawns.RemovePawn(p);
                            Util.Msg(p.Name + " has been removed from the World and added to the Ally list.");
                            if (GameComponent.ListAllyAvailable.Count == 1)
                            {
                                GameComponent.TryScheduleNextEvent(ScheduleMode.Forced);
                            }
                        }
                    };

                    foreach (Pawn current in Find.WorldPawns.AllPawnsAlive)
                    {
                        Pawn pLocal = current;
                        if (current != null && current.story != null)                         // don't list those already with the trait
                        {
                            list.Add(new DebugMenuOption(current.LabelShort, DebugMenuOptionMode.Action, delegate
                            {
                                actionPawn(pLocal);
                            }));
                        }
                    }

                    Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
                };
                ___debugActions.Add(debugAddAlly);                 // add to main list

                // *** Print Ally List ***
                var debugPrintAllyList = new Dialog_DebugActionsMenu.DebugActionOption();

                debugPrintAllyList.actionType = DebugActionType.Action;
                debugPrintAllyList.label      = "Print \"Ally\" list";
                debugPrintAllyList.category   = CATEGORY;
                debugPrintAllyList.action     = delegate
                {
                    if (GameComponent.ListAllyAvailable.Count > 0)
                    {
                        Util.PrintAllyList();
                    }
                    else
                    {
                        Util.Msg("There are no allies in the Ally list!");
                    }
                };
                ___debugActions.Add(debugPrintAllyList);                 // add to main list
            }