mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-11 00:52:19 +00:00
50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
using QSB.EventsCore;
|
|
using QSB.Player;
|
|
using QSB.Tools;
|
|
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 Transform InitLocalTransform()
|
|
{
|
|
var body = Locator.GetPlayerCamera().gameObject.transform;
|
|
|
|
Player.Camera = body.gameObject;
|
|
|
|
Player.IsReady = true;
|
|
GlobalMessenger<bool>.FireEvent(EventNames.QSBPlayerReady, true);
|
|
DebugLog.DebugWrite("PlayerCameraSync init done - Request state!");
|
|
GlobalMessenger.FireEvent(EventNames.QSBPlayerStatesRequest);
|
|
|
|
return body;
|
|
}
|
|
|
|
protected override Transform InitRemoteTransform()
|
|
{
|
|
var body = new GameObject("RemotePlayerCamera");
|
|
|
|
PlayerToolsManager.Init(body.transform);
|
|
|
|
Player.Camera = body;
|
|
|
|
return body.transform;
|
|
}
|
|
|
|
public override bool IsReady => Locator.GetPlayerTransform() != null
|
|
&& Player != null
|
|
&& QSBPlayerManager.PlayerExists(Player.PlayerId)
|
|
&& netId.Value != uint.MaxValue
|
|
&& netId.Value != 0U;
|
|
}
|
|
}
|