Janky eye warp

This commit is contained in:
Nick 2022-03-08 03:02:36 -05:00
parent 02a3048720
commit 6ba4a217c8
4 changed files with 67 additions and 2 deletions

View File

@ -51,7 +51,7 @@ namespace NewHorizons.Components
GlobalMessenger<OWRigidbody>.AddListener("EnterFlightConsole", new Callback<OWRigidbody>(OnEnterFlightConsole));
_nextCardIndex = 0;
foreach (var starSystem in Main.BodyDict.Keys)
foreach (var starSystem in Main.SystemDict.Keys)
{
// Get rid of the warp option for the current system
if (starSystem == Main.Instance.CurrentStarSystem) continue;
@ -70,6 +70,15 @@ namespace NewHorizons.Components
AddSystemCard(starSystem);
}
}
AddSystemCard("EyeOfTheUniverse");
/* Ship log manager isnt initiatiized yet
if(Locator.GetShipLogManager().IsFactRevealed("OPC_EYE_COORDINATES_X1"))
{
AddSystemCard("EyeOfTheUniverse");
}
*/
}
public void AddSystemCard(string starSystem)

View File

@ -58,6 +58,8 @@ namespace NewHorizons
private bool _firstLoad = true;
private ShipWarpController _shipWarpController;
private GameObject _ship;
public override object GetApi()
{
return new NewHorizonsApi();
@ -95,6 +97,7 @@ namespace NewHorizons
GlobalMessenger.AddListener("WakeUp", new Callback(OnWakeUp));
ShaderBundle = Main.Instance.ModHelper.Assets.LoadBundle("AssetBundle/shader");
BodyDict["SolarSystem"] = new List<NewHorizonsBody>();
BodyDict["EyeOfTheUniverse"] = new List<NewHorizonsBody>(); // Keep this empty tho fr
SystemDict["SolarSystem"] = new NewHorizonsSystem("SolarSystem", new StarSystemConfig(null), this);
Tools.Patches.Apply();
@ -191,6 +194,27 @@ namespace NewHorizons
TitleSceneHandler.DisplayBodyOnTitleScreen(BodyDict.Values.ToList().SelectMany(x => x).ToList());
}
if(scene.name == "EyeOfTheUniverse" && IsWarping)
{
if(_ship != null) SceneManager.MoveGameObjectToScene(_ship, SceneManager.GetActiveScene());
// Don't do this for now
IsWarping = false;
Instance.ModHelper.Events.Unity.RunWhen(
() => GameObject.Find("Ship_Body") != null && GameObject.Find("Player_Body") != null,
() => _ship.transform.position = GameObject.Find("Player_Body").transform.position
);
Instance.ModHelper.Events.Unity.RunWhen(
() => Locator.GetDeathManager() != null && Locator.GetPlayerTransform() != null,
() => {
Locator.GetDeathManager()._invincible = true;
Locator.GetPlayerTransform().GetComponent<PlayerResources>()._invincible = true;
});
_ship = null;
}
if(scene.name == "SolarSystem")
{
IsSystemReady = false;
@ -348,7 +372,19 @@ namespace NewHorizons
// We kill them so they don't move as much
Locator.GetDeathManager().KillPlayer(DeathType.Meditation);
LoadManager.LoadSceneAsync(OWScene.SolarSystem, true, LoadManager.FadeType.ToBlack, 0.1f, true);
if(newStarSystem == "EyeOfTheUniverse")
{
// Else it drops us in the observator
PlayerData.SaveWarpedToTheEye(60);
// This is jank look out
_ship = Locator.GetShipBody().gameObject;
DontDestroyOnLoad(_ship);
LoadManager.LoadSceneAsync(OWScene.EyeOfTheUniverse, true, LoadManager.FadeType.ToBlack, 0.1f, true);
}
else
{
LoadManager.LoadSceneAsync(OWScene.SolarSystem, true, LoadManager.FadeType.ToBlack, 0.1f, true);
}
}
void OnDeath(DeathType _)

View File

@ -59,6 +59,8 @@ namespace NewHorizons.Tools
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<PlayerSpawner>("SpawnPlayer", typeof(Patches), nameof(Patches.OnPlayerSpawnerSpawnPlayerPreFix));
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<DeathManager>("KillPlayer", typeof(Patches), nameof(Patches.OnDeathManagerKillPlayer));
// Postfixes
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<MapController>("Awake", typeof(Patches), nameof(Patches.OnMapControllerAwake));
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<MapController>("OnTargetReferenceFrame", typeof(Patches), nameof(Patches.OnMapControllerOnTargetReferenceFrame));
@ -360,5 +362,10 @@ namespace NewHorizons.Tools
Logger.Log("Player spawning");
__instance.SetInitialSpawnPoint(Main.SystemDict[Main.Instance.CurrentStarSystem].SpawnPoint);
}
public static bool OnDeathManagerKillPlayer()
{
return (Main.Instance.CurrentStarSystem != "EyeOfTheUniverse");
}
}
}

View File

@ -104,5 +104,18 @@ namespace NewHorizons.Utility
"$1 $2"
);
}
public static GameObject InstantiateInactive(this GameObject original)
{
if (!original.activeSelf)
{
return UnityEngine.Object.Instantiate(original);
}
original.SetActive(false);
var copy = UnityEngine.Object.Instantiate(original);
original.SetActive(true);
return copy;
}
}
}