quantum-space-buddies/QSB/TransformSync/PlayerCameraSync.cs

49 lines
1.3 KiB
C#
Raw Normal View History

2020-08-10 17:24:28 +00:00
using QSB.Events;
using QSB.Tools;
2020-08-24 14:51:12 +00:00
using QSB.Utility;
using UnityEngine;
namespace QSB.TransformSync
{
2020-08-31 08:36:29 +00:00
public class PlayerCameraSync : TransformSync
{
public static PlayerCameraSync LocalInstance { get; private set; }
public override void OnStartLocalPlayer()
{
LocalInstance = this;
}
2020-08-20 18:31:10 +00:00
protected override Transform InitLocalTransform()
{
var body = Locator.GetPlayerCamera().gameObject.transform;
Player.Camera = body.gameObject;
2020-08-10 10:45:24 +00:00
Player.IsReady = true;
2020-08-10 17:24:28 +00:00
GlobalMessenger<bool>.FireEvent(EventNames.QSBPlayerReady, true);
2020-08-24 14:51:12 +00:00
DebugLog.DebugWrite("PlayerCameraSync init done - Request state!");
2020-08-10 17:24:28 +00:00
GlobalMessenger.FireEvent(EventNames.QSBPlayerStatesRequest);
2020-08-10 10:45:24 +00:00
return body;
}
protected override Transform InitRemoteTransform()
{
2020-09-02 10:17:04 +00:00
var body = new GameObject("RemotePlayerCamera");
PlayerToolsManager.Init(body.transform);
Player.Camera = body;
return body.transform;
}
2020-09-04 19:10:01 +00:00
public override bool IsReady => Locator.GetPlayerTransform() != null
&& Player != null
2020-11-03 21:18:40 +00:00
&& QSBPlayerManager.PlayerExists(Player.PlayerId)
2020-09-04 19:09:25 +00:00
&& netId.Value != uint.MaxValue
2020-09-03 16:09:38 +00:00
&& netId.Value != 0U;
}
}