mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-04 03:39:55 +00:00
ship stuff idk im tired and aaaaaaaaaaaaaaaaaaaaaaa
This commit is contained in:
parent
a2872c159c
commit
5791c9fd0c
@ -8,7 +8,7 @@ namespace QSB.Player.TransformSync
|
||||
{
|
||||
public class PlayerCameraSync : SectoredTransformSync
|
||||
{
|
||||
protected override GameObject InitLocalTransform()
|
||||
protected override Transform InitLocalTransform()
|
||||
{
|
||||
SectorSync.SetSectorDetector(Locator.GetPlayerSectorDetector());
|
||||
var body = Locator.GetPlayerCamera().gameObject.transform;
|
||||
@ -21,10 +21,10 @@ namespace QSB.Player.TransformSync
|
||||
DebugLog.DebugWrite("PlayerCameraSync init done - Request state!");
|
||||
QSBEventManager.FireEvent(EventNames.QSBPlayerStatesRequest);
|
||||
|
||||
return body.gameObject;
|
||||
return body;
|
||||
}
|
||||
|
||||
protected override GameObject InitRemoteTransform()
|
||||
protected override Transform InitRemoteTransform()
|
||||
{
|
||||
var body = new GameObject("RemotePlayerCamera");
|
||||
|
||||
@ -39,7 +39,7 @@ namespace QSB.Player.TransformSync
|
||||
Player.Camera = owcamera;
|
||||
Player.CameraBody = body;
|
||||
|
||||
return body;
|
||||
return body.transform;
|
||||
}
|
||||
|
||||
public override bool IsReady => Locator.GetPlayerTransform() != null
|
||||
|
@ -35,7 +35,7 @@ namespace QSB.Player.TransformSync
|
||||
private Transform GetPlayerModel() =>
|
||||
Locator.GetPlayerTransform().Find("Traveller_HEA_Player_v2");
|
||||
|
||||
protected override GameObject InitLocalTransform()
|
||||
protected override Transform InitLocalTransform()
|
||||
{
|
||||
SectorSync.SetSectorDetector(Locator.GetPlayerSectorDetector());
|
||||
var body = GetPlayerModel();
|
||||
@ -45,10 +45,10 @@ namespace QSB.Player.TransformSync
|
||||
|
||||
Player.Body = body.gameObject;
|
||||
|
||||
return body.gameObject;
|
||||
return body;
|
||||
}
|
||||
|
||||
protected override GameObject InitRemoteTransform()
|
||||
protected override Transform InitRemoteTransform()
|
||||
{
|
||||
var body = Instantiate(GetPlayerModel());
|
||||
Player.Body = body.gameObject;
|
||||
@ -61,7 +61,7 @@ namespace QSB.Player.TransformSync
|
||||
|
||||
body.gameObject.AddComponent<PlayerMapMarker>().PlayerName = Player.Name;
|
||||
|
||||
return body.gameObject;
|
||||
return body;
|
||||
}
|
||||
|
||||
public override bool IsReady => Locator.GetPlayerTransform() != null
|
||||
|
@ -23,17 +23,17 @@ namespace QSB.ProbeSync.TransformSync
|
||||
private Transform GetProbe() =>
|
||||
Locator.GetProbe().transform.Find("CameraPivot").Find("Geometry");
|
||||
|
||||
protected override GameObject InitLocalTransform()
|
||||
protected override Transform InitLocalTransform()
|
||||
{
|
||||
SectorSync.SetSectorDetector(Locator.GetProbe().GetSectorDetector());
|
||||
var body = GetProbe();
|
||||
|
||||
Player.ProbeBody = body.gameObject;
|
||||
|
||||
return body.gameObject;
|
||||
return body;
|
||||
}
|
||||
|
||||
protected override GameObject InitRemoteTransform()
|
||||
protected override Transform InitRemoteTransform()
|
||||
{
|
||||
var probe = GetProbe();
|
||||
|
||||
@ -52,7 +52,7 @@ namespace QSB.ProbeSync.TransformSync
|
||||
|
||||
Player.ProbeBody = body.gameObject;
|
||||
|
||||
return body.gameObject;
|
||||
return body;
|
||||
}
|
||||
|
||||
public override bool IsReady => Locator.GetProbe() != null
|
||||
|
@ -238,6 +238,10 @@
|
||||
<Compile Include="QuantumSync\QuantumManager.cs" />
|
||||
<Compile Include="QuantumSync\Patches\QuantumVisibilityPatches.cs" />
|
||||
<Compile Include="QuantumSync\Patches\ServerQuantumPatches.cs" />
|
||||
<Compile Include="Syncs\ISectoredSync.cs" />
|
||||
<Compile Include="Syncs\ISync.cs" />
|
||||
<Compile Include="Syncs\RigidbodySync\UnparentedBaseRigidbodySync.cs" />
|
||||
<Compile Include="Syncs\RigidbodySync\SectoredRigidbodySync.cs" />
|
||||
<Compile Include="Utility\CustomRelativisticParticleSystem.cs" />
|
||||
<Compile Include="RoastingSync\QSBMarshmallow.cs" />
|
||||
<Compile Include="RoastingSync\Events\EnterExitRoastingEvent.cs" />
|
||||
@ -255,7 +259,7 @@
|
||||
<Compile Include="StatueSync\StatueManager.cs" />
|
||||
<Compile Include="RoastingSync\TransformSync\RoastingStickTransformSync.cs" />
|
||||
<Compile Include="Syncs\TransformSync\BaseTransformSync.cs" />
|
||||
<Compile Include="Syncs\TransformSync\IntermediaryTransform.cs" />
|
||||
<Compile Include="Syncs\IntermediaryTransform.cs" />
|
||||
<Compile Include="Syncs\TransformSync\SectoredTransformSync.cs" />
|
||||
<Compile Include="Syncs\TransformSync\UnparentedBaseTransformSync.cs" />
|
||||
<Compile Include="TranslationSync\Events\SetAsTranslatedEvent.cs" />
|
||||
|
@ -20,15 +20,15 @@ namespace QSB.RoastingSync.TransformSync
|
||||
private Transform GetPivot()
|
||||
=> Resources.FindObjectsOfTypeAll<RoastingStickController>().First().transform.Find("Stick_Root/Stick_Pivot");
|
||||
|
||||
protected override GameObject InitLocalTransform()
|
||||
protected override Transform InitLocalTransform()
|
||||
{
|
||||
var pivot = GetPivot();
|
||||
Player.RoastingStick = pivot.gameObject;
|
||||
_stickTip = pivot.Find("Stick_Tip");
|
||||
return pivot.gameObject;
|
||||
return pivot;
|
||||
}
|
||||
|
||||
protected override GameObject InitRemoteTransform()
|
||||
protected override Transform InitRemoteTransform()
|
||||
{
|
||||
var newPivot = Instantiate(GetPivot());
|
||||
newPivot.parent = null;
|
||||
@ -58,7 +58,7 @@ namespace QSB.RoastingSync.TransformSync
|
||||
Player.Marshmallow = newMarshmallow;
|
||||
mallowRoot.gameObject.SetActive(true);
|
||||
_stickTip = newPivot.Find("Stick_Tip");
|
||||
return newPivot.gameObject;
|
||||
return newPivot;
|
||||
}
|
||||
|
||||
protected override void UpdateTransform()
|
||||
|
@ -1,5 +1,7 @@
|
||||
using OWML.Common;
|
||||
using QSB.SectorSync.WorldObjects;
|
||||
using QSB.Syncs;
|
||||
using QSB.Syncs.RigidbodySync;
|
||||
using QSB.Syncs.TransformSync;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
@ -27,7 +29,21 @@ namespace QSB.SectorSync
|
||||
continue;
|
||||
}
|
||||
if (sync.HasAuthority
|
||||
&& sync.AttachedObject.activeInHierarchy
|
||||
&& sync.AttachedObject.gameObject.activeInHierarchy
|
||||
&& sync.IsReady)
|
||||
{
|
||||
CheckTransformSyncSector(sync);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var sync in SectoredRigidbodySync.SectoredNetworkTransformList)
|
||||
{
|
||||
if (sync.AttachedObject == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (sync.HasAuthority
|
||||
&& sync.AttachedObject.gameObject.activeInHierarchy
|
||||
&& sync.IsReady)
|
||||
{
|
||||
CheckTransformSyncSector(sync);
|
||||
@ -64,7 +80,8 @@ namespace QSB.SectorSync
|
||||
IsReady = QSBWorldSync.GetWorldObjects<QSBSector>().Any();
|
||||
}
|
||||
|
||||
private void CheckTransformSyncSector(SectoredTransformSync transformSync)
|
||||
private void CheckTransformSyncSector<T>(ISectoredSync<T> transformSync)
|
||||
where T : Component
|
||||
{
|
||||
var attachedObject = transformSync.AttachedObject;
|
||||
var closestSector = transformSync.SectorSync.GetClosestSector(attachedObject.transform);
|
||||
|
@ -1,10 +1,11 @@
|
||||
using QSB.Syncs.RigidbodySync;
|
||||
using QSB.Syncs.TransformSync;
|
||||
using QSB.Utility;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.ShipSync.TransformSync
|
||||
{
|
||||
public class ShipTransformSync : SectoredTransformSync
|
||||
public class ShipTransformSync : SectoredRigidbodySync
|
||||
{
|
||||
public static ShipTransformSync LocalInstance { get; private set; }
|
||||
|
||||
@ -20,26 +21,10 @@ namespace QSB.ShipSync.TransformSync
|
||||
LocalInstance = this;
|
||||
}
|
||||
|
||||
protected override GameObject InitLocalTransform()
|
||||
protected override OWRigidbody GetRigidbody()
|
||||
{
|
||||
SectorSync.SetSectorDetector(Locator.GetShipDetector().GetComponent<SectorDetector>());
|
||||
return Locator.GetShipBody().gameObject;
|
||||
}
|
||||
|
||||
protected override GameObject InitRemoteTransform()
|
||||
{
|
||||
SectorSync.SetSectorDetector(Locator.GetShipDetector().GetComponent<SectorDetector>());
|
||||
return Locator.GetShipBody().gameObject;
|
||||
}
|
||||
|
||||
protected override void UpdateTransform()
|
||||
{
|
||||
base.UpdateTransform();
|
||||
|
||||
if (!HasAuthority && ReferenceSector != null)
|
||||
{
|
||||
Locator.GetShipBody().SetVelocity(ReferenceSector.AttachedObject.GetOWRigidbody().GetPointVelocity(Locator.GetShipTransform().position));
|
||||
}
|
||||
return Locator.GetShipBody();
|
||||
}
|
||||
}
|
||||
}
|
12
QSB/Syncs/ISectoredSync.cs
Normal file
12
QSB/Syncs/ISectoredSync.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using QSB.SectorSync.WorldObjects;
|
||||
|
||||
namespace QSB.Syncs
|
||||
{
|
||||
public interface ISectoredSync<T> : ISync<T>
|
||||
{
|
||||
SectorSync.SectorSync SectorSync { get; }
|
||||
QSBSector ReferenceSector { get; }
|
||||
|
||||
void SetReferenceSector(QSBSector sector);
|
||||
}
|
||||
}
|
17
QSB/Syncs/ISync.cs
Normal file
17
QSB/Syncs/ISync.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.Syncs
|
||||
{
|
||||
public interface ISync<T>
|
||||
{
|
||||
Transform ReferenceTransform { get; }
|
||||
T AttachedObject { get; }
|
||||
|
||||
bool IsReady { get; }
|
||||
bool UseInterpolation { get; }
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
using QSB.Utility;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.Syncs.TransformSync
|
||||
namespace QSB.Syncs
|
||||
{
|
||||
public class IntermediaryTransform
|
||||
{
|
114
QSB/Syncs/RigidbodySync/SectoredRigidbodySync.cs
Normal file
114
QSB/Syncs/RigidbodySync/SectoredRigidbodySync.cs
Normal file
@ -0,0 +1,114 @@
|
||||
using QSB.SectorSync;
|
||||
using QSB.SectorSync.WorldObjects;
|
||||
using QSB.Syncs.TransformSync;
|
||||
using QSB.WorldSync;
|
||||
using QuantumUNET.Transport;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace QSB.Syncs.RigidbodySync
|
||||
{
|
||||
public abstract class SectoredRigidbodySync : UnparentedBaseRigidbodySync, ISectoredSync<OWRigidbody>
|
||||
{
|
||||
public QSBSector ReferenceSector { get; set; }
|
||||
public SectorSync.SectorSync SectorSync { get; private set; }
|
||||
public static List<SectoredRigidbodySync> SectoredNetworkTransformList = new List<SectoredRigidbodySync>();
|
||||
|
||||
public override void Start()
|
||||
{
|
||||
SectorSync = gameObject.AddComponent<SectorSync.SectorSync>();
|
||||
SectoredNetworkTransformList.Add(this);
|
||||
base.Start();
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
SectoredNetworkTransformList.Remove(this);
|
||||
if (SectorSync != null)
|
||||
{
|
||||
Destroy(SectorSync);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
if (!QSBSectorManager.Instance.IsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var closestSector = SectorSync.GetClosestSector(AttachedObject.transform);
|
||||
if (closestSector != null)
|
||||
{
|
||||
SetReferenceTransform(closestSector.Transform);
|
||||
}
|
||||
}
|
||||
|
||||
public override void SerializeTransform(QNetworkWriter writer)
|
||||
{
|
||||
if (_intermediaryTransform == null)
|
||||
{
|
||||
_intermediaryTransform = new IntermediaryTransform(transform);
|
||||
}
|
||||
if (ReferenceSector != null)
|
||||
{
|
||||
writer.Write(ReferenceSector.ObjectId);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(-1);
|
||||
}
|
||||
base.SerializeTransform(writer);
|
||||
}
|
||||
|
||||
public override void DeserializeTransform(QNetworkReader reader)
|
||||
{
|
||||
if (!QSBCore.WorldObjectsReady)
|
||||
{
|
||||
reader.ReadInt32();
|
||||
reader.ReadVector3();
|
||||
DeserializeRotation(reader);
|
||||
return;
|
||||
}
|
||||
|
||||
var sectorId = reader.ReadInt32();
|
||||
var sector = sectorId == -1
|
||||
? null
|
||||
: QSBWorldSync.GetWorldFromId<QSBSector>(sectorId);
|
||||
|
||||
if (sector != ReferenceSector)
|
||||
{
|
||||
SetReferenceSector(sector);
|
||||
}
|
||||
|
||||
base.DeserializeTransform(reader);
|
||||
}
|
||||
|
||||
protected override void UpdateTransform()
|
||||
{
|
||||
if ((ReferenceTransform == null || ReferenceSector == null) && QSBSectorManager.Instance.IsReady)
|
||||
{
|
||||
var closestSector = SectorSync.GetClosestSector(AttachedObject.transform);
|
||||
if (closestSector != null)
|
||||
{
|
||||
SetReferenceTransform(closestSector.Transform);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
base.UpdateTransform();
|
||||
}
|
||||
|
||||
public void SetReferenceSector(QSBSector sector)
|
||||
{
|
||||
ReferenceSector = sector;
|
||||
SetReferenceTransform(sector.Transform);
|
||||
}
|
||||
}
|
||||
}
|
214
QSB/Syncs/RigidbodySync/UnparentedBaseRigidbodySync.cs
Normal file
214
QSB/Syncs/RigidbodySync/UnparentedBaseRigidbodySync.cs
Normal file
@ -0,0 +1,214 @@
|
||||
using OWML.Common;
|
||||
using QSB.Syncs.TransformSync;
|
||||
using QSB.Utility;
|
||||
using QuantumUNET.Components;
|
||||
using QuantumUNET.Transport;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.Syncs.RigidbodySync
|
||||
{
|
||||
public abstract class UnparentedBaseRigidbodySync : QNetworkTransform, ISync<OWRigidbody>
|
||||
{
|
||||
public Transform ReferenceTransform { get; set; }
|
||||
public OWRigidbody AttachedObject { get; set; }
|
||||
|
||||
public abstract bool IsReady { get; }
|
||||
public abstract bool UseInterpolation { get; }
|
||||
|
||||
protected bool _isInitialized;
|
||||
protected IntermediaryTransform _intermediaryTransform;
|
||||
protected Vector3 _velocity;
|
||||
protected Vector3 _angularVelocity;
|
||||
private string _logName => $"{NetId}:{GetType().Name}";
|
||||
|
||||
protected abstract OWRigidbody GetRigidbody();
|
||||
|
||||
public virtual void Start()
|
||||
{
|
||||
DontDestroyOnLoad(gameObject);
|
||||
_intermediaryTransform = new IntermediaryTransform(transform);
|
||||
QSBSceneManager.OnSceneLoaded += OnSceneLoaded;
|
||||
}
|
||||
|
||||
protected virtual void OnDestroy()
|
||||
{
|
||||
QSBSceneManager.OnSceneLoaded -= OnSceneLoaded;
|
||||
}
|
||||
|
||||
private void OnSceneLoaded(OWScene scene, bool isInUniverse)
|
||||
=> _isInitialized = false;
|
||||
|
||||
protected virtual void Init()
|
||||
{
|
||||
if (!QSBSceneManager.IsInUniverse)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - {_logName} is being init-ed when not in the universe!", MessageType.Error);
|
||||
}
|
||||
AttachedObject = GetRigidbody();
|
||||
_isInitialized = true;
|
||||
}
|
||||
|
||||
public override void SerializeTransform(QNetworkWriter writer)
|
||||
{
|
||||
if (_intermediaryTransform == null)
|
||||
{
|
||||
_intermediaryTransform = new IntermediaryTransform(transform);
|
||||
}
|
||||
|
||||
/* We need to send :
|
||||
* - Position
|
||||
* - Rotation
|
||||
* - Velocity
|
||||
* - Angular velocity
|
||||
* We can't store the last two on the IntermediaryTransform, so they come from fields.
|
||||
*/
|
||||
|
||||
// Get world position from IT.
|
||||
|
||||
// Get world rotation from IT.
|
||||
|
||||
// Get velocity from field.
|
||||
|
||||
// Get angular velocity from field.
|
||||
|
||||
// Send all.
|
||||
|
||||
// Set _prev fields.
|
||||
|
||||
var worldPos = _intermediaryTransform.GetPosition();
|
||||
var worldRot = _intermediaryTransform.GetRotation();
|
||||
var velocity = _velocity;
|
||||
var angularVelocity = _angularVelocity;
|
||||
|
||||
writer.Write(worldPos);
|
||||
SerializeRotation(writer, worldRot);
|
||||
writer.Write(velocity);
|
||||
writer.Write(angularVelocity);
|
||||
_prevPosition = worldPos;
|
||||
_prevRotation = worldRot;
|
||||
}
|
||||
|
||||
public override void DeserializeTransform(QNetworkReader reader)
|
||||
{
|
||||
if (!QSBCore.WorldObjectsReady)
|
||||
{
|
||||
reader.ReadVector3();
|
||||
DeserializeRotation(reader);
|
||||
reader.ReadVector3();
|
||||
reader.ReadVector3();
|
||||
return;
|
||||
}
|
||||
|
||||
var pos = reader.ReadVector3();
|
||||
var rot = DeserializeRotation(reader);
|
||||
var vel = reader.ReadVector3();
|
||||
var angVel = reader.ReadVector3();
|
||||
|
||||
if (HasAuthority)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_intermediaryTransform == null)
|
||||
{
|
||||
_intermediaryTransform = new IntermediaryTransform(transform);
|
||||
}
|
||||
|
||||
_intermediaryTransform.SetPosition(pos);
|
||||
_intermediaryTransform.SetRotation(rot);
|
||||
_velocity = vel;
|
||||
_angularVelocity = angVel;
|
||||
|
||||
if (_intermediaryTransform.GetPosition() == Vector3.zero)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - {_logName} at (0,0,0)! - Given position was {pos}", MessageType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (!_isInitialized && IsReady)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
else if (_isInitialized && !IsReady)
|
||||
{
|
||||
_isInitialized = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_isInitialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (AttachedObject == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - AttachedRigidbody {_logName} is null.", MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AttachedObject.gameObject.activeInHierarchy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateTransform();
|
||||
|
||||
base.Update();
|
||||
}
|
||||
|
||||
protected virtual void UpdateTransform()
|
||||
{
|
||||
if (HasAuthority)
|
||||
{
|
||||
_intermediaryTransform.EncodePosition(AttachedObject.transform.position);
|
||||
_intermediaryTransform.EncodeRotation(AttachedObject.transform.rotation);
|
||||
_velocity = AttachedObject.GetRelativeVelocity(ReferenceTransform.GetAttachedOWRigidbody());
|
||||
_angularVelocity = AttachedObject.GetRelativeAngularVelocity(ReferenceTransform.GetAttachedOWRigidbody());
|
||||
return;
|
||||
}
|
||||
|
||||
var targetPos = _intermediaryTransform.GetTargetPosition_Unparented();
|
||||
var targetRot = _intermediaryTransform.GetTargetRotation_Unparented();
|
||||
|
||||
if (targetPos == Vector3.zero || _intermediaryTransform.GetTargetPosition_ParentedToReference() == Vector3.zero)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AttachedObject.SetPosition(targetPos);
|
||||
AttachedObject.SetRotation(targetRot);
|
||||
AttachedObject.SetVelocity(ReferenceTransform.GetAttachedOWRigidbody().GetVelocity() + _velocity);
|
||||
AttachedObject.SetAngularVelocity(ReferenceTransform.GetAttachedOWRigidbody().GetAngularVelocity() + _angularVelocity);
|
||||
}
|
||||
|
||||
public void SetReferenceTransform(Transform transform)
|
||||
{
|
||||
if (ReferenceTransform == transform)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ReferenceTransform = transform;
|
||||
_intermediaryTransform.SetReferenceTransform(transform);
|
||||
}
|
||||
|
||||
private void OnRenderObject()
|
||||
{
|
||||
if (!QSBCore.WorldObjectsReady || !QSBCore.DebugMode || !QSBCore.ShowLinesInDebug || !IsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Popcron.Gizmos.Cube(_intermediaryTransform.GetTargetPosition_Unparented(), _intermediaryTransform.GetTargetRotation_Unparented(), Vector3.one / 2, Color.red);
|
||||
Popcron.Gizmos.Line(_intermediaryTransform.GetTargetPosition_Unparented(), AttachedObject.transform.position, Color.red);
|
||||
var color = HasMoved() ? Color.green : Color.yellow;
|
||||
Popcron.Gizmos.Cube(AttachedObject.transform.position, AttachedObject.transform.rotation, Vector3.one / 2, color);
|
||||
Popcron.Gizmos.Line(AttachedObject.transform.position, ReferenceTransform.position, Color.cyan);
|
||||
}
|
||||
}
|
||||
}
|
@ -10,24 +10,24 @@ using UnityEngine;
|
||||
namespace QSB.Syncs.TransformSync
|
||||
{
|
||||
/*
|
||||
* Rewrite number : 4
|
||||
* Rewrite number : 5
|
||||
* God has cursed me for my hubris, and my work is never finished.
|
||||
*/
|
||||
|
||||
public abstract class BaseTransformSync : QNetworkTransform
|
||||
public abstract class BaseTransformSync : QNetworkTransform, ISync<Transform>
|
||||
{
|
||||
public uint AttachedNetId => NetIdentity?.NetId.Value ?? uint.MaxValue;
|
||||
public uint PlayerId => NetIdentity.RootIdentity?.NetId.Value ?? NetIdentity.NetId.Value;
|
||||
public PlayerInfo Player => QSBPlayerManager.GetPlayer(PlayerId);
|
||||
|
||||
public Transform ReferenceTransform { get; set; }
|
||||
public GameObject AttachedObject { get; set; }
|
||||
public Transform AttachedObject { get; set; }
|
||||
|
||||
public abstract bool IsReady { get; }
|
||||
public abstract bool UseInterpolation { get; }
|
||||
|
||||
protected abstract GameObject InitLocalTransform();
|
||||
protected abstract GameObject InitRemoteTransform();
|
||||
protected abstract Transform InitLocalTransform();
|
||||
protected abstract Transform InitRemoteTransform();
|
||||
|
||||
protected bool _isInitialized;
|
||||
private const float SmoothTime = 0.1f;
|
||||
@ -144,7 +144,7 @@ namespace QSB.Syncs.TransformSync
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AttachedObject.activeInHierarchy)
|
||||
if (!AttachedObject.gameObject.activeInHierarchy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -3,10 +3,11 @@ using QSB.SectorSync.WorldObjects;
|
||||
using QSB.WorldSync;
|
||||
using QuantumUNET.Transport;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.Syncs.TransformSync
|
||||
{
|
||||
public abstract class SectoredTransformSync : BaseTransformSync
|
||||
public abstract class SectoredTransformSync : BaseTransformSync, ISectoredSync<Transform>
|
||||
{
|
||||
public QSBSector ReferenceSector { get; set; }
|
||||
public SectorSync.SectorSync SectorSync { get; private set; }
|
||||
|
@ -9,7 +9,7 @@ using UnityEngine;
|
||||
|
||||
namespace QSB.Syncs.TransformSync
|
||||
{
|
||||
public abstract class UnparentedBaseTransformSync : QNetworkTransform
|
||||
public abstract class UnparentedBaseTransformSync : QNetworkTransform, ISync<GameObject>
|
||||
{
|
||||
public uint AttachedNetId => NetIdentity?.NetId.Value ?? uint.MaxValue;
|
||||
public uint PlayerId => NetIdentity.RootIdentity?.NetId.Value ?? NetIdentity.NetId.Value;
|
||||
|
@ -72,5 +72,10 @@ namespace QSB.Utility
|
||||
var methodAction = (Action)Activator.CreateInstance(typeof(Action), obj, functionPointer);
|
||||
methodAction();
|
||||
}
|
||||
|
||||
// OW
|
||||
|
||||
public static Vector3 GetRelativeAngularVelocity(this OWRigidbody baseBody, OWRigidbody relativeBody)
|
||||
=> relativeBody.GetAngularVelocity() - baseBody.GetAngularVelocity();
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,10 @@
|
||||
<Reference Include="UnityEngine.Networking">
|
||||
<HintPath>$(GameDir)\OuterWilds_Data\Managed\UnityEngine.Networking.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UNETModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(GameDir)\OuterWilds_Data\Managed\UnityEngine.UNETModule.dll</HintPath>
|
||||
|
Loading…
x
Reference in New Issue
Block a user