Add fake sectors to black hole forge

This should finish up the PR.
This commit is contained in:
Moonstone Studios 2023-12-21 19:52:29 -08:00
parent 923243d102
commit f68dca026c
No known key found for this signature in database
GPG Key ID: 049449FDBA649F3E
2 changed files with 47 additions and 17 deletions

View File

@ -1,5 +1,6 @@
using HarmonyLib;
using QSB.Patches;
using QSB.Utility;
using UnityEngine;
namespace QSB.ElevatorSync.Patches;
@ -14,6 +15,8 @@ public class NomaiElevatorPatches : QSBPatch
private static NomaiElevator blackHoleForgeEntrance;
private static OWTriggerVolume blackHoleForgeEntranceTrigger;
private static bool runOnce;
[HarmonyPostfix]
[HarmonyPatch(typeof(NomaiElevator), nameof(NomaiElevator.FixedUpdate))]
public static void NomaiElevator_FixedUpdate(NomaiElevator __instance)
@ -34,23 +37,8 @@ public class NomaiElevatorPatches : QSBPatch
if (!blackHoleForgeEntrance || !blackHoleForgeEntranceTrigger)
{
blackHoleForgeEntrance = GameObject.Find("BlackHoleForge_EntrancePivot").GetComponent<NomaiElevator>();
// Use a built-in trigger and alter it.
var baseTrigger = GameObject.Find("BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/" +
"Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_BlackHoleForge/" +
"BlackHoleForgePivot/Interactables_BlackHoleForge/BlackHoleForge_EntrancePivot/" +
"Geometry_BlackHoleForge_Entrance/GravityVolume (20)");
var newTrigger = Object.Instantiate(baseTrigger, baseTrigger.transform.parent);
blackHoleForgeEntranceTrigger = newTrigger.GetComponent<OWTriggerVolume>();
// Make a new box and move it so that the entrance trigger is aligned with the entrance better.
// This prevents the player from moving with the entrance when they aren't in it
// because the base shape is too far up.
var box = (BoxShape)blackHoleForgeEntranceTrigger._shape;
// The shape is rotated so we dont use Y.
box.center = new Vector3(-1.85f, 0f, 0f);
box.enabled = true;
blackHoleForgeEntranceTrigger = GameObject.Find("FakeSector_BlackHoleForge_EntrancePivot")
.GetComponent<OWTriggerVolume>();
}
var speed = blackHoleForge._speed;
@ -73,5 +61,17 @@ public class NomaiElevatorPatches : QSBPatch
var newPos = Locator.GetPlayerTransform().position + new Vector3(0f, speed * Time.deltaTime, 0f);
Locator.GetPlayerTransform().position = newPos;
}
if (!runOnce)
{
// Recenter the universe because the player has been manually moved.
runOnce = true;
Delay.RunWhen(() => !__instance.enabled, () =>
{
runOnce = false;
CenterOfTheUniverse.s_instance.OnPlayerRepositioned();
});
}
}
}

View File

@ -153,6 +153,36 @@ public class QSBSectorManager : WorldObjectManager
});
}
//black hole forge
{
var forge = GameObject.Find("BlackHoleForgePivot");
FakeSector.Create(forge,
forge.GetComponentInParent<Sector>(),
x =>
{
var trigger = x.gameObject.AddComponent<OWTriggerVolume>();
x._triggerRoot = GameObject.Find("BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/" +
"Sector_HangingCity/Sector_HangingCity_BlackHoleForge/BlackHoleForgePivot/" +
"Volumes_BlackHoleForge/DirectionalForceVolume");
});
}
// black hole forge entrance elevator
{
var entrance = GameObject.Find("BlackHoleForge_EntrancePivot");
var sector = GameObject.Find("Sector_HangingCity_BlackHoleForge").GetComponent<Sector>();
FakeSector.Create(entrance,
sector,
x =>
{
x.gameObject.AddComponent<OWTriggerVolume>();
var shape = x.gameObject.AddComponent<BoxShape>();
shape.size = new Vector3(5.5f, 5.8f, 5.5f);
shape.center = new Vector3(0f, 2.9f, 1.5f);
});
}
// OPC probe
{
var probe = Locator._orbitalProbeCannon