2020-08-10 19:24:28 +02:00
|
|
|
|
using QSB.Events;
|
|
|
|
|
using QSB.Tools;
|
2020-07-28 00:13:43 +01:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace QSB.TransformSync
|
|
|
|
|
{
|
|
|
|
|
public class PlayerCameraSync : TransformSync
|
|
|
|
|
{
|
|
|
|
|
public static PlayerCameraSync LocalInstance { get; private set; }
|
|
|
|
|
|
2020-08-18 21:31:14 +02:00
|
|
|
|
protected override uint PlayerIdOffset => 2;
|
|
|
|
|
|
2020-07-28 00:13:43 +01:00
|
|
|
|
public override void OnStartLocalPlayer()
|
|
|
|
|
{
|
|
|
|
|
LocalInstance = this;
|
|
|
|
|
}
|
2020-08-18 21:31:14 +02:00
|
|
|
|
|
2020-07-28 00:13:43 +01:00
|
|
|
|
protected override Transform InitLocalTransform()
|
|
|
|
|
{
|
|
|
|
|
var body = Locator.GetPlayerCamera().gameObject.transform;
|
|
|
|
|
|
|
|
|
|
PlayerToolsManager.Init(body);
|
|
|
|
|
|
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);
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
var body = new GameObject("PlayerCamera");
|
|
|
|
|
|
|
|
|
|
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-08-18 21:29:31 +01:00
|
|
|
|
public override bool IsReady => Locator.GetPlayerTransform() != null && PlayerRegistry.PlayerExists(PlayerId);
|
2020-07-28 00:13:43 +01:00
|
|
|
|
}
|
|
|
|
|
}
|