mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-03 17:53:57 +00:00
Merge branch 'dev' into picture-frame-doors
This commit is contained in:
commit
b9382750de
@ -22,7 +22,7 @@ internal class QSBItem<T> : WorldObject<T>, IQSBItem
|
||||
{
|
||||
if (AttachedObject == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - AttachedObject is null! Type:{GetType()}", OWML.Common.MessageType.Error);
|
||||
DebugLog.ToConsole($"Error - AttachedObject is null! Type:{GetType().Name}", OWML.Common.MessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -55,14 +55,14 @@ public static class QSBPatchManager
|
||||
//DebugLog.DebugWrite($"Patch block {Enum.GetName(typeof(QSBPatchTypes), type)}", MessageType.Info);
|
||||
foreach (var patch in _patchList.Where(x => x.Type == type))
|
||||
{
|
||||
//DebugLog.DebugWrite($" - Patching in {patch}", MessageType.Info);
|
||||
//DebugLog.DebugWrite($" - Patching in {patch.GetType().Name}", MessageType.Info);
|
||||
try
|
||||
{
|
||||
patch.DoPatches(TypeToInstance[type]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DebugLog.ToConsole($"Error while patching {patch} :\r\n{ex}", MessageType.Error);
|
||||
DebugLog.ToConsole($"Error while patching {patch.GetType().Name} :\r\n{ex}", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,5 +300,5 @@ public class PlayerInfo
|
||||
_ditheringAnimator.SetVisible(visible, seconds);
|
||||
}
|
||||
|
||||
public override string ToString() => $"{PlayerId}:{GetType()} ({Name})";
|
||||
public override string ToString() => $"{PlayerId}:{GetType().Name} ({Name})";
|
||||
}
|
@ -70,9 +70,10 @@ public abstract class SectoredRigidbodySync : BaseSectoredSync
|
||||
return;
|
||||
}
|
||||
|
||||
transform.position = ReferenceTransform.ToRelPos(AttachedRigidbody.GetPosition());
|
||||
var pos = AttachedRigidbody.GetPosition();
|
||||
transform.position = ReferenceTransform.ToRelPos(pos);
|
||||
transform.rotation = ReferenceTransform.ToRelRot(AttachedRigidbody.GetRotation());
|
||||
Velocity = ReferenceRigidbody.ToRelVel(AttachedRigidbody.GetVelocity(), AttachedRigidbody.GetPosition());
|
||||
Velocity = ReferenceRigidbody.ToRelVel(AttachedRigidbody.GetVelocity(), pos);
|
||||
AngularVelocity = ReferenceRigidbody.ToRelAngVel(AttachedRigidbody.GetAngularVelocity());
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ public abstract class SyncBase : QSBNetworkTransform
|
||||
public string Name => AttachedTransform ? AttachedTransform.name : "<NullObject!>";
|
||||
|
||||
public override string ToString() => (IsPlayerObject ? $"{Player.PlayerId}." : string.Empty)
|
||||
+ $"{netId}:{GetType()} ({Name})";
|
||||
+ $"{netId}:{GetType().Name} ({Name})";
|
||||
|
||||
protected virtual float DistanceChangeThreshold => 5f;
|
||||
private float _prevDistance;
|
||||
|
@ -64,9 +64,10 @@ public abstract class UnsectoredRigidbodySync : BaseUnsectoredSync
|
||||
|
||||
protected override void GetFromAttached()
|
||||
{
|
||||
transform.position = ReferenceTransform.ToRelPos(AttachedRigidbody.GetPosition());
|
||||
var pos = AttachedRigidbody.GetPosition();
|
||||
transform.position = ReferenceTransform.ToRelPos(pos);
|
||||
transform.rotation = ReferenceTransform.ToRelRot(AttachedRigidbody.GetRotation());
|
||||
Velocity = ReferenceRigidbody.ToRelVel(AttachedRigidbody.GetVelocity(), AttachedRigidbody.GetPosition());
|
||||
Velocity = ReferenceRigidbody.ToRelVel(AttachedRigidbody.GetVelocity(), pos);
|
||||
AngularVelocity = ReferenceRigidbody.ToRelAngVel(AttachedRigidbody.GetAngularVelocity());
|
||||
}
|
||||
|
||||
|
@ -4,12 +4,27 @@ namespace QSB.Utility;
|
||||
|
||||
public static class RelativeTransformUtil
|
||||
{
|
||||
public static Vector3 ToRelPos(this Transform reference, Vector3 pos) => reference.InverseTransformPoint(pos);
|
||||
public static Vector3 FromRelPos(this Transform reference, Vector3 relPos) => reference.TransformPoint(relPos);
|
||||
public static Quaternion ToRelRot(this Transform reference, Quaternion rot) => reference.InverseTransformRotation(rot);
|
||||
public static Quaternion FromRelRot(this Transform reference, Quaternion relRot) => reference.TransformRotation(relRot);
|
||||
public static Vector3 ToRelVel(this OWRigidbody reference, Vector3 vel, Vector3 pos) => vel - reference.GetPointVelocity(pos);
|
||||
public static Vector3 FromRelVel(this OWRigidbody reference, Vector3 relVel, Vector3 pos) => relVel + reference.GetPointVelocity(pos);
|
||||
public static Vector3 ToRelAngVel(this OWRigidbody reference, Vector3 angVel) => angVel - reference.GetAngularVelocity();
|
||||
public static Vector3 FromRelAngVel(this OWRigidbody reference, Vector3 relAngVel) => relAngVel + reference.GetAngularVelocity();
|
||||
}
|
||||
public static Vector3 ToRelPos(this Transform refTransform, Vector3 pos) =>
|
||||
refTransform.InverseTransformPoint(pos);
|
||||
|
||||
public static Vector3 FromRelPos(this Transform refTransform, Vector3 relPos) =>
|
||||
refTransform.TransformPoint(relPos);
|
||||
|
||||
public static Quaternion ToRelRot(this Transform refTransform, Quaternion rot) =>
|
||||
refTransform.InverseTransformRotation(rot);
|
||||
|
||||
public static Quaternion FromRelRot(this Transform refTransform, Quaternion relRot) =>
|
||||
refTransform.TransformRotation(relRot);
|
||||
|
||||
public static Vector3 ToRelVel(this OWRigidbody refBody, Vector3 vel, Vector3 pos) =>
|
||||
refBody.transform.InverseTransformDirection(vel - refBody.GetPointVelocity(pos));
|
||||
|
||||
public static Vector3 FromRelVel(this OWRigidbody refBody, Vector3 relVel, Vector3 pos) =>
|
||||
refBody.GetPointVelocity(pos) + refBody.transform.TransformDirection(relVel);
|
||||
|
||||
public static Vector3 ToRelAngVel(this OWRigidbody refBody, Vector3 angVel) =>
|
||||
refBody.transform.InverseTransformDirection(angVel - refBody.GetAngularVelocity());
|
||||
|
||||
public static Vector3 FromRelAngVel(this OWRigidbody refBody, Vector3 relAngVel) =>
|
||||
refBody.GetAngularVelocity() + refBody.transform.TransformDirection(relAngVel);
|
||||
}
|
||||
|
@ -203,13 +203,13 @@ public static class QSBWorldSync
|
||||
{
|
||||
if (!WorldObjects.IsInRange(objectId))
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - Tried to find {typeof(TWorldObject)} id {objectId}. Count is {WorldObjects.Count}.", MessageType.Warning);
|
||||
DebugLog.ToConsole($"Warning - Tried to find {typeof(TWorldObject).Name} id {objectId}. Count is {WorldObjects.Count}.", MessageType.Warning);
|
||||
return default;
|
||||
}
|
||||
|
||||
if (WorldObjects[objectId] is not TWorldObject worldObject)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - {typeof(TWorldObject)} id {objectId} is actually {WorldObjects[objectId].GetType()}.", MessageType.Error);
|
||||
DebugLog.ToConsole($"Error - {typeof(TWorldObject).Name} id {objectId} is actually {WorldObjects[objectId].GetType().Name}.", MessageType.Error);
|
||||
return default;
|
||||
}
|
||||
|
||||
@ -221,13 +221,13 @@ public static class QSBWorldSync
|
||||
{
|
||||
if (!unityObject)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Trying to run GetWorldFromUnity with a null unity object! TWorldObject:{typeof(TWorldObject)}, TUnityObject:NULL, Stacktrace:\r\n{Environment.StackTrace}", MessageType.Error);
|
||||
DebugLog.ToConsole($"Error - Trying to run GetWorldFromUnity with a null unity object! TWorldObject:{typeof(TWorldObject).Name}, TUnityObject:NULL, Stacktrace:\r\n{Environment.StackTrace}", MessageType.Error);
|
||||
return default;
|
||||
}
|
||||
|
||||
if (!UnityObjectsToWorldObjects.TryGetValue(unityObject, out var worldObject))
|
||||
{
|
||||
DebugLog.ToConsole($"Error - WorldObjectsToUnityObjects does not contain \"{unityObject.name}\"! TWorldObject:{typeof(TWorldObject)}, TUnityObject:{unityObject.GetType()}, Stacktrace:\r\n{Environment.StackTrace}", MessageType.Error);
|
||||
DebugLog.ToConsole($"Error - WorldObjectsToUnityObjects does not contain \"{unityObject.name}\"! TWorldObject:{typeof(TWorldObject).Name}, TUnityObject:{unityObject.GetType().Name}, Stacktrace:\r\n{Environment.StackTrace}", MessageType.Error);
|
||||
return default;
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ public abstract class WorldObject<T> : IWorldObject
|
||||
MonoBehaviour IWorldObject.AttachedObject => AttachedObject;
|
||||
public T AttachedObject { get; init; }
|
||||
public string Name => AttachedObject ? AttachedObject.name : "<NullObject!>";
|
||||
public override string ToString() => $"{ObjectId}:{GetType()} ({Name})";
|
||||
public override string ToString() => $"{ObjectId}:{GetType().Name} ({Name})";
|
||||
|
||||
public virtual async UniTask Init(CancellationToken ct) { }
|
||||
public virtual void OnRemoval() { }
|
||||
|
@ -20,5 +20,5 @@ public abstract class WorldObjectManager : MonoBehaviour, IAddComponentOnStart
|
||||
|
||||
public virtual void UnbuildWorldObjects() { }
|
||||
|
||||
public override string ToString() => GetType().ToString();
|
||||
public override string ToString() => GetType().Name;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user