Some black holes still dont work

This commit is contained in:
Nick J. Connors 2022-01-08 21:01:08 -05:00
parent 31bf3b508d
commit 5af24599a8
5 changed files with 61 additions and 39 deletions

View File

@ -12,7 +12,7 @@ namespace NewHorizons.Builder.General
public static SpawnPoint Make(GameObject body, SpawnModule module, OWRigidbody rb)
{
SpawnPoint playerSpawn = null;
if(!Main.IsWarping && module.PlayerSpawnPoint != null)
if(!Main.Instance.IsWarping && module.PlayerSpawnPoint != null)
{
GameObject spawnGO = new GameObject("PlayerSpawnPoint");
spawnGO.transform.parent = body.transform;
@ -45,7 +45,7 @@ namespace NewHorizons.Builder.General
ship.GetRequiredComponent<MatchInitialMotion>().SetBodyToMatch(rb);
if(Main.IsWarping)
if(Main.Instance.IsWarping)
{
Logger.Log("Overriding player spawn to be inside ship");
GameObject playerSpawnGO = new GameObject("PlayerSpawnPoint");
@ -60,7 +60,7 @@ namespace NewHorizons.Builder.General
GameObject.FindObjectOfType<PlayerSpawner>().SetInitialSpawnPoint(playerSpawn);
}
}
if(!Main.IsWarping && module.StartWithSuit && !suitUpQueued)
if(!Main.Instance.IsWarping && module.StartWithSuit && !suitUpQueued)
{
suitUpQueued = true;
Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => SuitUp(), 4);

View File

@ -16,10 +16,15 @@ namespace NewHorizons.Components
_deathType = DeathType.Meditation;
}
public override void VanishShip(OWRigidbody shipBody, RelativeLocationData entryLocation)
{
if(PlayerState.IsInsideShip()) Main.Instance.ChangeCurrentStarSystem(TargetSolarSystem, true);
}
public override void VanishPlayer(OWRigidbody playerBody, RelativeLocationData entryLocation)
{
//Main.Instance.ChangeCurrentStarSystem(TargetSolarSystem, PlayerState.AtFlightConsole());
Main.Instance.ChangeCurrentStarSystem(TargetSolarSystem, false);
Main.Instance.ChangeCurrentStarSystem(TargetSolarSystem, PlayerState.AtFlightConsole());
//Main.Instance.ChangeCurrentStarSystem(TargetSolarSystem, false);
}
}
}

View File

@ -94,7 +94,11 @@ namespace NewHorizons.Components
}
var newCard = GameObject.Instantiate(_cardTemplate, parent);
newCard.transform.Find("EntryCardRoot/NameBackground/Name").GetComponent<UnityEngine.UI.Text>().text = UniqueNameToString(uniqueName);
var textComponent = newCard.transform.Find("EntryCardRoot/NameBackground/Name").GetComponent<UnityEngine.UI.Text>();
var name = UniqueNameToString(uniqueName);
textComponent.text = name;
if (name.Length > 17) textComponent.fontSize = 10;
newCard.SetActive(true);
newCard.transform.name = uniqueName;
newCard.transform.localPosition = new Vector3(position.x, position.y, 40);

View File

@ -6,6 +6,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Components
{
@ -28,11 +29,18 @@ namespace NewHorizons.Components
MakeBlackHole();
MakeWhiteHole();
_isWarpingIn = false;
_oneShotSource = base.gameObject.AddComponent<OWAudioSource>();
GlobalMessenger.AddListener("FinishOpenEyes", new Callback(OnFinishOpenEyes));
}
public void OnDestroy()
{
GlobalMessenger.RemoveListener("FinishOpenEyes", new Callback(OnFinishOpenEyes));
}
private void MakeBlackHole()
{
var blackHoleShader = GameObject.Find("TowerTwin_Body/Sector_TowerTwin/Sector_Tower_HGT/Interactables_Tower_HGT/Interactables_Tower_TT/Prefab_NOM_WarpTransmitter (1)/BlackHole/BlackHoleSingularity").GetComponent<MeshRenderer>().material.shader;
@ -81,13 +89,9 @@ namespace NewHorizons.Components
whiteHoleRenderer.SetActive(true);
}
public void OnDestroy()
{
GlobalMessenger.RemoveListener("FinishOpenEyes", new Callback(OnFinishOpenEyes));
}
public void WarpIn()
{
Logger.Log("Starting warp-in");
// Trying really hard to stop the player from dying while warping in
_impactDeathSpeed = Locator.GetDeathManager()._impactDeathSpeed;
Locator.GetDeathManager()._impactDeathSpeed = Mathf.Infinity;
@ -99,6 +103,7 @@ namespace NewHorizons.Components
public void WarpOut()
{
Logger.Log("Starting warp-out");
_oneShotSource.PlayOneShot(global::AudioType.VesselSingularityCreate, 1f);
_blackhole.Create();
}
@ -107,37 +112,28 @@ namespace NewHorizons.Components
{
if(_isWarpingIn && LateInitializerManager.isDoneInitializing)
{
_oneShotSource.PlayOneShot(global::AudioType.VesselSingularityCollapse, 1f);
Locator.GetDeathManager()._invincible = true;
if (Main.Instance.CurrentStarSystem.Equals("SolarSystem")) Teleportation.teleportPlayerToShip();
_whitehole.Create();
Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => StartWarpInEffect(), 1);
_isWarpingIn = false;
_waitingToBeSeated = true;
if (!Locator.GetPlayerController()._isWearingSuit)
{
SpawnPointBuilder.SuitUp();
}
}
// Idk whats making this work but now it works and idc
if(_waitingToBeSeated
&& PlayerState.IsInsideShip()
&& PlayerState.IsWearingSuit()
&& base.GetComponentInChildren<ShipCockpitController>()?._playerAttachPoint?.GetAttachedOWRigidbody() != null
&& !Locator.GetPlayerController()._isMovementLocked
&& !Locator.GetPlayerController()._isTurningLocked
&& _eyesOpen)
{
Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => FinishWarp(), 4);
_waitingToBeSeated = false;
}
if (_waitingToBeSeated)
{
if (Player.getResources()._currentHealth < 100f)
{
Logger.Log("Player died in a warp drive accident, reviving them");
// Means the player was killed meaning they weren't teleported in
Player.getResources()._currentHealth = 100f;
Teleportation.teleportPlayerToShip();
if(!PlayerState.AtFlightConsole()) Teleportation.teleportPlayerToShip();
}
Logger.Log($"{PlayerState.IsInsideShip()}, {PlayerState.IsWearingSuit()}, {base.GetComponentInChildren<ShipCockpitController>()?._playerAttachPoint?.GetAttachedOWRigidbody() != null}, {!Locator.GetPlayerController()._isMovementLocked}, {!Locator.GetPlayerController()._isTurningLocked }, {_eyesOpen}");
}
// Idk whats making this work but now it works and idc
if (_waitingToBeSeated && PlayerState.IsInsideShip() && _eyesOpen)
{
Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => FinishWarpIn(), 1);
_waitingToBeSeated = false;
}
}
@ -146,8 +142,23 @@ namespace NewHorizons.Components
_eyesOpen = true;
}
public void FinishWarp()
private void StartWarpInEffect()
{
Logger.Log("Starting warp-in effect");
_oneShotSource.PlayOneShot(global::AudioType.VesselSingularityCollapse, 1f);
Locator.GetDeathManager()._invincible = true;
if (Main.Instance.CurrentStarSystem.Equals("SolarSystem")) Teleportation.teleportPlayerToShip();
_whitehole.Create();
_waitingToBeSeated = true;
if (!Locator.GetPlayerController()._isWearingSuit)
{
SpawnPointBuilder.SuitUp();
}
}
public void FinishWarpIn()
{
Logger.Log("Finishing warp");
Locator.GetShipBody().GetComponentInChildren<ShipCockpitController>().OnPressInteract();
_waitingToBeSeated = false;
Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => _whitehole.Collapse(), 30);

View File

@ -39,8 +39,7 @@ namespace NewHorizons
public string CurrentStarSystem { get { return Instance._currentStarSystem; } }
private bool _isChangingStarSystem = false;
private bool _isWarping = false;
public static bool IsWarping { get { return Instance._isWarping; } }
public bool IsWarping { get; private set; } = false;
private ShipWarpController _shipWarpController;
@ -199,8 +198,9 @@ namespace NewHorizons
if (map != null) map._maxPanDistance = FurthestOrbit * 1.5f;
_shipWarpController = GameObject.Find("Ship_Body").AddComponent<ShipWarpController>();
if (_isWarping) Instance.ModHelper.Events.Unity.FireInNUpdates(() => _shipWarpController.WarpIn(), 1);
_isWarping = false;
Logger.Log($"Is the player warping in? {IsWarping}");
//if (IsWarping) Instance.ModHelper.Events.Unity.FireInNUpdates(() => _shipWarpController.WarpIn(), 1);
IsWarping = false;
}
#region TitleScreen
@ -548,11 +548,13 @@ namespace NewHorizons
#region Change star system
public void ChangeCurrentStarSystem(string newStarSystem, bool warp = false)
{
if (_isChangingStarSystem) return;
Logger.Log($"Warping to {newStarSystem}");
if(warp) _shipWarpController.WarpOut();
_currentStarSystem = newStarSystem;
_isChangingStarSystem = true;
_isWarping = warp;
IsWarping = warp;
// We kill them so they don't move as much
Locator.GetDeathManager().KillPlayer(DeathType.Meditation);