mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-18 13:23:05 +00:00
force probe to stay in launcher when not active
This commit is contained in:
parent
02c6d7f9bc
commit
2f72ffb31d
@ -1,4 +1,5 @@
|
||||
using OWML.Common;
|
||||
using OWML.Utils;
|
||||
using QSB.Player;
|
||||
using QSB.SectorSync;
|
||||
using QSB.Syncs.TransformSync;
|
||||
@ -57,6 +58,80 @@ namespace QSB.ProbeSync.TransformSync
|
||||
return body;
|
||||
}
|
||||
|
||||
// TODO : maybe just add a field like "useinterpolation" for still updating if the attachedobject is disabled
|
||||
public override void Update()
|
||||
{
|
||||
if (!_isInitialized && IsReady)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
else if (_isInitialized && !IsReady)
|
||||
{
|
||||
_isInitialized = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_isInitialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (AttachedObject == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - AttachedObject {_logName} is null.", MessageType.Warning);
|
||||
_isInitialized = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ReferenceTransform != null && ReferenceTransform.position == Vector3.zero)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - {_logName}'s ReferenceTransform is at (0,0,0). ReferenceTransform:{ReferenceTransform.name}, AttachedObject:{AttachedObject.name}", MessageType.Warning);
|
||||
}
|
||||
|
||||
if (ReferenceTransform == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - {_logName}'s ReferenceTransform is null. AttachedObject:{AttachedObject.name}", MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateTransform();
|
||||
}
|
||||
|
||||
protected override void UpdateTransform()
|
||||
{
|
||||
if (HasAuthority)
|
||||
{
|
||||
if (!AttachedObject.gameObject.activeInHierarchy)
|
||||
{
|
||||
var probeOWRigidbody = Locator.GetProbe().GetComponent<SurveyorProbe>().GetOWRigidbody();
|
||||
if (probeOWRigidbody == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - Could not find OWRigidbody of local probe.", MessageType.Warning);
|
||||
}
|
||||
|
||||
var probeLauncher = Player.LocalProbeLauncher;
|
||||
var launcherTransform = probeLauncher.GetValue<Transform>("_launcherTransform");
|
||||
probeOWRigidbody.SetPosition(launcherTransform.position);
|
||||
probeOWRigidbody.SetRotation(launcherTransform.rotation);
|
||||
|
||||
_intermediaryTransform.EncodePosition(AttachedObject.transform.position);
|
||||
_intermediaryTransform.EncodeRotation(AttachedObject.transform.rotation);
|
||||
|
||||
var currentReferenceSector = ReferenceSector;
|
||||
var playerReferenceSector = Player.TransformSync.ReferenceSector;
|
||||
|
||||
if (currentReferenceSector != playerReferenceSector)
|
||||
{
|
||||
SetReferenceSector(playerReferenceSector);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
base.UpdateTransform();
|
||||
}
|
||||
|
||||
public override bool IsReady => Locator.GetProbe() != null
|
||||
&& Player != null
|
||||
&& QSBPlayerManager.PlayerExists(Player.PlayerId)
|
||||
|
Loading…
x
Reference in New Issue
Block a user