mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-26 18:35:34 +00:00
fixed null bug in resync event
This commit is contained in:
parent
79fb2cfe0b
commit
15a973d109
@ -64,7 +64,7 @@ namespace QSB.MeteorSync.Events
|
|||||||
if (msg.Integrity <= 0 && qsbFragment.DetachableFragment != null)
|
if (msg.Integrity <= 0 && qsbFragment.DetachableFragment != null)
|
||||||
{
|
{
|
||||||
// the detach is delayed, so wait until that happens
|
// the detach is delayed, so wait until that happens
|
||||||
QSBCore.UnityEvents.RunWhen(() => qsbFragment.DetachableFragment._isDetached,() =>
|
QSBCore.UnityEvents.RunWhen(() => qsbFragment.DetachableFragment._isDetached, () =>
|
||||||
{
|
{
|
||||||
if (msg.IsThruWhiteHole && !qsbFragment.IsThruWhiteHole)
|
if (msg.IsThruWhiteHole && !qsbFragment.IsThruWhiteHole)
|
||||||
{
|
{
|
||||||
@ -82,15 +82,25 @@ namespace QSB.MeteorSync.Events
|
|||||||
}
|
}
|
||||||
|
|
||||||
var refBody = qsbFragment.RefBody;
|
var refBody = qsbFragment.RefBody;
|
||||||
var body = qsbFragment.Body;
|
if (msg.IsThruWhiteHole)
|
||||||
var targetPos = refBody.transform.TransformPoint(msg.Pos);
|
{
|
||||||
var targetRot = refBody.transform.TransformRotation(msg.Rot);
|
var body = qsbFragment.Body;
|
||||||
var targetVel = refBody.GetPointVelocity(targetPos) + msg.Vel;
|
var targetPos = refBody.transform.TransformPoint(msg.Pos);
|
||||||
var targetAngVel = refBody.GetAngularVelocity() + msg.AngVel;
|
var targetRot = refBody.transform.TransformRotation(msg.Rot);
|
||||||
body.MoveToPosition(targetPos);
|
var targetVel = refBody.GetPointVelocity(targetPos) + msg.Vel;
|
||||||
body.MoveToRotation(targetRot);
|
var targetAngVel = refBody.GetAngularVelocity() + msg.AngVel;
|
||||||
SetVelocity(body, targetVel);
|
body.MoveToPosition(targetPos);
|
||||||
body.SetAngularVelocity(targetAngVel);
|
body.MoveToRotation(targetRot);
|
||||||
|
SetVelocity(body, targetVel);
|
||||||
|
body.SetAngularVelocity(targetAngVel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var targetPos = refBody.transform.TransformPoint(msg.Pos);
|
||||||
|
var targetRot = refBody.transform.TransformRotation(msg.Rot);
|
||||||
|
qsbFragment.AttachedObject.transform.position = targetPos;
|
||||||
|
qsbFragment.AttachedObject.transform.rotation = targetRot;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using QSB.WorldSync;
|
using OWML.Common;
|
||||||
|
using QSB.Utility;
|
||||||
|
using QSB.WorldSync;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace QSB.MeteorSync.WorldObjects
|
namespace QSB.MeteorSync.WorldObjects
|
||||||
@ -26,9 +28,20 @@ namespace QSB.MeteorSync.WorldObjects
|
|||||||
public DetachableFragment DetachableFragment;
|
public DetachableFragment DetachableFragment;
|
||||||
public bool IsThruWhiteHole => DetachableFragment != null &&
|
public bool IsThruWhiteHole => DetachableFragment != null &&
|
||||||
DetachableFragment._sector._parentSector == MeteorManager.WhiteHoleVolume._whiteHoleSector;
|
DetachableFragment._sector._parentSector == MeteorManager.WhiteHoleVolume._whiteHoleSector;
|
||||||
public OWRigidbody RefBody => IsThruWhiteHole ? MeteorManager.WhiteHoleVolume._whiteHoleBody :
|
public OWRigidbody RefBody => IsThruWhiteHole ? MeteorManager.WhiteHoleVolume._whiteHoleBody : Locator._brittleHollow._owRigidbody;
|
||||||
Locator._brittleHollow._owRigidbody;
|
public OWRigidbody Body
|
||||||
public OWRigidbody Body => IsThruWhiteHole ? AttachedObject.transform.parent.parent.GetAttachedOWRigidbody() : null;
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (IsThruWhiteHole)
|
||||||
|
{
|
||||||
|
return AttachedObject.transform.parent.parent.GetAttachedOWRigidbody();
|
||||||
|
}
|
||||||
|
DebugLog.ToConsole($"{LogName} - trying to get rigidbody when not thru white hole. "
|
||||||
|
+ "did you mean to get the transform instead?", MessageType.Error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// what the leash length will be when we eventually detach and fall thru white hole
|
/// what the leash length will be when we eventually detach and fall thru white hole
|
||||||
public float LeashLength;
|
public float LeashLength;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user