mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-09 12:54:51 +00:00
35 lines
940 B
C#
35 lines
940 B
C#
using QSB.Anglerfish.Messages;
|
|
using QSB.Anglerfish.TransformSync;
|
|
using QSB.Messaging;
|
|
using QSB.Utility.LinkedWorldObject;
|
|
using UnityEngine;
|
|
|
|
namespace QSB.Anglerfish.WorldObjects;
|
|
|
|
public class QSBAngler : LinkedWorldObject<AnglerfishController, AnglerTransformSync>
|
|
{
|
|
public override bool ShouldDisplayDebug() => false;
|
|
|
|
public Transform TargetTransform;
|
|
public Vector3 TargetVelocity { get; private set; }
|
|
|
|
private Vector3 _lastTargetPosition;
|
|
|
|
protected override GameObject NetworkObjectPrefab => QSBNetworkManager.singleton.AnglerPrefab;
|
|
protected override bool SpawnWithServerAuthority => false;
|
|
|
|
public override void SendInitialState(uint to) =>
|
|
this.SendMessage(new AnglerDataMessage(this) { To = to });
|
|
|
|
public void UpdateTargetVelocity()
|
|
{
|
|
if (TargetTransform == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
TargetVelocity = TargetTransform.position - _lastTargetPosition;
|
|
_lastTargetPosition = TargetTransform.position;
|
|
}
|
|
}
|