From 24cd9f81adf201718e3fe5797a26b69b06f598ee Mon Sep 17 00:00:00 2001 From: user Date: Tue, 7 Jan 2025 19:27:52 +0300 Subject: [PATCH] Added dev: launch to world tile command --- Source/1.5/Building/Building_ShipBridge.cs | 47 ++++++++++++++++++++++ Source/1.5/ShipInteriorMod2.cs | 12 +++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/Source/1.5/Building/Building_ShipBridge.cs b/Source/1.5/Building/Building_ShipBridge.cs index e15c7f95..b7625174 100644 --- a/Source/1.5/Building/Building_ShipBridge.cs +++ b/Source/1.5/Building/Building_ShipBridge.cs @@ -97,6 +97,24 @@ private List InterstellarFailReasons() return result; } + public bool DevChooseLaunchTarget(GlobalTargetInfo target) + { + if (Find.World.Impassable(target.Tile)) + { + return false; + } + if (Find.WorldObjects.AnyWorldObjectAt(target.Tile)) + { + return false; + } + if (CanLaunchNow) + { + ShipInteriorMod2.worldTileOverride = target.Tile; + ShipCountdown.InitiateCountdown(this); + QuestUtility.SendQuestTargetSignals(base.Map.Parent.questTags, "LaunchedShip"); + } + return true; + } [DebuggerHidden] public override IEnumerable GetGizmos() { @@ -1024,7 +1042,10 @@ public override IEnumerable GetGizmos() if (playerShipMap != null) //player ship in orbit already, move to temp map Ship.CreateShipSketchIfFuelPct(1f, playerShipMap, 0, true); else + { + ShipInteriorMod2.worldTileOverride = -1; ShipCountdown.InitiateCountdown(this); + } QuestUtility.SendQuestTargetSignals(base.Map.Parent.questTags, "LaunchedShip"); } }, @@ -1042,6 +1063,32 @@ public override IEnumerable GetGizmos() launch.Disable(null); } yield return launch; + if (Prefs.DevMode && ShipInteriorMod2.FindPlayerShipMap() == null) + { + Command_Action launchToSpecificTile = new Command_Action() + { + groupable = false, + action = delegate + { + CameraJumper.TryJump(CameraJumper.GetWorldTarget(this)); + Find.WorldSelector.ClearSelection(); + Find.WorldTargeter.BeginTargeting(DevChooseLaunchTarget, canTargetTiles: true, closeWorldTabWhenFinished: true); + }, + hotKey = KeyBindingDefOf.Misc1, + defaultLabel = "Dev: Launch to specific tile", + defaultDesc = "Pick a surface tile that will be associated with the ship. Based on selected tile latitude, solar panels will work great or bad. " + + "Quests and Ideology work sites will be genarated near picked surface tile." + }; + if (!CanLaunchNow) + { + launchToSpecificTile.Disable(ShipUtility.LaunchFailReasons(this).First()); + } + else if (ShipCountdown.CountingDown) + { + launchToSpecificTile.Disable(null); + } + yield return launchToSpecificTile; + } } } private bool ChoseWorldTarget(GlobalTargetInfo target) diff --git a/Source/1.5/ShipInteriorMod2.cs b/Source/1.5/ShipInteriorMod2.cs index c9b6ae42..206deac8 100644 --- a/Source/1.5/ShipInteriorMod2.cs +++ b/Source/1.5/ShipInteriorMod2.cs @@ -507,6 +507,9 @@ public static int FindWorldTile() } return -1; } + + // Can override world tile selection in dev Launch sommmand, launching ship over specified tile + public static int worldTileOverride = -1; public static int FindWorldTilePlayer() //slower, will find tile nearest to ship object pos { float bestAbsLatitude = float.MaxValue; @@ -539,7 +542,14 @@ public static Map GeneratePlayerShipMap(IntVec3 size) WorldObjectOrbitingShip orbiter = (WorldObjectOrbitingShip)WorldObjectMaker.MakeWorldObject(ResourceBank.WorldObjectDefOf.ShipOrbiting); orbiter.SetNominalPos(); orbiter.SetFaction(Faction.OfPlayer); - orbiter.Tile = FindWorldTilePlayer(); + if (worldTileOverride == -1) + { + orbiter.Tile = FindWorldTilePlayer(); + } + else + { + orbiter.Tile = worldTileOverride; + } Find.WorldObjects.Add(orbiter); Map map = MapGenerator.GenerateMap(size, orbiter, orbiter.MapGeneratorDef,null,null,false); //map.fogGrid.ClearAllFog();