2020-07-30 22:27:14 +02:00
|
|
|
|
using QSB.Tools;
|
2020-08-09 21:46:51 +01:00
|
|
|
|
using QSB.Utility;
|
2020-07-28 00:13:43 +01:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace QSB.TransformSync
|
|
|
|
|
{
|
|
|
|
|
public class PlayerCameraSync : TransformSync
|
|
|
|
|
{
|
|
|
|
|
public static PlayerCameraSync LocalInstance { get; private set; }
|
|
|
|
|
|
|
|
|
|
public override void OnStartLocalPlayer()
|
|
|
|
|
{
|
|
|
|
|
LocalInstance = this;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-07 20:39:07 +01:00
|
|
|
|
protected override uint PlayerId => netId.Value - 2;
|
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
|
|
|
|
|
|
|
|
|
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-07 20:39:07 +01:00
|
|
|
|
protected override bool IsReady => Locator.GetPlayerTransform() != null && Player != null;
|
2020-07-28 00:13:43 +01:00
|
|
|
|
}
|
|
|
|
|
}
|