mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-25 06:35:45 +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)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
@ -82,15 +82,25 @@ namespace QSB.MeteorSync.Events
|
||||
}
|
||||
|
||||
var refBody = qsbFragment.RefBody;
|
||||
var body = qsbFragment.Body;
|
||||
var targetPos = refBody.transform.TransformPoint(msg.Pos);
|
||||
var targetRot = refBody.transform.TransformRotation(msg.Rot);
|
||||
var targetVel = refBody.GetPointVelocity(targetPos) + msg.Vel;
|
||||
var targetAngVel = refBody.GetAngularVelocity() + msg.AngVel;
|
||||
body.MoveToPosition(targetPos);
|
||||
body.MoveToRotation(targetRot);
|
||||
SetVelocity(body, targetVel);
|
||||
body.SetAngularVelocity(targetAngVel);
|
||||
if (msg.IsThruWhiteHole)
|
||||
{
|
||||
var body = qsbFragment.Body;
|
||||
var targetPos = refBody.transform.TransformPoint(msg.Pos);
|
||||
var targetRot = refBody.transform.TransformRotation(msg.Rot);
|
||||
var targetVel = refBody.GetPointVelocity(targetPos) + msg.Vel;
|
||||
var targetAngVel = refBody.GetAngularVelocity() + msg.AngVel;
|
||||
body.MoveToPosition(targetPos);
|
||||
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;
|
||||
|
||||
namespace QSB.MeteorSync.WorldObjects
|
||||
@ -26,9 +28,20 @@ namespace QSB.MeteorSync.WorldObjects
|
||||
public DetachableFragment DetachableFragment;
|
||||
public bool IsThruWhiteHole => DetachableFragment != null &&
|
||||
DetachableFragment._sector._parentSector == MeteorManager.WhiteHoleVolume._whiteHoleSector;
|
||||
public OWRigidbody RefBody => IsThruWhiteHole ? MeteorManager.WhiteHoleVolume._whiteHoleBody :
|
||||
Locator._brittleHollow._owRigidbody;
|
||||
public OWRigidbody Body => IsThruWhiteHole ? AttachedObject.transform.parent.parent.GetAttachedOWRigidbody() : null;
|
||||
public OWRigidbody RefBody => IsThruWhiteHole ? MeteorManager.WhiteHoleVolume._whiteHoleBody : Locator._brittleHollow._owRigidbody;
|
||||
public OWRigidbody Body
|
||||
{
|
||||
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
|
||||
public float LeashLength;
|
||||
|
Loading…
x
Reference in New Issue
Block a user