39 lines
1.0 KiB
C#
Raw Normal View History

2021-11-09 17:56:45 -08:00
using System.Collections.Generic;
using QSB.Anglerfish.WorldObjects;
using QSB.Syncs.Unsectored.Rigidbodies;
using QSB.WorldSync;
namespace QSB.Anglerfish.TransformSync
{
public class AnglerTransformSync : UnsectoredRigidbodySync
{
public override bool IsReady => QSBCore.WorldObjectsReady;
public override bool UseInterpolation => true;
2021-11-09 18:38:19 -08:00
protected override OWRigidbody GetRigidbody() => _qsbAngler.AttachedObject._anglerBody;
2021-11-09 17:56:45 -08:00
2021-11-09 18:38:19 -08:00
private QSBAngler _qsbAngler;
2021-11-09 17:56:45 -08:00
private static readonly List<AnglerTransformSync> _instances = new List<AnglerTransformSync>();
public override void Start()
{
_instances.Add(this);
base.Start();
}
protected override void OnDestroy()
{
_instances.Remove(this);
base.OnDestroy();
}
public override float GetNetworkSendInterval() => 1 / 4f;
2021-11-09 17:56:45 -08:00
protected override void Init()
{
2021-11-09 18:38:19 -08:00
_qsbAngler = QSBWorldSync.GetWorldFromId<QSBAngler>(_instances.IndexOf(this));
_qsbAngler.transformSync = this;
2021-11-09 17:56:45 -08:00
base.Init();
2021-11-09 18:38:19 -08:00
SetReferenceTransform(_qsbAngler.AttachedObject._brambleBody._transform);
2021-11-09 17:56:45 -08:00
}
}
}