49 lines
1.3 KiB
C#
Raw Normal View History

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;
using UnityEngine;
namespace QSB.TransformSync
{
2020-08-31 09:36:29 +01:00
public class PlayerCameraSync : TransformSync
{
public static PlayerCameraSync LocalInstance { get; private set; }
public override void OnStartLocalPlayer()
{
LocalInstance = this;
}
2020-08-20 19:31:10 +01:00
protected override Transform InitLocalTransform()
{
var body = Locator.GetPlayerCamera().gameObject.transform;
Player.Camera = body.gameObject;
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
return body;
}
protected override Transform InitRemoteTransform()
{
2020-09-02 11:17:04 +01:00
var body = new GameObject("RemotePlayerCamera");
PlayerToolsManager.Init(body.transform);
Player.Camera = body;
return body.transform;
}
2020-09-04 20:10:01 +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;
}
}