43 lines
1021 B
C#
Raw Normal View History

using QSB.Tools;
2020-08-09 21:46:51 +01:00
using QSB.Utility;
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;
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;
}
}