From 9007502d8b30fde90d3bc320d959f0511539a207 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Sun, 20 Jun 2021 13:39:34 +0100 Subject: [PATCH] stop ship "respawning" --- QSB/DeathSync/RespawnOnDeath.cs | 84 +-------------------------------- 1 file changed, 2 insertions(+), 82 deletions(-) diff --git a/QSB/DeathSync/RespawnOnDeath.cs b/QSB/DeathSync/RespawnOnDeath.cs index b8573cb6..3a9b2614 100644 --- a/QSB/DeathSync/RespawnOnDeath.cs +++ b/QSB/DeathSync/RespawnOnDeath.cs @@ -1,6 +1,5 @@ using OWML.Common; using OWML.Utils; -using QSB.ShipSync.TransformSync; using QSB.Utility; using System.Linq; using UnityEngine; @@ -17,20 +16,11 @@ namespace QSB.DeathSync DeathType.TimeLoop }; - private readonly Vector3 ShipContainerOffset = new Vector3(-16.45f, -52.67f, 227.39f); - private readonly Quaternion ShipContainerRotation = Quaternion.Euler(-76.937f, 1.062f, -185.066f); - - private SpawnPoint _shipSpawnPoint; private SpawnPoint _playerSpawnPoint; - private OWRigidbody _shipBody; private PlayerSpawner _playerSpawner; private FluidDetector _fluidDetector; private PlayerResources _playerResources; - private ShipComponent[] _shipComponents; - private HatchController _hatchController; - private ShipCockpitController _cockpitController; private PlayerSpacesuit _spaceSuit; - private ShipTractorBeamSwitch _shipTractorBeam; private SuitPickupVolume[] _suitPickupVolumes; public void Awake() => Instance = this; @@ -41,37 +31,9 @@ namespace QSB.DeathSync _playerResources = playerTransform.GetComponent(); _spaceSuit = Locator.GetPlayerSuit(); _playerSpawner = FindObjectOfType(); - _shipTractorBeam = FindObjectOfType(); _suitPickupVolumes = FindObjectsOfType(); - _fluidDetector = Locator.GetPlayerCamera().GetComponentInChildren(); - _playerSpawnPoint = GetSpawnPoint(); - _shipSpawnPoint = GetSpawnPoint(true); - - var shipTransform = Locator.GetShipTransform(); - if (shipTransform == null) - { - DebugLog.ToConsole($"Warning - Init() ran when ship was null?", MessageType.Warning); - return; - } - - _shipComponents = shipTransform.GetComponentsInChildren(); - _hatchController = shipTransform.GetComponentInChildren(); - _cockpitController = shipTransform.GetComponentInChildren(); - _shipBody = Locator.GetShipBody(); - - if (_shipSpawnPoint == null) - { - DebugLog.ToConsole("Warning - _shipSpawnPoint is null in Init()!", MessageType.Warning); - return; - } - - // Move debug spawn point to initial ship position (so ship doesnt spawn in space!) - var timberHearth = Locator.GetAstroObject(AstroObject.Name.TimberHearth).transform; - _shipSpawnPoint.transform.SetParent(timberHearth); - _shipSpawnPoint.transform.localPosition = ShipContainerOffset; - _shipSpawnPoint.transform.localRotation = ShipContainerRotation; } public void ResetPlayer() @@ -123,49 +85,7 @@ namespace QSB.DeathSync } } - public void ResetShip() - { - DebugLog.DebugWrite($"Trying to reset ship."); - if (!ShipTransformSync.LocalInstance.HasAuthority) - { - DebugLog.ToConsole($"Warning - Tried to reset ship when not in control!", MessageType.Warning); - return; - } - - if (_shipSpawnPoint == null) - { - DebugLog.ToConsole("Warning - _shipSpawnPoint is null!", MessageType.Warning); - Init(); - } - - if (_shipBody == null) - { - DebugLog.ToConsole($"Warning - Tried to reset ship, but the ship is null!", MessageType.Warning); - return; - } - - _shipBody.SetVelocity(_shipSpawnPoint.GetPointVelocity()); - _shipBody.WarpToPositionRotation(_shipSpawnPoint.transform.position, _shipSpawnPoint.transform.rotation); - - foreach (var shipComponent in _shipComponents) - { - shipComponent.SetDamaged(false); - } - - Invoke(nameof(ExitShip), 0.01f); - } - - private void ExitShip() - { - DebugLog.DebugWrite($"Exit ship."); - _cockpitController.Invoke("ExitFlightConsole"); - _cockpitController.Invoke("CompleteExitFlightConsole"); - _hatchController.SetValue("_isPlayerInShip", false); - _hatchController.Invoke("OpenHatch"); - _shipTractorBeam.ActivateTractorBeam(); - } - - private SpawnPoint GetSpawnPoint(bool isShip = false) + private SpawnPoint GetSpawnPoint() { var spawnList = _playerSpawner.GetValue("_spawnList"); if (spawnList == null) @@ -176,7 +96,7 @@ namespace QSB.DeathSync return spawnList.FirstOrDefault(spawnPoint => spawnPoint.GetSpawnLocation() == SpawnLocation.TimberHearth - && spawnPoint.IsShipSpawn() == isShip); + && spawnPoint.IsShipSpawn() == false); } } } \ No newline at end of file