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

52 lines
1.4 KiB
C#
Raw Normal View History

2020-12-02 09:51:53 +00:00
using OWML.Common;
using QSB.EventsCore;
2020-11-03 21:33:48 +00:00
using QSB.Player;
2020-08-10 17:24:28 +00:00
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()
{
2020-12-02 09:51:53 +00:00
DebugLog.DebugWrite("OnStartLocalPlayer", MessageType.Info);
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-12-02 09:51:53 +00:00
&& NetId.Value != uint.MaxValue
&& NetId.Value != 0U;
}
}