private void RandomizeCurPawn()
        {
            if (!TutorSystem.AllowAction("RandomizePawn"))
            {
                return;
            }
            int num = 0;

            while (true)
            {
                this.curPawn = StartingPawnUtility.RandomizeInPlace(this.curPawn);
                num++;
                if (num > 15)
                {
                    break;
                }
                if (StartingPawnUtility.WorkTypeRequirementsSatisfied())
                {
                    goto Block_3;
                }
            }
            return;

Block_3:
            TutorSystem.Notify_Event("RandomizePawn");
        }
 protected override bool CanDoNext()
 {
     if (!base.CanDoNext())
     {
         return(false);
     }
     if (TutorSystem.TutorialMode)
     {
         WorkTypeDef workTypeDef = StartingPawnUtility.RequiredWorkTypesDisabledForEveryone().FirstOrDefault();
         if (workTypeDef != null)
         {
             Messages.Message("RequiredWorkTypeDisabledForEveryone".Translate() + ": " + workTypeDef.gerundLabel.CapitalizeFirst() + ".", MessageTypeDefOf.RejectInput, historical: false);
             return(false);
         }
     }
     foreach (Pawn startingAndOptionalPawn in Find.GameInitData.startingAndOptionalPawns)
     {
         if (!startingAndOptionalPawn.Name.IsValid)
         {
             Messages.Message("EveryoneNeedsValidName".Translate(), MessageTypeDefOf.RejectInput, historical: false);
             return(false);
         }
     }
     PortraitsCache.Clear();
     return(true);
 }
        private void CheckWarnRequiredWorkTypesDisabledForEveryone(Action nextAction)
        {
            IEnumerable <WorkTypeDef> enumerable = StartingPawnUtility.RequiredWorkTypesDisabledForEveryone();

            if (enumerable.Any <WorkTypeDef>())
            {
                StringBuilder stringBuilder = new StringBuilder();
                foreach (WorkTypeDef current in enumerable)
                {
                    if (stringBuilder.Length > 0)
                    {
                        stringBuilder.AppendLine();
                    }
                    stringBuilder.Append("  - " + current.gerundLabel.CapitalizeFirst());
                }
                string text = "ConfirmRequiredWorkTypeDisabledForEveryone".Translate(new object[]
                {
                    stringBuilder.ToString()
                });
                Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(text, nextAction, false, null));
            }
            else
            {
                nextAction();
            }
        }
Exemple #4
0
        public override void PostWorldGenerate()
        {
            int num = 0;

            while (true)
            {
                StartingPawnUtility.ClearAllStartingPawns();
                for (int i = 0; i < this.pawnCount; i++)
                {
                    Find.GameInitData.startingPawns.Add(StartingPawnUtility.NewGeneratedStartingPawn());
                }
                num++;
                if (num > 20)
                {
                    break;
                }
                if (StartingPawnUtility.WorkTypeRequirementsSatisfied())
                {
                    goto Block_3;
                }
            }
            return;

Block_3:
            while (Find.GameInitData.startingPawns.Count < this.pawnChoiceCount)
            {
                Find.GameInitData.startingPawns.Add(StartingPawnUtility.NewGeneratedStartingPawn());
            }
            Find.GameInitData.startingPawnCount = this.pawnCount;
        }
Exemple #5
0
 private void RandomizeCurPawn()
 {
     if (TutorSystem.AllowAction("RandomizePawn"))
     {
         this.curPawn = StartingPawnUtility.RandomizeInPlace(this.curPawn);
         TutorSystem.Notify_Event("RandomizePawn");
     }
 }
Exemple #6
0
 private void RollForPawns()
 {
     checked {
         for (int i = 0; i < Find.GameInitData.startingPawns.Count; i++)
         {
             Pawn pawn = Find.GameInitData.startingPawns[i];
             pawn = StartingPawnUtility.RandomizeInPlace(pawn);
         }
         this.callingPage.SelectPawn(Find.GameInitData.startingPawns[0]);
     }
 }
Exemple #7
0
 public void RollColonist(int index)
 {
     try {
         Pawn pawn = Find.GameInitData.startingPawns[index];
         pawn = StartingPawnUtility.RandomizeInPlace(pawn);
     }
     catch {
         Log.Message("index is " + index);
         Log.Message("Find.GameInitData.startingPawns count is " + Find.GameInitData.startingPawns.Count);
     }
     ConfigureStartingPawns_Controller.SelectPawnOnPage(this.originalPage, Find.GameInitData.startingPawns[0]);
 }
 private void RandomizeCurPawn()
 {
     if (!TutorSystem.AllowAction("RandomizePawn"))
     {
         return;
     }
     do
     {
         this.curPawn = StartingPawnUtility.RandomizeInPlace(this.curPawn);
     }while (!StartingPawnUtility.WorkTypeRequirementsSatisfied());
     TutorSystem.Notify_Event("RandomizePawn");
 }
        /// <summary>
        /// Перед запуском удалить всех колонистов игрока
        /// </summary>
        /// <param name="pawnsCount"></param>
        /// <param name="result"></param>
        public static void ShowDialog(int pawnsCount, Action <List <Pawn> > result)
        {
            List <Pawn> oldPawns = null;
            //запоминаем текущее
            var gameIsNull = Current.Game == null || Current.Game.InitData == null;

            if (gameIsNull)
            {
                GameUtils.ShortSetupForQuickTestPlay();
            }
            else
            {
                oldPawns = Current.Game.InitData.startingAndOptionalPawns.ToList();
            }

            //тяп-ляп и новые пешки
            Current.Game.InitData.startingAndOptionalPawns.Clear();
            for (int i = 0; i < pawnsCount; i++)
            {
                Current.Game.InitData.startingAndOptionalPawns.Add(PawnGenerateRandom());
            }
            //if (MainHelper.DebugMode) File.WriteAllText(Loger.PathLog + @"SrvTest.txt", DevelopTest.TextObj(Current.Game.InitData.startingPawns, true), Encoding.UTF8);
            for (int i = 0; i < pawnsCount; i++)
            {
                StartingPawnUtility.RandomizeInPlace(Current.Game.InitData.startingAndOptionalPawns[i]);
            }

            //запускаем форму редактирования
            var form = new Page_ConfigureStartingPawns();

            form.nextAct = () =>
            {
                var pawns = Current.Game.InitData.startingAndOptionalPawns.ToList();

                //восстанавливаем значеня
                if (gameIsNull)
                {
                    Current.Game = null;
                }
                else
                {
                    Current.Game.InitData.startingAndOptionalPawns.Clear();
                    for (int i = 0; i < oldPawns.Count; i++)
                    {
                        Current.Game.InitData.startingAndOptionalPawns.Add(oldPawns[i]);
                    }
                }

                result(pawns);
            };
            Find.WindowStack.Add(form);
        }
 private void RandomizeCurPawn()
 {
     if (TutorSystem.AllowAction("RandomizePawn"))
     {
         int num = 0;
         do
         {
             curPawn = StartingPawnUtility.RandomizeInPlace(curPawn);
             num++;
         }while (num <= 20 && !StartingPawnUtility.WorkTypeRequirementsSatisfied());
         TutorSystem.Notify_Event("RandomizePawn");
     }
 }
Exemple #11
0
        //private void RandomizeCurPawn()
        //{
        //    if (!TutorSystem.AllowAction("RandomizePawn"))
        //    {
        //        return;
        //    }
        //    int num = 0;
        //    do
        //    {
        //        this.curPawn = StartingPawnUtility.RandomizeInPlace(this.curPawn);
        //        num++;
        //        if (num <= 15)
        //        {
        //            continue;
        //        }
        //        return;
        //    }
        //    while (!StartingPawnUtility.WorkTypeRequirementsSatisfied());
        //    TutorSystem.Notify_Event("RandomizePawn");
        //}

        private IEnumerator RandomizeAllPawns()
        {
            // Temp variable to store generated pawns
            Pawn[] aPawns = new Pawn[0];

            // Try 15 times to generate pawn with WorkTypeRequirementsSatisfied?
            int num = 0;

            do
            {
                // Loop through current pawns and generate random in place
                foreach (Pawn p in Find.GameInitData.startingPawns)
                {
                    Pawn curpawn = new Pawn();

                    curpawn = StartingPawnUtility.RandomizeInPlace(p);

                    aPawns = aPawns.Concat(new Pawn[] { curpawn }).ToArray();
                }

                NewGameRules.ClearCurPawns();

                Find.GameInitData.startingPawns = aPawns.ToList();
                aPawns = new Pawn[0];

                lstCardRects            = new List <Rect>();
                lstPNC_Cards            = new List <PNC_Card>();
                lstPNC_CardsInOrder     = new List <PNC_Card>();
                templstPNC_CardsInOrder = new List <PNC_Card>();
                intCardNum = 0;

                PopulateCards(false);

                if (num > 10 && StartingPawnUtility.WorkTypeRequirementsSatisfied())
                {
                    yield break;
                }

                num++;
                if (num <= 15)
                {
                    yield return(new WaitForSeconds(.05f));

                    //Log.Message(num.ToString());
                    continue;
                }
                yield break;
            }while (num < 3);
        }
        // Token: 0x06004DA0 RID: 19872 RVA: 0x001A4DAC File Offset: 0x001A2FAC
        public override void PostWorldGenerate()
        {
            if (this.Pawns.NullOrEmpty())
            {
                base.PostWorldGenerate();
                return;
            }
            List <PawnKindDef> kinds = new List <PawnKindDef>();

            foreach (var item in this.Pawns)
            {
                for (int i = 0; i < item.count; i++)
                {
                    kinds.Add(item.kindDef);
                }
            }
            this.pawnCount = kinds.Count;
            Find.GameInitData.startingPawnCount = this.pawnCount;
            int num = 0;

            do
            {
                StartingPawnUtility.ClearAllStartingPawns();
                foreach (var item in kinds)
                {
                    //	Log.Message("Generating "+item);
                    Find.GameInitData.startingAndOptionalPawns.Add(SpecificStartingPawnUtility.NewGeneratedStartingPawn(item));
                }
                num++;
                if (num > 20)
                {
                    break;
                }
            }while (!StartingPawnUtility.WorkTypeRequirementsSatisfied());
IL_62:
            while (Find.GameInitData.startingAndOptionalPawns.Count < this.pawnChoiceCount)
            {
                foreach (var item in kinds)
                {
                    //	Log.Message("Generating " + item);
                    Find.GameInitData.startingAndOptionalPawns.Add(SpecificStartingPawnUtility.NewGeneratedStartingPawn(item));
                }
            }
            return;

            goto IL_62;
        }
        public override void PostWorldGenerate()
        {
            Find.GameInitData.startingPawnCount = pawnCount;
            int num = 0;

            do
            {
                StartingPawnUtility.ClearAllStartingPawns();
                for (int i = 0; i < pawnCount; i++)
                {
                    Find.GameInitData.startingAndOptionalPawns.Add(StartingPawnUtility.NewGeneratedStartingPawn());
                }
                num++;
            }while (num <= 20 && !StartingPawnUtility.WorkTypeRequirementsSatisfied());
            while (Find.GameInitData.startingAndOptionalPawns.Count < pawnChoiceCount)
            {
                Find.GameInitData.startingAndOptionalPawns.Add(StartingPawnUtility.NewGeneratedStartingPawn());
            }
        }
        public override void PostWorldLoad()
        {
            int num = 0;

            while (true)
            {
                //StartingPawnUtility.ClearAllStartingPawns();
                for (int i = 0; i < this.slaveCount; i++)
                {
                    Find.GameInitData.startingPawns.Add(ElderThingFaction.ScenPart_ConfigPage_ConfigureStartingSlaves.NewGeneratedStartingSlave());
                }
                num++;
                if (num > 20)
                {
                    break;
                }
                if (StartingPawnUtility.WorkTypeRequirementsSatisfied())
                {
                    return;
                }
            }
        }
        public override void PostWorldGenerate()
        {
            var num = 0;

            while (true)
            {
                //StartingPawnUtility.ClearAllStartingPawns();
                for (var i = 0; i < slaveCount; i++)
                {
                    Find.GameInitData.startingAndOptionalPawns.Add(NewGeneratedStartingSlave());
                }

                num++;
                if (num > 20)
                {
                    break;
                }

                if (StartingPawnUtility.WorkTypeRequirementsSatisfied())
                {
                    return;
                }
            }
        }
        public static void GenerateEmptyMap()
        {
            LongEventHandler.QueueLongEvent(delegate()
            {
                var game = new Game
                {
                    InitData = new GameInitData()
                    {
                        mapSize = 75, permadeath = false
                    },
                    Scenario    = ScenarioDefOf.Crashlanded.scenario,
                    storyteller = new Storyteller(StorytellerDefOf.Cassandra, DifficultyDefOf.Rough)
                };
                Find.Scenario.PreConfigure();
                Current.Game = game;

                Find.GameInitData.PrepForMapGen();
                Find.GameInitData.startedFromEntry = true;
                Find.Scenario.PreMapGenerate();

                Find.GameInitData.ResetWorldRelatedMapInitData();
                Current.Game.World = WorldGenerator.GenerateWorld(0.05f, GenText.RandomSeedString(), OverallRainfall.Normal, OverallTemperature.Normal, OverallPopulation.Normal);
                MemoryUtility.UnloadUnusedUnityAssets();
                Find.World.renderer.RegenerateAllLayersNow();

                MemoryUtility.UnloadUnusedUnityAssets();

                Current.ProgramState = ProgramState.MapInitializing;

                var mapSize = new IntVec3(game.InitData.mapSize, 1, game.InitData.mapSize);
                game.World.info.initialMapSize = mapSize;
                if (game.InitData.permadeath)
                {
                    game.Info.permadeathMode           = true;
                    game.Info.permadeathModeUniqueName = PermadeathModeUtility.GeneratePermadeathSaveName();
                }

                game.tickManager.gameStartAbsTick = GenTicks.ConfiguredTicksAbsAtGameStart;

                _ = Find.Scenario.parts.RemoveAll(part => part is ScenPart_GameStartDialog);
                var arrivalMethod    = Find.Scenario.AllParts.OfType <ScenPart_PlayerPawnsArriveMethod>().First();
                arrivalMethod.method = PlayerPawnsArriveMethod.Standing;

                var tile = TileFinder.RandomStartingTile();

                Find.GameInitData.startingAndOptionalPawns.Clear();

                for (var i = 1; i <= 3; i++)
                {
                    var pawn = StartingPawnUtility.NewGeneratedStartingPawn();
                    pawn.playerSettings.hostilityResponse = HostilityResponseMode.Ignore;
                    DefDatabase <SkillDef> .AllDefsListForReading.Do(skillDef => pawn.skills.GetSkill(skillDef).EnsureMinLevelWithMargin(1));
                    Find.GameInitData.startingAndOptionalPawns.Add(pawn);
                }

                var settlement = (Settlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement);
                settlement.SetFaction(Find.GameInitData.playerFaction);
                settlement.Tile = tile;
                settlement.Name = NameGenerator.GenerateName(Faction.OfPlayer.def.factionNameMaker);
                Find.WorldObjects.Add(settlement);

                Current.Game.CurrentMap = MapGenerator.GenerateMap(mapSize, settlement, settlement.MapGeneratorDef, settlement.ExtraGenStepDefs, null);
                PawnUtility.GiveAllStartingPlayerPawnsThought(ThoughtDefOf.NewColonyOptimism);

                game.FinalizeInit();
                game.playSettings.useWorkPriorities = true;

                Find.CameraDriver.JumpToCurrentMapLoc(MapGenerator.PlayerStartSpot);
                Find.CameraDriver.ResetSize();
                Find.Scenario.PostGameStart();

                foreach (var researchProjectDef in DefDatabase <ResearchProjectDef> .AllDefs)
                {
                    game.researchManager.FinishProject(researchProjectDef, false, null);
                }

                GameComponentUtility.StartedNewGame();
                game.InitData = null;
            }, "GeneratingMap", true, new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap), true);
            LongEventHandler.QueueLongEvent(delegate()
            {
                ScreenFader.SetColor(Color.black);
                ScreenFader.StartFade(Color.clear, 0.5f);
            }, null, false, null, true);
        }
Exemple #17
0
        public override void PostMapGenerate(Map map)
        {
            if (Find.GameInitData == null)
            {
                return;
            }
            string str1 = Path.Combine(Path.Combine(GenFilePaths.SaveDataFolderPath, "Ships"), shipFactionName + ".rwship");
            string actualFactionName = shipFactionName;
            bool   isVersion2        = false;

            if (File.Exists(str1 + "2")) //woo 2.0
            {
                str1      += "2";
                isVersion2 = true;
            }
            Scribe.loader.InitLoading(str1);

            FactionDef     factionDef = Faction.OfPlayer.def;
            ShipDefinition ship       = null;

            ShipInteriorMod.Log("Loading base managers...");
            Scribe_Deep.Look(ref Current.Game.uniqueIDsManager, false, "uniqueIDsManager", new object[0]);
            Scribe_Deep.Look(ref Current.Game.tickManager, false, "tickManager", new object[0]);
            Scribe_Deep.Look(ref Current.Game.drugPolicyDatabase, false, "drugPolicyDatabase", new object[0]);
            Scribe_Deep.Look(ref Current.Game.outfitDatabase, false, "outfitDatabase", new object[0]);

            //spawn a temp pawn.
            Pawn tmpPawn = StartingPawnUtility.NewGeneratedStartingPawn();

            //Advancing time
            ShipInteriorMod.Log("Advancing time...");
            Current.Game.tickManager.DebugSetTicksGame(Current.Game.tickManager.TicksAbs + 3600000 * Rand.RangeInclusive(Mod.minTravelTime.Value, Mod.maxTravelTime.Value));

            if (isVersion2)
            {
                Scribe_Values.Look(ref actualFactionName, "playerFactionName");
                Scribe_Deep.Look(ref ship, "shipDefinition");
            }
            else
            {
                ship = new ShipDefinition();
                //load the data the more cludgey way.
                ship.ExposeData();
            }

            highCorner = ship.Max;
            lowCorner  = ship.Min;

            IntVec3 spot   = MapGenerator.PlayerStartSpot;
            int     width  = highCorner.x - lowCorner.x;
            int     height = highCorner.z - lowCorner.z;

            //try to position us over the start location
            spot.x -= width / 2;
            spot.z -= height / 2;

            //now offset the corners and the parts to the spot.
            int offsetx = spot.x - lowCorner.x;
            int offsety = spot.z - lowCorner.z;

            lowCorner.x  += offsetx;
            lowCorner.z  += offsety;
            highCorner.x += offsetx;
            highCorner.z += offsety;

            tmpPawn.Position = lowCorner - new IntVec3(3, 0, 3);
            tmpPawn.SpawnSetup(map, false);

            ShipInteriorMod.Log("Low Corner: " + lowCorner.x + ", " + lowCorner.y + ", " + lowCorner.z);
            ShipInteriorMod.Log("High Corner: " + highCorner.x + ", " + highCorner.y + ", " + highCorner.z);
            ShipInteriorMod.Log("Map Size: " + map.Size.x + ", " + map.Size.y + ", " + map.Size.z);

            ship.AdaptToNewGame(map, offsetx, offsety, "Landing", true, Handler);

            new MapScanner()
            .DestroyThings(-2, 2)
            .ForPoints((point, m) => m.roofGrid.SetRoof(point, null), -2, 2)
            .ForPoints((point, m) => m.terrainGrid.SetTerrain(point, TerrainDefOf.Gravel))
            .Unfog(-3, 3)
            .QueueAsLongEvent(map, lowCorner, highCorner, "Landing_Clean", true, Handler);

            ship.SpawnInNewGame(map, "Landing", true, Handler);


            LongEventHandler.QueueLongEvent(() =>
            {
                ShipInteriorMod.Log("Loading managers...");
                Scribe_Deep.Look(ref Current.Game.researchManager, false, "researchManager", new object[0]);
                Scribe_Deep.Look(ref Current.Game.taleManager, false, "taleManager", new object[0]);
                Scribe_Deep.Look(ref Current.Game.playLog, false, "playLog", new object[0]);
                Scribe.loader.FinalizeLoading();
                tmpPawn.DeSpawn();

                Faction.OfPlayer.Name = actualFactionName;

                ShipInteriorMod.Log("Done.");
            }, "Landing_Managers", true, Handler);
        }