we dont really cares what happens to the fragments after they detach, so i can afford to let them to desynced. it shouldnt be too drastic.

This commit is contained in:
JohnCorby 2021-11-14 00:45:25 -08:00
parent 3b4a8682be
commit 51cabb962c
2 changed files with 1 additions and 66 deletions

View File

@ -1,8 +1,6 @@
using QSB.Events;
using QSB.MeteorSync.WorldObjects;
using QSB.Utility;
using QSB.WorldSync;
using UnityEngine;
using EventType = QSB.Events.EventType;
namespace QSB.MeteorSync.Events
@ -28,15 +26,6 @@ namespace QSB.MeteorSync.Events
Integrity = qsbFragment.AttachedObject._integrity,
OrigIntegrity = qsbFragment.AttachedObject._origIntegrity
};
// if (msg.Integrity <= 0)
// {
// var refBody = Locator._brittleHollow.GetOWRigidbody();
// var body = qsbFragment.AttachedObject.GetAttachedOWRigidbody();
// msg.Pos = refBody.transform.InverseTransformPoint(body.transform.position);
// msg.Rot = refBody.transform.InverseTransformRotation(body.transform.rotation);
// msg.Vel = GetRelativeVelocity(body, refBody);
// msg.AngVel = body.GetRelativeAngularVelocity(refBody);
// }
return msg;
}
@ -51,42 +40,7 @@ namespace QSB.MeteorSync.Events
var qsbFragment = QSBWorldSync.GetWorldFromId<QSBFragment>(msg.ObjectId);
qsbFragment.AttachedObject._integrity = msg.Integrity;
qsbFragment.AttachedObject._origIntegrity = msg.OrigIntegrity;
// if (msg.Integrity <= 0)
// {
// var refBody = Locator._brittleHollow.GetOWRigidbody();
// var body = qsbFragment.AttachedObject.GetAttachedOWRigidbody();
// 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);
// }
qsbFragment.AttachedObject.CallOnTakeDamage();
}
// code yoink from transform sync lol
private static void SetVelocity(OWRigidbody rigidbody, Vector3 relativeVelocity)
{
var isRunningKinematic = rigidbody.RunningKinematicSimulation();
var currentVelocity = rigidbody._currentVelocity;
if (isRunningKinematic)
{
rigidbody._kinematicRigidbody.velocity = relativeVelocity + Locator.GetCenterOfTheUniverse().GetStaticFrameVelocity_Internal();
}
else
{
rigidbody._rigidbody.velocity = relativeVelocity + Locator.GetCenterOfTheUniverse().GetStaticFrameVelocity_Internal();
}
rigidbody._lastVelocity = currentVelocity;
rigidbody._currentVelocity = relativeVelocity;
}
private static Vector3 GetRelativeVelocity(OWRigidbody body, OWRigidbody refBody)
=> body.GetVelocity() - refBody.GetPointVelocity(body.transform.position);
}
}

View File

@ -1,6 +1,5 @@
using QSB.WorldSync.Events;
using QuantumUNET.Transport;
using UnityEngine;
namespace QSB.MeteorSync.Events
{
@ -8,23 +7,12 @@ namespace QSB.MeteorSync.Events
{
public float Integrity;
public float OrigIntegrity;
// public Vector3 Pos;
// public Quaternion Rot;
// public Vector3 Vel;
// public Vector3 AngVel;
public override void Deserialize(QNetworkReader reader)
{
base.Deserialize(reader);
Integrity = reader.ReadSingle();
OrigIntegrity = reader.ReadSingle();
// if (Integrity <= 0)
// {
// Pos = reader.ReadVector3();
// Rot = reader.ReadQuaternion();
// Vel = reader.ReadVector3();
// AngVel = reader.ReadVector3();
// }
}
public override void Serialize(QNetworkWriter writer)
@ -32,13 +20,6 @@ namespace QSB.MeteorSync.Events
base.Serialize(writer);
writer.Write(Integrity);
writer.Write(OrigIntegrity);
// if (Integrity <= 0)
// {
// writer.Write(Pos);
// writer.Write(Rot);
// writer.Write(Vel);
// writer.Write(AngVel);
// }
}
}
}