|
| 1 | +using HarmonyLib; |
| 2 | +using SFS.World; |
| 3 | +using SFS; |
| 4 | +using SFS.WorldBase; |
| 5 | +using UnityEngine; |
| 6 | +using SFS.Parts.Modules; |
| 7 | + |
| 8 | +[HarmonyPatch(typeof(SpaceCenter), "Start")] |
| 9 | +class SpaceCenterPatcher |
| 10 | +{ |
| 11 | + [HarmonyPostfix] |
| 12 | + public static void Postfix(SpaceCenter __instance) |
| 13 | + { |
| 14 | + __instance.vab.building.gameObject.SetActive(false); |
| 15 | + __instance.launchPad.building.gameObject.SetActive(false); |
| 16 | + |
| 17 | + |
| 18 | + SpaceCenterData spaceCenter = Base.planetLoader.spaceCenter; |
| 19 | + |
| 20 | + // VAB building |
| 21 | + GameObject vabGameObject = GameObject.Instantiate(BRPack.Main.vab.building.gameObject); |
| 22 | + vabGameObject.transform.parent = __instance.transform; |
| 23 | + vabGameObject.SetActive(true); |
| 24 | + |
| 25 | + BuildingUtil.AddBuildingToWorld(vabGameObject, spaceCenter.address.GetPlanet(), spaceCenter.LaunchPadLocation.position + new Double2(-750.0, -9.0)); |
| 26 | + foreach (I_InitializePartModule initialize in vabGameObject.GetComponentsInChildren<I_InitializePartModule>()) |
| 27 | + { |
| 28 | + initialize.Initialize(); |
| 29 | + } |
| 30 | + foreach (BaseMesh mesh in vabGameObject.GetComponentsInChildren<BaseMesh>()) |
| 31 | + { |
| 32 | + mesh.GenerateMesh(); |
| 33 | + } |
| 34 | + |
| 35 | + WorldLocation vabLocation = vabGameObject.GetComponent<WorldLocation>(); |
| 36 | + __instance.vab.building.location.position.Value = vabLocation.position.Value + new Double2(80,0); |
| 37 | + |
| 38 | + |
| 39 | + // Launch pad building |
| 40 | + GameObject launchPadGameObject = GameObject.Instantiate(BRPack.Main.launchPad.building.gameObject); |
| 41 | + launchPadGameObject.transform.parent = __instance.transform; |
| 42 | + launchPadGameObject.SetActive(true); |
| 43 | + |
| 44 | + BuildingUtil.AddBuildingToWorld(launchPadGameObject, spaceCenter.address.GetPlanet(), spaceCenter.LaunchPadLocation.position + new Double2(-130, -10.0)); |
| 45 | + foreach (I_InitializePartModule initialize in launchPadGameObject.GetComponentsInChildren<I_InitializePartModule>()) |
| 46 | + { |
| 47 | + initialize.Initialize(); |
| 48 | + } |
| 49 | + foreach (BaseMesh mesh in launchPadGameObject.GetComponentsInChildren<BaseMesh>()) |
| 50 | + { |
| 51 | + mesh.GenerateMesh(); |
| 52 | + } |
| 53 | + |
| 54 | + } |
| 55 | +} |
| 56 | + |
0 commit comments