Beispiel #1
0
        private void DoDialogDelayHandling()
        {
            if (!DialogDelayActive)
            {
                return;
            }


            if (DialogDelayTicks < 0)
            {
                DialogDelayTicks = GenDate.TicksPerHour * 6;
            }

            else if (DialogDelayTicks > 0)
            {
                DialogDelayTicks--;
            }

            else //if (dialogDelayTicks == 0)
            {
                // Create colonists selection dialog
                Dialog_RumorOf_AssignColonists.CreateColonistSelectionDialog();

                DialogDelayActive = false;
                DialogDelayTicks  = -1;
            }
        }
Beispiel #2
0
        public static void CreateColonistSelectionDialog()
        {
            // Create colonists selection dialog
            Dialog_RumorOf_AssignColonists dialog = new Dialog_RumorOf_AssignColonists();

            dialog.forcePause           = true;
            dialog.onlyOneOfTypeAllowed = true;
            Find.WindowStack.Add(dialog);
        }
Beispiel #3
0
        public override bool TryExecute(IncidentParms parms)
        {
            // Do nothing, if MapComponent isn't available
            if (!MapComponent_ColonistsOutsideMap_RumorOf.IsMapComponentAvailable(out mapComponent))
            {
                return(false);
            }

            Map map = parms.target as Map;

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

            // Reinit a new story
            mapComponent.def = null;
            mapComponent.DoUpdateDef();

            // Set a new travel time
            mapComponent.SetNewTravelTime();

            IEnumerable <Pawn> friendlies = TryFindFriendlyPawns(map);

            //if (friendlies == null || friendlies.Count() == 0)
            //    return false;
            if (friendlies == null || friendlies.Count() == 0)
            {
                return(TryExecuteVisitorsAndRestartSelf(parms));
            }

            Pawn pawnTellingRumor = friendlies.RandomElement();

            IntVec3             exitMapCell;
            Predicate <IntVec3> predicate = (IntVec3 c) =>
            {
                if (!c.Standable(map) || !map.reachability.CanReachColony(c))
                {
                    return(false);
                }

                return(true);
            };

            if (!CellFinder.TryFindRandomEdgeCellWith(predicate, map, out exitMapCell))
            {
                return(false);
            }


            // Create initial selection dialog
            string  str     = mapComponent.def.InitialMessageVariable.Translate(new object[] { pawnTellingRumor.Name.ToStringFull, pawnTellingRumor.Faction.ToString() });
            DiaNode diaNode = new DiaNode(str.AdjustedFor(pawnTellingRumor));

            DiaOption diaOption = new DiaOption(mapComponent.def.InitialMessageButtonAcceptVariable.Translate())
            {
                action = () =>
                {
                    mapComponent.ExitMapCell    = exitMapCell;
                    mapComponent.IncidentPoints = parms.points;

                    // Create colonists selection dialog
                    Dialog_RumorOf_AssignColonists.CreateColonistSelectionDialog();
                },
                resolveTree = true
            };

            diaNode.options.Add(diaOption);

            string    str1       = mapComponent.def.InitialMessageRejectedVariable.Translate(new object[] { pawnTellingRumor.NameStringShort });
            DiaNode   diaNode1   = new DiaNode(str1.AdjustedFor(pawnTellingRumor));
            DiaOption diaOption1 = new DiaOption("OK".Translate())
            {
                resolveTree = true
            };

            diaNode1.options.Add(diaOption1);

            DiaOption diaOption2 = new DiaOption(mapComponent.def.InitialMessageButtonRejectVariable.Translate())
            {
                link = diaNode1
            };

            diaNode.options.Add(diaOption2);

            Find.WindowStack.Add(new Dialog_NodeTree(diaNode));
            return(true);
        }