65 lines
1.5 KiB
C#
Raw Normal View History

2020-09-02 11:17:04 +01:00
using OWML.Common;
2020-11-03 21:33:48 +00:00
using QSB.Player;
2021-05-02 13:59:39 +01:00
using QSB.Syncs.TransformSync;
2021-05-03 20:27:52 +01:00
using QSB.Tools;
2020-08-23 10:07:43 +02:00
using QSB.Utility;
using UnityEngine;
2021-04-11 17:05:02 +01:00
namespace QSB.ProbeSync.TransformSync
{
2021-04-28 00:22:08 +01:00
public class PlayerProbeSync : SectoredTransformSync
2020-12-14 21:20:53 +00:00
{
2021-04-20 08:36:07 +01:00
public static PlayerProbeSync LocalInstance { get; private set; }
2021-04-21 16:49:30 +01:00
protected override float DistanceLeeway => 10f;
2021-04-28 10:02:16 +01:00
public override bool UseInterpolation => true;
2021-04-21 16:49:30 +01:00
2021-04-20 08:36:07 +01:00
public override void OnStartAuthority()
2021-04-28 00:22:08 +01:00
{
DebugLog.DebugWrite($"OnStartAuthority probe");
LocalInstance = this;
}
2021-04-20 08:36:07 +01:00
2020-12-14 21:48:41 +01:00
private Transform GetProbe() =>
2020-12-14 21:20:53 +00:00
Locator.GetProbe().transform.Find("CameraPivot").Find("Geometry");
2020-12-14 21:41:56 +01:00
protected override Transform InitLocalTransform()
2020-12-14 21:20:53 +00:00
{
2021-03-09 19:45:00 +00:00
SectorSync.SetSectorDetector(Locator.GetProbe().GetSectorDetector());
2020-12-14 21:20:53 +00:00
var body = GetProbe();
2020-12-14 21:41:56 +01:00
2020-12-14 21:20:53 +00:00
Player.ProbeBody = body.gameObject;
2020-12-14 21:41:56 +01:00
return body;
2020-12-14 21:20:53 +00:00
}
2020-12-14 21:41:56 +01:00
protected override Transform InitRemoteTransform()
2020-12-14 21:20:53 +00:00
{
var probe = GetProbe();
2020-12-14 21:41:56 +01:00
2020-12-14 21:20:53 +00:00
if (probe == null)
{
DebugLog.ToConsole("Error - Probe is null!", MessageType.Error);
return default;
}
2020-12-14 21:41:56 +01:00
2020-12-14 21:20:53 +00:00
var body = probe.InstantiateInactive();
body.name = "RemoteProbeTransform";
2020-12-14 21:41:56 +01:00
2020-12-14 21:20:53 +00:00
Destroy(body.GetComponentInChildren<ProbeAnimatorController>());
2020-12-14 21:41:56 +01:00
2020-12-14 21:20:53 +00:00
PlayerToolsManager.CreateProbe(body, Player);
2020-12-14 21:41:56 +01:00
2020-12-14 21:20:53 +00:00
Player.ProbeBody = body.gameObject;
2020-12-14 21:41:56 +01:00
return body;
2020-12-14 21:20:53 +00:00
}
2020-12-14 21:41:56 +01:00
2020-12-14 21:20:53 +00:00
public override bool IsReady => Locator.GetProbe() != null
&& Player != null
&& QSBPlayerManager.PlayerExists(Player.PlayerId)
2021-04-18 18:46:55 +01:00
&& Player.PlayerStates.IsReady
2020-12-14 21:20:53 +00:00
&& NetId.Value != uint.MaxValue
&& NetId.Value != 0U;
}
2020-12-03 08:28:05 +00:00
}