fix probe not working

This commit is contained in:
Mister_Nebula 2021-07-05 16:13:53 +01:00
parent f4483b27b3
commit 11bf557464
3 changed files with 52 additions and 39 deletions

View File

@ -27,21 +27,6 @@ namespace QSB.ProbeSync.Events
var player = QSBPlayerManager.GetPlayer(message.AboutId);
var probe = player.Probe;
switch (message.EnumValue)
{
case ProbeEvent.Anchor:
case ProbeEvent.Unanchor:
case ProbeEvent.Launch:
player.PlayerStates.ProbeActive = true;
probe.SetState(true);
break;
case ProbeEvent.Destroy:
case ProbeEvent.Retrieve:
player.PlayerStates.ProbeActive = false;
probe.SetState(false);
break;
}
probe.HandleEvent(message.EnumValue);
}
}

View File

@ -1,4 +1,5 @@
using QSB.Utility;
using QSB.Player;
using QSB.Utility;
using UnityEngine;
namespace QSB.ProbeSync
@ -19,6 +20,7 @@ namespace QSB.ProbeSync
private RulesetDetector _rulesetDetector;
private SingularityWarpEffect _warpEffect;
private bool _isRetrieving;
private PlayerInfo _owner;
public RulesetDetector GetRulesetDetector()
=> _rulesetDetector;
@ -32,31 +34,49 @@ namespace QSB.ProbeSync
_isRetrieving = false;
}
private void OnDestroy()
private void Start()
{
gameObject.SetActive(false);
}
protected void OnDestroy()
{
_warpEffect.OnWarpComplete -= OnWarpComplete;
}
public void SetOwner(PlayerInfo player)
{
if (_owner != null)
{
DebugLog.ToConsole($"Warning - Trying to set owner of probe that already has an owner!", OWML.Common.MessageType.Warning);
}
_owner = player;
}
private void OnWarpComplete()
{
DebugLog.DebugWrite($"OnWarpComplete");
//gameObject.SetActive(false);
gameObject.SetActive(false);
transform.parent = null;
transform.localScale = Vector3.one;
_isRetrieving = false;
}
public bool IsRetrieving()
{
return IsLaunched() && _isRetrieving;
}
=> IsLaunched() && _isRetrieving;
public bool IsLaunched()
{
return gameObject.activeSelf;
}
=> gameObject.activeSelf;
public void HandleEvent(ProbeEvent probeEvent)
{
if (_owner == null)
{
DebugLog.ToConsole($"Error - Trying to handle event on probe with no owner.", OWML.Common.MessageType.Error);
return;
}
switch (probeEvent)
{
case ProbeEvent.Launch:
@ -66,6 +86,13 @@ namespace QSB.ProbeSync
break;
}
DebugLog.DebugWrite($"LAUNCH!");
gameObject.SetActive(true);
transform.parent = null;
transform.position = _owner.ProbeLauncher.transform.position;
transform.rotation = _owner.ProbeLauncher.transform.rotation;
OnLaunchProbe();
break;
case ProbeEvent.Anchor:
@ -75,10 +102,15 @@ namespace QSB.ProbeSync
break;
}
DebugLog.DebugWrite($"ANCHOR!");
OnAnchorProbe();
break;
case ProbeEvent.Unanchor:
DebugLog.DebugWrite($"OnUnanchorProbe");
DebugLog.DebugWrite($"UNANCHOR!");
OnUnanchorProbe();
break;
case ProbeEvent.Retrieve:
@ -88,6 +120,8 @@ namespace QSB.ProbeSync
break;
}
DebugLog.DebugWrite($"RETRIEVE!");
OnRetrieveProbe();
break;
case ProbeEvent.Destroy:
@ -115,23 +149,14 @@ namespace QSB.ProbeSync
DebugLog.DebugWrite($"start warp out");
_warpEffect.WarpObjectOut(duration);
if (_warpEffect.gameObject.activeInHierarchy == false)
if (OnStartRetrieveProbe == null)
{
DebugLog.DebugWrite($"warp effect GO is not active!");
DebugLog.ToConsole($"Warning - OnStartRetrieveProbe is null!", OWML.Common.MessageType.Warning);
return;
}
}
}
public void SetState(bool state)
{
if (state)
{
gameObject.SetActive(true);
gameObject.Show();
return;
OnStartRetrieveProbe(duration);
}
gameObject.Hide();
}
}
}

View File

@ -44,6 +44,7 @@ namespace QSB.Tools
{
var qsbProbe = newProbe.gameObject.AddComponent<QSBProbe>();
player.Probe = qsbProbe;
qsbProbe.SetOwner(player);
// Probe_Body
Object.Destroy(newProbe.GetComponent<ProbeAnchor>());
@ -154,6 +155,8 @@ namespace QSB.Tools
newProbe.Find("RecallEffect").gameObject.GetComponent<SingularityController>().enabled = true;
newProbe.Find("RecallEffect").gameObject.GetComponent<SingularityWarpEffect>().enabled = true;
newProbe.Find("RecallEffect").name = "RemoteProbeRecallEffect";
newProbe.gameObject.SetActive(true);
}
private static void CreateStowTransforms(Transform cameraBody)