46 lines
1.1 KiB
C#
Raw Normal View History

2020-08-10 18:17:54 +02:00
using QSB.Tools;
using UnityEngine;
namespace QSB.TransformSync
{
public class PlayerCameraSync : TransformSync
{
public static PlayerCameraSync LocalInstance { get; private set; }
public override void OnStartLocalPlayer()
{
LocalInstance = this;
}
protected override uint PlayerId => netId.Value - 2;
protected override Transform InitLocalTransform()
{
var body = Locator.GetPlayerCamera().gameObject.transform;
PlayerToolsManager.Init(body);
Player.Camera = body.gameObject;
2020-08-10 11:45:24 +01:00
Player.IsReady = true;
GlobalMessenger<bool>.FireEvent("QSBPlayerReady", true);
2020-08-10 14:40:06 +01:00
GlobalMessenger.FireEvent("QSBPlayerStatesRequest");
2020-08-10 11:45:24 +01:00
return body;
}
protected override Transform InitRemoteTransform()
{
var body = new GameObject("PlayerCamera");
PlayerToolsManager.Init(body.transform);
Player.Camera = body;
return body.transform;
}
protected override bool IsReady => Locator.GetPlayerTransform() != null && Player != null;
}
}