Exemple #1
0
        private void DoCustomBottomButtons()
        {
            int num;
            int num1 = (!TutorSystem.TutorialMode ? 5 : 4);

            num = (num1 < 4 || (float)UI.screenWidth >= 1340f ? 1 : 2);
            int     num2          = Mathf.CeilToInt((float)num1 / (float)num);
            Vector2 bottomButSize = Page.BottomButSize;
            float   single        = bottomButSize.x * (float)num2 + 10f * (float)(num2 + 1);
            float   single1       = (float)num;
            Vector2 vector2       = Page.BottomButSize;
            float   single2       = single1 * vector2.y + 10f * (float)(num + 1);
            Rect    rect          = new Rect(((float)UI.screenWidth - single) / 2f, (float)UI.screenHeight - single2 - 4f, single, single2);

            if (Find.WindowStack.IsOpen <WorldInspectPane>() && rect.x < InspectPaneUtility.PaneSize.x + 4f)
            {
                rect.x = InspectPaneUtility.PaneSize.x + 4f;
            }
            Widgets.DrawWindowBackground(rect);
            float bottomButSize1 = rect.xMin + 10f;
            float bottomButSize2 = rect.yMin + 10f;

            Text.Font = GameFont.Small;
            if (Widgets.ButtonText(new Rect(bottomButSize1, bottomButSize2, Page.BottomButSize.x, Page.BottomButSize.y), "Back".Translate(), true, false, true) && this.CanDoBack())
            {
                this.DoBack();
            }
            bottomButSize1 = bottomButSize1 + (Page.BottomButSize.x + 10f);
            if (!TutorSystem.TutorialMode)
            {
                if (Widgets.ButtonText(new Rect(bottomButSize1, bottomButSize2, Page.BottomButSize.x, Page.BottomButSize.y), "Advanced".Translate(), true, false, true))
                {
                    Find.WindowStack.Add(new Dialog_AdvancedGameConfig(Find.WorldInterface.SelectedTile));
                }
                bottomButSize1 = bottomButSize1 + (Page.BottomButSize.x + 10f);
            }
            if (Widgets.ButtonText(new Rect(bottomButSize1, bottomButSize2, Page.BottomButSize.x, Page.BottomButSize.y), "SelectRandomSite".Translate(), true, false, true))
            {
                SoundDefOf.Click.PlayOneShotOnCamera(null);
                Find.WorldInterface.SelectedTile = TileFinder.RandomStartingTile();
                Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile));
            }
            bottomButSize1 = bottomButSize1 + (Page.BottomButSize.x + 10f);
            if (num == 2)
            {
                bottomButSize1 = rect.xMin + 10f;
                bottomButSize2 = bottomButSize2 + (Page.BottomButSize.y + 10f);
            }
            if (Widgets.ButtonText(new Rect(bottomButSize1, bottomButSize2, Page.BottomButSize.x, Page.BottomButSize.y), "WorldFactionsTab".Translate(), true, false, true))
            {
                Find.WindowStack.Add(new Dialog_FactionDuringLanding());
            }
            bottomButSize1 = bottomButSize1 + (Page.BottomButSize.x + 10f);
            if (Widgets.ButtonText(new Rect(bottomButSize1, bottomButSize2, Page.BottomButSize.x, Page.BottomButSize.y), "Next".Translate(), true, false, true) && this.CanDoNext())
            {
                this.DoNext();
            }
            bottomButSize1 = bottomButSize1 + (Page.BottomButSize.x + 10f);
            GenUI.AbsorbClicksInRect(rect);
        }
Exemple #2
0
        private static int MoveMapParentSomewhereElse(MapParent oldParent)
        {
            var originalTile = oldParent.Tile;

            oldParent.Tile = TileFinder.RandomStartingTile();
            return(originalTile);
        }
Exemple #3
0
        public static void GenerateFactionsIntoWorldPostFix()
        {
            Log.Message("Generating Corruption Story Tracker");
            CorruptionStoryTracker corrTracker = (CorruptionStoryTracker)WorldObjectMaker.MakeWorldObject(DefOfs.C_WorldObjectDefOf.CorruptionStoryTracker);

            corrTracker.Tile = TileFinder.RandomStartingTile();
            Find.WorldObjects.Add(corrTracker);
        }
Exemple #4
0
        public static void GenerateFactionsIntoWorldPostFix()
        {
            Log.Message("GeneratingShipTracker");
            ShipTracker shipTracker = (ShipTracker)WorldObjectMaker.MakeWorldObject(ShipNamespaceDefOfs.ShipTracker);

            shipTracker.Tile = TileFinder.RandomStartingTile();
            Find.WorldObjects.Add(shipTracker);
        }
Exemple #5
0
        public static void GenerateFactionsIntoWorldPostFix()
        {
            Log.Message("Generating PlayerFaction Story Tracker");
            PlayerFactionStoryTracker corrTracker = (PlayerFactionStoryTracker)WorldObjectMaker.MakeWorldObject(FactionColorsDefOf.PlayerFactionStoryTracker);

            corrTracker.Tile = TileFinder.RandomStartingTile();
            Find.WorldObjects.Add(corrTracker);
        }
Exemple #6
0
        private static void GenerateMap()
        {
            MapParent mapParent = (MapParent)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement);

            mapParent.Tile = TileFinder.RandomStartingTile();
            mapParent.SetFaction(Faction.OfPlayer);
            Find.WorldObjects.Add(mapParent);
            GetOrGenerateMapUtility.GetOrGenerateMap(mapParent.Tile, new IntVec3(50, 1, 50), null);
        }
        private void DoCustomBottomButtons()
        {
            int              num              = TutorSystem.TutorialMode ? 4 : 5;
            int              num2             = (num < 4 || !((float)UI.screenWidth < 1340f)) ? 1 : 2;
            int              num3             = Mathf.CeilToInt((float)num / (float)num2);
            float            num4             = Page.BottomButSize.x * (float)num3 + 10f * (float)(num3 + 1);
            float            num5             = (float)num2 * Page.BottomButSize.y + 10f * (float)(num2 + 1);
            Rect             rect             = new Rect(((float)UI.screenWidth - num4) / 2f, (float)UI.screenHeight - num5 - 4f, num4, num5);
            WorldInspectPane worldInspectPane = Find.WindowStack.WindowOfType <WorldInspectPane>();

            if (worldInspectPane != null && rect.x < InspectPaneUtility.PaneWidthFor(worldInspectPane) + 4f)
            {
                rect.x = InspectPaneUtility.PaneWidthFor(worldInspectPane) + 4f;
            }
            Widgets.DrawWindowBackground(rect);
            float num6 = rect.xMin + 10f;
            float num7 = rect.yMin + 10f;

            Text.Font = GameFont.Small;
            if (Widgets.ButtonText(new Rect(num6, num7, Page.BottomButSize.x, Page.BottomButSize.y), "Back".Translate()) && CanDoBack())
            {
                DoBack();
            }
            num6 += Page.BottomButSize.x + 10f;
            if (!TutorSystem.TutorialMode)
            {
                if (Widgets.ButtonText(new Rect(num6, num7, Page.BottomButSize.x, Page.BottomButSize.y), "Advanced".Translate()))
                {
                    Find.WindowStack.Add(new Dialog_AdvancedGameConfig(Find.WorldInterface.SelectedTile));
                }
                num6 += Page.BottomButSize.x + 10f;
            }
            if (Widgets.ButtonText(new Rect(num6, num7, Page.BottomButSize.x, Page.BottomButSize.y), "SelectRandomSite".Translate()))
            {
                SoundDefOf.Click.PlayOneShotOnCamera();
                Find.WorldInterface.SelectedTile = TileFinder.RandomStartingTile();
                Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile));
            }
            num6 += Page.BottomButSize.x + 10f;
            if (num2 == 2)
            {
                num6  = rect.xMin + 10f;
                num7 += Page.BottomButSize.y + 10f;
            }
            if (Widgets.ButtonText(new Rect(num6, num7, Page.BottomButSize.x, Page.BottomButSize.y), "WorldFactionsTab".Translate()))
            {
                Find.WindowStack.Add(new Dialog_FactionDuringLanding());
            }
            num6 += Page.BottomButSize.x + 10f;
            if (Widgets.ButtonText(new Rect(num6, num7, Page.BottomButSize.x, Page.BottomButSize.y), "Next".Translate()) && CanDoNext())
            {
                DoNext();
            }
            num6 += Page.BottomButSize.x + 10f;
            GenUI.AbsorbClicksInRect(rect);
        }
Exemple #8
0
        private void DoShipFall()
        {
            ShipMapGenerator generator = ships[Rand.Range(0, ships.Length)];

            int tile = TileFinder.RandomStartingTile();

            ShipCrash_Controller.MakeShipPart(generator, tile, Find.FactionManager.AllFactionsVisible.Where(x => x != Faction.OfPlayer).RandomElement());

            Messages.Message("GameCondition_SpaceBattleTitle".Translate(), MessageTypeDefOf.NeutralEvent, false);
        }
Exemple #9
0
        public void EstablishFarcasterLink()
        {
            mapHome = this.Map;
            Messages.Message("GU_FarcasterActivated".Translate(), MessageTypeDefOf.PositiveEvent);
            FarcasterDestination worldObjectFarcaster = (FarcasterDestination)WorldObjectMaker.MakeWorldObject(DefDatabase <WorldObjectDef> .GetNamed("GU_FarcasterDestinationSigmaAlcyon", true));

            mapParent      = (MapParent)worldObjectFarcaster;
            mapParent.Tile = TileFinder.RandomStartingTile();
            mapParent.SetFaction(Faction.OfPlayer);
            worldObjectFarcaster.mapHome = mapHome;
            worldObjectFarcaster.mapGen  = DefDatabase <MapGeneratorDef> .GetNamed("GU_FarcasterMapSigmaAlcyon", true);

            Find.WorldObjects.Add(mapParent);
            myMap = new Map();

            LongEventHandler.QueueLongEvent(delegate
            {
                myMap = GetOrGenerateMapUtility.GetOrGenerateMap(mapParent.Tile, Find.World.info.initialMapSize, null);
            }, "GU_LinkingWithFarcasters", true, new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap));
            LongEventHandler.QueueLongEvent(delegate
            {
                originalBiome        = myMap.TileInfo.biome;
                originalTile         = mapParent.Tile;
                myMap.TileInfo.biome = DefDatabase <BiomeDef> .GetNamed("GU_SigmaAlcyonIIb", true);
                mapParent.Tile       = base.Tile;

                mapFarcast = myMap;

                //Remote Farcaster portal spawning

                Building_AncientFarcaster building_AncientFarcaster = (Building_AncientFarcaster)ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed("GU_AncientFarcasterPortal", true));
                building_AncientFarcaster.mapHome      = mapHome;
                building_AncientFarcaster.locationHome = this.Position;
                building_AncientFarcaster.SetFaction(Faction.OfPlayer);
                GenSpawn.Spawn(building_AncientFarcaster, myMap.Center, myMap);
                locationFarcast = building_AncientFarcaster.Position;

                //An auxiliary pad too

                Building_Storage building_AncientPad = (Building_Storage)ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed("GU_AncientFarcasterPad", true));
                building_AncientPad.SetFaction(Faction.OfPlayer);
                GenSpawn.Spawn(building_AncientPad, myMap.Center - GenAdj.CardinalDirections[0] * 4, myMap);

                //Farcaster portal spawning ends here
            }, "GU_LinkingWithFarcasters", true, new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap));
        }
        void GenerateCity(WorldObjectDef def, bool abandoned, System.Predicate <Faction> factionFilter = null)
        {
            var city = (City)WorldObjectMaker.MakeWorldObject(def);

            city.SetFaction(GenCity.RandomCityFaction(factionFilter));
            if (!abandoned)
            {
                city.inhabitantFaction = city.Faction;
            }

            city.Tile = TileFinder.RandomSettlementTileFor(city.Faction);
            city.Name = city.ChooseName();
            if (!TileFinder.IsValidTileForNewSettlement(city.Tile))
            {
                // (Faction Control) ensure valid tile for existing saves
                city.Tile = TileFinder.RandomStartingTile();
            }

            Find.WorldObjects.Add(city);
        }
        void GenerateCities(int per100kTiles, bool abandoned)
        {
            int cityCount = GenMath.RoundRandom(Find.WorldGrid.TilesCount / 100000F * per100kTiles);

            for (int i = 0; i < cityCount; i++)
            {
                var city = (City)WorldObjectMaker.MakeWorldObject(DefDatabase <WorldObjectDef> .GetNamed(abandoned ? "City_Abandoned" : "City_Faction"));
                city.SetFaction(GenCity.RandomCityFaction());
                if (!abandoned)
                {
                    city.inhabitantFaction = city.Faction;
                }
                city.Tile = TileFinder.RandomSettlementTileFor(city.Faction);
                city.Name = SettlementNameGenerator.GenerateSettlementName(city);
                if (!TileFinder.IsValidTileForNewSettlement(city.Tile))
                {
                    // (Faction Control) ensure valid tile for existing saves
                    city.Tile = TileFinder.RandomStartingTile();
                }
                Find.WorldObjects.Add(city);
            }
        }
Exemple #12
0
        private void DoCustomBottomButtons()
        {
            int              num              = (!TutorSystem.TutorialMode) ? 5 : 4;
            int              num2             = (num < 4 || !((float)UI.screenWidth < 1340f)) ? 1 : 2;
            int              num3             = Mathf.CeilToInt((float)num / (float)num2);
            Vector2          bottomButSize    = Page.BottomButSize;
            float            num4             = bottomButSize.x * (float)num3 + 10f * (float)(num3 + 1);
            float            num5             = (float)num2;
            Vector2          bottomButSize2   = Page.BottomButSize;
            float            num6             = num5 * bottomButSize2.y + 10f * (float)(num2 + 1);
            Rect             rect             = new Rect(((float)UI.screenWidth - num4) / 2f, (float)UI.screenHeight - num6 - 4f, num4, num6);
            WorldInspectPane worldInspectPane = Find.WindowStack.WindowOfType <WorldInspectPane>();

            if (worldInspectPane != null && rect.x < InspectPaneUtility.PaneWidthFor(worldInspectPane) + 4f)
            {
                rect.x = InspectPaneUtility.PaneWidthFor(worldInspectPane) + 4f;
            }
            Widgets.DrawWindowBackground(rect);
            float num7 = rect.xMin + 10f;
            float num8 = rect.yMin + 10f;

            Text.Font = GameFont.Small;
            float   x = num7;
            float   y = num8;
            Vector2 bottomButSize3 = Page.BottomButSize;
            float   x2             = bottomButSize3.x;
            Vector2 bottomButSize4 = Page.BottomButSize;

            if (Widgets.ButtonText(new Rect(x, y, x2, bottomButSize4.y), "Back".Translate()) && CanDoBack())
            {
                DoBack();
            }
            float   num9           = num7;
            Vector2 bottomButSize5 = Page.BottomButSize;

            num7 = num9 + (bottomButSize5.x + 10f);
            if (!TutorSystem.TutorialMode)
            {
                float   x3             = num7;
                float   y2             = num8;
                Vector2 bottomButSize6 = Page.BottomButSize;
                float   x4             = bottomButSize6.x;
                Vector2 bottomButSize7 = Page.BottomButSize;
                if (Widgets.ButtonText(new Rect(x3, y2, x4, bottomButSize7.y), "Advanced".Translate()))
                {
                    Find.WindowStack.Add(new Dialog_AdvancedGameConfig(Find.WorldInterface.SelectedTile));
                }
                float   num10          = num7;
                Vector2 bottomButSize8 = Page.BottomButSize;
                num7 = num10 + (bottomButSize8.x + 10f);
            }
            float   x5              = num7;
            float   y3              = num8;
            Vector2 bottomButSize9  = Page.BottomButSize;
            float   x6              = bottomButSize9.x;
            Vector2 bottomButSize10 = Page.BottomButSize;

            if (Widgets.ButtonText(new Rect(x5, y3, x6, bottomButSize10.y), "SelectRandomSite".Translate()))
            {
                SoundDefOf.Click.PlayOneShotOnCamera();
                Find.WorldInterface.SelectedTile = TileFinder.RandomStartingTile();
                Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile));
            }
            float   num11           = num7;
            Vector2 bottomButSize11 = Page.BottomButSize;

            num7 = num11 + (bottomButSize11.x + 10f);
            if (num2 == 2)
            {
                num7 = rect.xMin + 10f;
                float   num12           = num8;
                Vector2 bottomButSize12 = Page.BottomButSize;
                num8 = num12 + (bottomButSize12.y + 10f);
            }
            float   x7 = num7;
            float   y4 = num8;
            Vector2 bottomButSize13 = Page.BottomButSize;
            float   x8 = bottomButSize13.x;
            Vector2 bottomButSize14 = Page.BottomButSize;

            if (Widgets.ButtonText(new Rect(x7, y4, x8, bottomButSize14.y), "WorldFactionsTab".Translate()))
            {
                Find.WindowStack.Add(new Dialog_FactionDuringLanding());
            }
            float   num13           = num7;
            Vector2 bottomButSize15 = Page.BottomButSize;

            num7 = num13 + (bottomButSize15.x + 10f);
            float   x9 = num7;
            float   y5 = num8;
            Vector2 bottomButSize16 = Page.BottomButSize;
            float   x10             = bottomButSize16.x;
            Vector2 bottomButSize17 = Page.BottomButSize;

            if (Widgets.ButtonText(new Rect(x9, y5, x10, bottomButSize17.y), "Next".Translate()) && CanDoNext())
            {
                DoNext();
            }
            float   num14           = num7;
            Vector2 bottomButSize18 = Page.BottomButSize;

            num7 = num14 + (bottomButSize18.x + 10f);
            GenUI.AbsorbClicksInRect(rect);
        }
Exemple #13
0
        // Expansion
        private bool doExpansion()
        {
            int tile = TileFinder.RandomStartingTile();

            if (!TileFinder.IsValidTileForNewSettlement(tile))
            {
                return(false);
            }
            List <Settlement> settlements = Find.WorldObjects.Settlements.ToList <Settlement>();

            if (settlements.Count > IncidentWorker_NPCExpansion.maxExpansionLimit)
            {
                return(false);
            }
            List <Settlement> candidateSettlements = new List <Settlement>();

            for (int i = 0; i < settlements.Count; i++)
            {
                Settlement SettlerCandidateBase = settlements[i];
                if (SettlerCandidateBase.Faction.IsPlayer || SettlerCandidateBase.Faction.def.settlementGenerationWeight == 0f)
                {
                }
                else
                {
                    if (Find.WorldGrid.TraversalDistanceBetween(tile, SettlerCandidateBase.Tile, true) <= IncidentWorker_NPCExpansion.expansionRadius)
                    {
                        candidateSettlements.Add(SettlerCandidateBase);
                    }
                }
            }

            Settlement SettlerBase;

            if (candidateSettlements.Count != 0)
            {
                SettlerBase = candidateSettlements.RandomElement <Settlement>();
            }
            else
            {
                // fail due to no valid candidate with supply line
                return(false);
            }

            Settlement settlement = (Settlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement);

            settlement.SetFaction(SettlerBase.Faction);
            bool flag3 = settlement.Faction == null;

            if (flag3)
            {
                return(false);
            }
            else
            {
                settlement.Tile = tile;
                settlement.Name = SettlementNameGenerator.GenerateSettlementName(settlement, null);
                Find.WorldObjects.Add(settlement);
            }

            return(true);
        }
        public static void Postfix()
        {
            if (!WorldGenerator_GenerateFromScribe.IsGeneratingWorld)
            {
                return;
            }
            // tell tile finder to use our data - this is done before we can re-obtain settlement tiles
            TileFinder_RandomSettlementTileFor.FirstSettlementLocations     = WorldGenerator_GenerateFromScribe.FirstSettlementLocation;
            TileFinder_IsValidTileForNewSettlement.FirstSettlementLocations = WorldGenerator_GenerateFromScribe.FirstSettlementLocation;
            TileFinder_IsValidTileForNewSettlement.FDs = WorldGenerator_GenerateFromScribe.FDs;

            // set 'first' settlements
            foreach (var s in Find.WorldObjects.Settlements)
            {
                if (!WorldGenerator_GenerateFromScribe.AddedSettlements.Contains(s) && s.Faction != null && s.Faction.Name != null &&
                    !WorldGenerator_GenerateFromScribe.FirstSettlementLocation.ContainsKey(s.Faction.Name))
                {
                    WorldGenerator_GenerateFromScribe.FirstSettlementLocation[s.Faction.Name] = s.Tile;
                }
            }
            // now randomize settlement positions based on mod logic
            foreach (var s in WorldGenerator_GenerateFromScribe.AddedSettlements)
            {
                s.Tile = s.Faction != null?TileFinder.RandomSettlementTileFor(s.Faction) : TileFinder.RandomStartingTile();
            }

            // now we can clear stuff we won't use until a save is loaded the next time
            WorldGenerator_GenerateFromScribe.AddedSettlements.Clear();
            WorldGenerator_GenerateFromScribe.IsGeneratingWorld = false;
        }
        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 #16
0
 public void ChooseRandomStartingTile()
 {
     startingTile = TileFinder.RandomStartingTile();
 }
Exemple #17
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!enableExpansion)
            {
                return(false);
            }

            int tile = TileFinder.RandomStartingTile();

            if (!TileFinder.IsValidTileForNewSettlement(tile))
            {
                return(false);
            }
            List <Settlement> settlements = Find.WorldObjects.Settlements.ToList <Settlement>();

            if (settlements.Count > maxExpansionLimit)
            {
                Log.Message("current settlememt count of " + settlements.Count.ToString() + " greater than max expansion limit of " + maxExpansionLimit.ToString());
                return(false);
            }
            List <Settlement> candidateSettlements = new List <Settlement>();

            for (int i = 0; i < settlements.Count; i++)
            {
                Settlement SettlerCandidateBase = settlements[i];
                if (SettlerCandidateBase.Faction.IsPlayer || SettlerCandidateBase.Faction.def.settlementGenerationWeight == 0f)
                {
                }
                else
                {
                    if (Find.WorldGrid.TraversalDistanceBetween(tile, SettlerCandidateBase.Tile, true) <= expansionRadius)
                    {
                        candidateSettlements.Add(SettlerCandidateBase);
                    }
                }
            }

            Settlement SettlerBase;

            if (candidateSettlements.Count != 0)
            {
                SettlerBase = candidateSettlements.RandomElement <Settlement>();
            }
            else
            {
                // fail due to no valid candidate with supply line
                return(false);
            }

            Settlement settlement = (Settlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement);

            settlement.SetFaction(SettlerBase.Faction);
            bool flag3 = settlement.Faction == null;

            if (flag3)
            {
                return(false);
            }
            else
            {
                settlement.Tile = tile;
                settlement.Name = SettlementNameGenerator.GenerateSettlementName(settlement, null);
                Find.WorldObjects.Add(settlement);
                Find.LetterStack.ReceiveLetter("LabelExpansion".Translate(), "DescExpansion".Translate(SettlerBase.Faction.Name, SettlerBase.Name, settlement.Name), LetterDefOf.NeutralEvent, settlement, null, null);
                ExpandableWorldObjectsUtility.ExpandableWorldObjectsUpdate();
            }

            return(true);
        }
        public void InitPlaces()
        {
            List <RandomPlaceDef> allPlaces = DefDatabase <RandomPlaceDef> .AllDefsListForReading;

            Triggers.Clear();

            for (int i = 0; i < allPlaces.Count; i++)
            {
                RandomPlaceDef randomPlaceDef = allPlaces[i];

                int spawnedCount = 0;
                int minToStart   = randomPlaceDef.MinStartScale == null ? randomPlaceDef.MinAtStart : (int)randomPlaceDef.MinStartScale.Evaluate(Find.World.PlanetCoverage);
                int maxSpawn     = randomPlaceDef.MaxSpawnScale == null ? randomPlaceDef.MaxSpawn : (int)randomPlaceDef.MaxSpawnScale.Evaluate(Find.World.PlanetCoverage);

                for (int i3 = 0; i3 < minToStart; i3++)
                {
                    int tile = TileFinder.RandomStartingTile();

                    if (Triggers.ContainsKey(tile))
                    {
                        continue;
                    }

                    if (randomPlaceDef.Worker == null || randomPlaceDef.Worker.CanPlace(tile))
                    {
                        TryGetFaction(randomPlaceDef.FactionType, out Faction faction);
                        Triggers.Add(tile, MakeTrigger(tile, randomPlaceDef, faction));
                        spawnedCount++;
                    }
                }

                if (spawnedCount >= maxSpawn)
                {
                    continue;
                }

                for (int i4 = 0; i4 < maxSpawn - spawnedCount; i4++)
                {
                    if (Rand.Chance(randomPlaceDef.Commonality))
                    {
                        int tile = TileFinder.RandomStartingTile();

                        if (Triggers.ContainsKey(tile))
                        {
                            continue;
                        }

                        if (randomPlaceDef.Worker == null || randomPlaceDef.Worker.CanPlace(tile))
                        {
                            TryGetFaction(randomPlaceDef.FactionType, out Faction faction);
                            Triggers.Add(tile, MakeTrigger(tile, randomPlaceDef, faction));
                        }
                    }
                }
            }

            if (Prefs.DevMode)
            {
                Log.Message($"TOTAL: {Triggers.Count}");
            }
        }
Exemple #19
0
        /// <summary>
        ///     This is a rip of the DoCustomButtons() function in RimWorld.Page_SelectLandingSite with a new button.
        /// </summary>
        public void DoCustomButtons()
        {
            // HACK : changed the number of buttons from '5 : 4' to '6 : 5' as we add a button
            var num = !TutorSystem.TutorialMode ? 6 : 5;
            int num2;

            if (num >= 4 && UI.screenWidth < 1340f)
            {
                num2 = 2;
            }
            else
            {
                num2 = 1;
            }
            var num3 = Mathf.CeilToInt(num / (float)num2);
            var num4 = BottomButSize.x * num3 + 10f * (num3 + 1);
            var num5 = num2 * BottomButSize.y + 10f * (num2 + 1);
            var rect = new Rect((UI.screenWidth - num4) / 2f, UI.screenHeight - num5 - 4f, num4, num5);

            if (Find.WindowStack.IsOpen <WorldInspectPane>() && rect.x < InspectPaneUtility.PaneSize.x + 4f)
            {
                rect.x = InspectPaneUtility.PaneSize.x + 4f;
            }
            Widgets.DrawWindowBackground(rect);
            var num6 = rect.xMin + 10f;
            var num7 = rect.yMin + 10f;

            Text.Font = GameFont.Small;
            if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "Back".Translate()) &&
                CanDoBack())
            {
                /* ADDED CODE */

                #region INSERTED_CODE

                // make sure the prepare landing window (or its minimized window) is closed when we go back
                if (Find.WindowStack.IsOpen <MainWindow>() || Find.WindowStack.IsOpen <MinimizedWindow>())
                {
                    if (PrepareLanding.Instance.MainWindow != null)
                    {
                        PrepareLanding.Instance.MainWindow.ForceClose();
                    }
                }

                #endregion

                /* END ADDED CODE*/

                DoBack();
            }
            num6 += BottomButSize.x + 10f;
            if (!TutorSystem.TutorialMode)
            {
                if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "Advanced".Translate()))
                {
                    Find.WindowStack.Add(new Dialog_AdvancedGameConfig(Find.WorldInterface.SelectedTile));
                }
                num6 += BottomButSize.x + 10f;
            }
            if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y),
                                   "SelectRandomSite".Translate()))
            {
                SoundDefOf.Click.PlayOneShotOnCamera();
                Find.WorldInterface.SelectedTile = TileFinder.RandomStartingTile();
                Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile));
            }
            num6 += BottomButSize.x + 10f;
            if (num2 == 2)
            {
                num6  = rect.xMin + 10f;
                num7 += BottomButSize.y + 10f;
            }
            if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y),
                                   "WorldFactionsTab".Translate()))
            {
                Find.WindowStack.Add(new Dialog_FactionDuringLanding());
            }
            num6 += BottomButSize.x + 10f;

            /* inserted button code */

            #region INSERTED_CODE

            if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "Prepare Landing"))
            {
                Log.Message("[PrepareLanding] Page button pressed!");

                // don't add a new window if the window is already there
                if (PrepareLanding.Instance.MainWindow == null)
                {
                    PrepareLanding.Instance.MainWindow = new MainWindow(PrepareLanding.Instance.UserData);
                }

                PrepareLanding.Instance.MainWindow.Show();
            }
            num6 += BottomButSize.x + 10f;

            #endregion INSERTED_CODE

            /* end of inserted code */

            if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "Next".Translate()) &&
                CanDoNext())
            {
                /* ADDED CODE */

                #region INSERTED_CODE

                // make sure the prepare landing window (or its minimized window) is closed when we go to the next window / game stage
                if (Find.WindowStack.IsOpen <MainWindow>() || Find.WindowStack.IsOpen <MinimizedWindow>())
                {
                    if (PrepareLanding.Instance.MainWindow != null)
                    {
                        PrepareLanding.Instance.MainWindow.ForceClose();
                    }
                }

                #endregion

                /* END ADDED CODE*/

                // go to next window
                DoNext();
            }

            //num6 += BottomButSize.x + 10f;
            GenUI.AbsorbClicksInRect(rect);
        }