2021-05-02 12:59:39 +00:00
|
|
|
|
using QSB.Syncs.TransformSync;
|
2021-04-28 09:02:16 +00:00
|
|
|
|
using QSB.Utility;
|
|
|
|
|
using QSB.WorldSync;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace QSB.OrbSync.TransformSync
|
|
|
|
|
{
|
2021-04-28 15:32:01 +00:00
|
|
|
|
internal class NomaiOrbTransformSync : UnparentedBaseTransformSync
|
2021-04-28 09:02:16 +00:00
|
|
|
|
{
|
2021-04-28 15:32:01 +00:00
|
|
|
|
public static List<NomaiOrbTransformSync> OrbTransformSyncs = new List<NomaiOrbTransformSync>();
|
2021-04-28 09:02:16 +00:00
|
|
|
|
|
|
|
|
|
private int _index => OrbTransformSyncs.IndexOf(this);
|
|
|
|
|
|
2021-05-19 10:52:39 +00:00
|
|
|
|
public override void OnStartClient() => OrbTransformSyncs.Add(this);
|
2021-04-28 09:02:16 +00:00
|
|
|
|
|
|
|
|
|
protected override void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
OrbTransformSyncs.Remove(this);
|
2021-04-29 22:57:55 +00:00
|
|
|
|
QSBSceneManager.OnSceneLoaded -= OnSceneLoaded;
|
2021-04-28 09:02:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Init()
|
|
|
|
|
{
|
|
|
|
|
base.Init();
|
|
|
|
|
SetReferenceTransform(AttachedObject.GetAttachedOWRigidbody().GetOrigParent());
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-07 21:12:41 +00:00
|
|
|
|
private Transform GetTransform()
|
2021-05-08 11:53:09 +00:00
|
|
|
|
{
|
2021-05-18 14:22:21 +00:00
|
|
|
|
if (_index == -1)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.ToConsole($"Error - Index cannot be found.", OWML.Common.MessageType.Error);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2021-06-18 21:38:32 +00:00
|
|
|
|
|
2021-05-08 11:53:09 +00:00
|
|
|
|
if (QSBWorldSync.OldOrbList == null || QSBWorldSync.OldOrbList.Count <= _index)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.ToConsole($"Error - OldOrbList is null or does not contain index {_index}.", OWML.Common.MessageType.Error);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2021-06-18 21:38:32 +00:00
|
|
|
|
|
2021-05-08 15:57:01 +00:00
|
|
|
|
if (QSBWorldSync.OldOrbList[_index] == null)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.ToConsole($"Error - OldOrbList index {_index} is null.", OWML.Common.MessageType.Error);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2021-06-18 21:38:32 +00:00
|
|
|
|
|
2021-07-07 21:12:41 +00:00
|
|
|
|
return QSBWorldSync.OldOrbList[_index].transform;
|
2021-05-08 11:53:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-07 22:54:09 +00:00
|
|
|
|
protected override Component InitLocalTransform() => GetTransform();
|
|
|
|
|
protected override Component InitRemoteTransform() => GetTransform();
|
2021-04-28 09:02:16 +00:00
|
|
|
|
|
2021-05-08 15:57:01 +00:00
|
|
|
|
public override bool IsReady => QSBCore.WorldObjectsReady;
|
2021-04-28 09:02:16 +00:00
|
|
|
|
public override bool UseInterpolation => false;
|
|
|
|
|
}
|
|
|
|
|
}
|