2021-12-17 19:16:22 -08:00

47 lines
989 B
C#

using QSB.Anglerfish.TransformSync;
using QSB.WorldSync;
using QuantumUNET;
using UnityEngine;
namespace QSB.Anglerfish.WorldObjects
{
public class QSBAngler : WorldObject<AnglerfishController>
{
public AnglerTransformSync TransformSync;
public Transform TargetTransform;
public Vector3 TargetVelocity { get; private set; }
private Vector3 _lastTargetPosition;
public override void Init()
{
if (QSBCore.IsHost)
{
QNetworkServer.Spawn(Object.Instantiate(QSBNetworkManager.Instance.AnglerPrefab));
}
StartDelayedReady();
QSBCore.UnityEvents.RunWhen(() => TransformSync, FinishDelayedReady);
}
public override void OnRemoval()
{
if (QSBCore.IsHost)
{
QNetworkServer.Destroy(TransformSync.gameObject);
}
}
public void UpdateTargetVelocity()
{
if (TargetTransform == null)
{
return;
}
TargetVelocity = TargetTransform.position - _lastTargetPosition;
_lastTargetPosition = TargetTransform.position;
}
}
}