2022-03-14 10:22:44 +00:00
|
|
|
|
using QSB.Anglerfish.Messages;
|
2022-01-15 06:54:18 +00:00
|
|
|
|
using QSB.Anglerfish.TransformSync;
|
2022-01-21 23:13:16 +00:00
|
|
|
|
using QSB.Messaging;
|
2022-03-14 08:53:12 +00:00
|
|
|
|
using QSB.Utility.LinkedWorldObject;
|
2021-11-10 01:56:45 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
namespace QSB.Anglerfish.WorldObjects;
|
|
|
|
|
|
2022-03-14 10:22:44 +00:00
|
|
|
|
public class QSBAngler : LinkedWorldObject<AnglerfishController, AnglerTransformSync>
|
2021-11-10 01:56:45 +00:00
|
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public override bool ShouldDisplayDebug() => false;
|
2022-01-22 01:56:20 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public Transform TargetTransform;
|
|
|
|
|
public Vector3 TargetVelocity { get; private set; }
|
2021-11-10 09:28:05 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
private Vector3 _lastTargetPosition;
|
2021-11-10 01:56:45 +00:00
|
|
|
|
|
2022-03-14 10:22:44 +00:00
|
|
|
|
protected override GameObject NetworkObjectPrefab => QSBNetworkManager.singleton.AnglerPrefab;
|
2022-03-14 10:44:52 +00:00
|
|
|
|
protected override bool SpawnWithServerAuthority => false;
|
2021-11-10 02:38:19 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public override void SendInitialState(uint to) =>
|
|
|
|
|
this.SendMessage(new AnglerDataMessage(this) { To = to });
|
2022-01-21 23:13:16 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public void UpdateTargetVelocity()
|
|
|
|
|
{
|
|
|
|
|
if (TargetTransform == null)
|
2021-11-10 04:35:55 +00:00
|
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
|
return;
|
2022-02-27 12:40:44 +00:00
|
|
|
|
}
|
2022-03-03 03:46:33 +00:00
|
|
|
|
|
|
|
|
|
TargetVelocity = TargetTransform.position - _lastTargetPosition;
|
|
|
|
|
_lastTargetPosition = TargetTransform.position;
|
2021-11-10 01:56:45 +00:00
|
|
|
|
}
|
2022-03-14 10:22:44 +00:00
|
|
|
|
}
|