2020-08-10 19:24:28 +02:00
|
|
|
|
using QSB.Events;
|
|
|
|
|
using QSB.Tools;
|
2020-08-24 15:51:12 +01:00
|
|
|
|
using QSB.Utility;
|
2020-07-28 00:13:43 +01:00
|
|
|
|
using UnityEngine;
|
2020-09-03 17:09:38 +01:00
|
|
|
|
using UnityEngine.Networking;
|
2020-07-28 00:13:43 +01:00
|
|
|
|
|
|
|
|
|
namespace QSB.TransformSync
|
|
|
|
|
{
|
2020-08-31 09:36:29 +01:00
|
|
|
|
public class PlayerCameraSync : TransformSync
|
2020-07-28 00:13:43 +01:00
|
|
|
|
{
|
|
|
|
|
public static PlayerCameraSync LocalInstance { get; private set; }
|
|
|
|
|
|
|
|
|
|
public override void OnStartLocalPlayer()
|
|
|
|
|
{
|
|
|
|
|
LocalInstance = this;
|
|
|
|
|
}
|
2020-08-20 19:31:10 +01:00
|
|
|
|
|
2020-07-28 00:13:43 +01:00
|
|
|
|
protected override Transform InitLocalTransform()
|
|
|
|
|
{
|
|
|
|
|
var body = Locator.GetPlayerCamera().gameObject.transform;
|
|
|
|
|
|
2020-08-07 20:39:07 +01:00
|
|
|
|
Player.Camera = body.gameObject;
|
2020-07-28 00:13:43 +01:00
|
|
|
|
|
2020-08-10 11:45:24 +01:00
|
|
|
|
Player.IsReady = true;
|
2020-08-10 19:24:28 +02:00
|
|
|
|
GlobalMessenger<bool>.FireEvent(EventNames.QSBPlayerReady, true);
|
2020-08-24 15:51:12 +01:00
|
|
|
|
DebugLog.DebugWrite("PlayerCameraSync init done - Request state!");
|
2020-08-10 19:24:28 +02:00
|
|
|
|
GlobalMessenger.FireEvent(EventNames.QSBPlayerStatesRequest);
|
2020-08-10 11:45:24 +01:00
|
|
|
|
|
2020-07-28 00:13:43 +01:00
|
|
|
|
return body;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Transform InitRemoteTransform()
|
|
|
|
|
{
|
2020-09-02 11:17:04 +01:00
|
|
|
|
var body = new GameObject("RemotePlayerCamera");
|
2020-07-28 00:13:43 +01:00
|
|
|
|
|
|
|
|
|
PlayerToolsManager.Init(body.transform);
|
|
|
|
|
|
2020-08-07 20:39:07 +01:00
|
|
|
|
Player.Camera = body;
|
2020-07-28 00:13:43 +01:00
|
|
|
|
|
|
|
|
|
return body.transform;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-03 17:09:38 +01:00
|
|
|
|
public override bool IsReady => Locator.GetPlayerTransform() != null
|
|
|
|
|
&& Player != null
|
|
|
|
|
&& PlayerRegistry.PlayerExists(Player.PlayerId)
|
2020-09-04 20:09:25 +01:00
|
|
|
|
&& netId.Value != uint.MaxValue
|
2020-09-03 17:09:38 +01:00
|
|
|
|
&& netId.Value != 0U;
|
2020-07-28 00:13:43 +01:00
|
|
|
|
}
|
|
|
|
|
}
|