mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-29 09:32:38 +00:00
add ship recovery point (no interaction yet)
This commit is contained in:
parent
b39ceb851f
commit
91dad2cdf4
@ -6,6 +6,7 @@ using QSB.Utility;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace QSB.DeathSync
|
||||
{
|
||||
@ -17,11 +18,29 @@ namespace QSB.DeathSync
|
||||
|
||||
private List<PlayerInfo> _playersPendingRespawn = new List<PlayerInfo>();
|
||||
private NotificationData _previousNotification;
|
||||
private GameObject _owRecoveryPoint;
|
||||
private GameObject _qsbRecoveryPoint;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Instance = this;
|
||||
QSBSceneManager.OnSceneLoaded += OnSceneLoaded;
|
||||
QSBNetworkManager.Instance.OnClientConnected += OnConnected;
|
||||
QSBNetworkManager.Instance.OnClientDisconnected += OnDisconnected;
|
||||
}
|
||||
|
||||
private void OnConnected()
|
||||
{
|
||||
if (QSBSceneManager.IsInUniverse)
|
||||
{
|
||||
OnSceneLoaded(OWScene.None, QSBSceneManager.CurrentScene, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisconnected(NetworkError error)
|
||||
{
|
||||
_owRecoveryPoint?.SetActive(true);
|
||||
_qsbRecoveryPoint?.SetActive(false);
|
||||
}
|
||||
|
||||
private void OnSceneLoaded(OWScene oldScene, OWScene newScene, bool inUniverse)
|
||||
@ -29,6 +48,48 @@ namespace QSB.DeathSync
|
||||
QSBPlayerManager.ShowAllPlayers();
|
||||
QSBPlayerManager.PlayerList.ForEach(x => x.IsDead = false);
|
||||
_playersPendingRespawn.Clear();
|
||||
|
||||
if (newScene != OWScene.SolarSystem)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_owRecoveryPoint == null)
|
||||
{
|
||||
_owRecoveryPoint = GameObject.Find("Systems_Supplies/PlayerRecoveryPoint");
|
||||
}
|
||||
|
||||
if (_owRecoveryPoint == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Couldn't find the ship's PlayerRecoveryPoint!", OWML.Common.MessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_owRecoveryPoint.SetActive(false);
|
||||
|
||||
var Systems_Supplies = _owRecoveryPoint.gameObject.transform.parent;
|
||||
|
||||
if (_qsbRecoveryPoint == null)
|
||||
{
|
||||
_qsbRecoveryPoint = new GameObject("QSBPlayerRecoveryPoint");
|
||||
_qsbRecoveryPoint.SetActive(false);
|
||||
_qsbRecoveryPoint.transform.parent = Systems_Supplies;
|
||||
_qsbRecoveryPoint.transform.localPosition = new Vector3(2.46f, 1.957f, 1.156f);
|
||||
_qsbRecoveryPoint.transform.localRotation = Quaternion.Euler(0, 6.460001f, 0f);
|
||||
_qsbRecoveryPoint.layer = 21;
|
||||
|
||||
var boxCollider = _qsbRecoveryPoint.AddComponent<BoxCollider>();
|
||||
boxCollider.isTrigger = true;
|
||||
boxCollider.size = new Vector3(1.3f, 1.01f, 0.47f);
|
||||
|
||||
var multiInteract = _qsbRecoveryPoint.AddComponent<MultiInteractReceiver>();
|
||||
multiInteract._usableInShip = true;
|
||||
multiInteract._interactRange = 1.5f;
|
||||
|
||||
_qsbRecoveryPoint.AddComponent<ShipRecoveryPoint>();
|
||||
}
|
||||
|
||||
_qsbRecoveryPoint.SetActive(true);
|
||||
}
|
||||
|
||||
public void TriggerRespawnMap()
|
||||
|
69
QSB/DeathSync/ShipRecoveryPoint.cs
Normal file
69
QSB/DeathSync/ShipRecoveryPoint.cs
Normal file
@ -0,0 +1,69 @@
|
||||
using QSB.Utility;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.DeathSync
|
||||
{
|
||||
internal class ShipRecoveryPoint : MonoBehaviour
|
||||
{
|
||||
private MultipleInteractionVolume _interactVolume;
|
||||
private PlayerResources _playerResources;
|
||||
private VisorEffectController _playerVisor;
|
||||
private PlayerAudioController _playerAudioController;
|
||||
private bool _recovering;
|
||||
private int _refillIndex;
|
||||
private int _respawnIndex;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
DebugLog.DebugWrite($"AWAKE");
|
||||
_interactVolume = this.GetRequiredComponent<MultipleInteractionVolume>();
|
||||
//_interactVolume.OnPressInteract += OnPressInteract;
|
||||
_interactVolume.OnGainFocus += OnGainFocus;
|
||||
|
||||
_refillIndex = _interactVolume.AddInteraction(InputLibrary.interact, InputMode.Character, UITextType.None, true, true);
|
||||
_respawnIndex = _interactVolume.AddInteraction(InputLibrary.interactSecondary, InputMode.Character, UITextType.YouEscapeOnRingWorld, false, true);
|
||||
}
|
||||
|
||||
private void OnGainFocus()
|
||||
{
|
||||
DebugLog.DebugWrite($"OnGainFocus");
|
||||
|
||||
if (_playerResources == null)
|
||||
{
|
||||
_playerResources = Locator.GetPlayerTransform().GetComponent<PlayerResources>();
|
||||
}
|
||||
|
||||
_interactVolume.EnableSingleInteraction(RespawnManager.Instance.RespawnNeeded, _respawnIndex);
|
||||
|
||||
var needsHealing = _playerResources.GetHealthFraction() != 1f;
|
||||
var needsRefueling = _playerResources.GetFuelFraction() != 1f;
|
||||
|
||||
UITextType uitextType;
|
||||
if (needsHealing && needsRefueling)
|
||||
{
|
||||
uitextType = UITextType.RefillPrompt_0;
|
||||
_interactVolume.SetKeyCommandVisible(true, _refillIndex);
|
||||
}
|
||||
else if (needsHealing)
|
||||
{
|
||||
uitextType = UITextType.RefillPrompt_2;
|
||||
_interactVolume.SetKeyCommandVisible(true, _refillIndex);
|
||||
}
|
||||
else if (needsRefueling)
|
||||
{
|
||||
uitextType = UITextType.RefillPrompt_4;
|
||||
_interactVolume.SetKeyCommandVisible(true, _refillIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
uitextType = UITextType.RefillPrompt_7;
|
||||
_interactVolume.SetKeyCommandVisible(false, _refillIndex);
|
||||
}
|
||||
|
||||
if (uitextType != UITextType.None)
|
||||
{
|
||||
_interactVolume.ChangePrompt(uitextType, _refillIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -95,6 +95,7 @@
|
||||
<Compile Include="DeathSync\Patches\DeathPatches.cs" />
|
||||
<Compile Include="DeathSync\Patches\RespawnPatches.cs" />
|
||||
<Compile Include="DeathSync\RespawnManager.cs" />
|
||||
<Compile Include="DeathSync\ShipRecoveryPoint.cs" />
|
||||
<Compile Include="EchoesOfTheEye\AirlockSync\AirlockManager.cs" />
|
||||
<Compile Include="EchoesOfTheEye\AirlockSync\WorldObjects\QSBGhostAirlock.cs" />
|
||||
<Compile Include="ElevatorSync\WorldObjects\QSBElevator.cs" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user