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;
|
2020-07-27 23:13:43 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace QSB.TransformSync
|
|
|
|
|
{
|
2020-08-31 08:36:29 +00:00
|
|
|
|
public class PlayerCameraSync : TransformSync
|
2020-07-27 23:13:43 +00:00
|
|
|
|
{
|
|
|
|
|
public static PlayerCameraSync LocalInstance { get; private set; }
|
|
|
|
|
|
|
|
|
|
public override void OnStartLocalPlayer()
|
|
|
|
|
{
|
2020-12-02 09:51:53 +00:00
|
|
|
|
DebugLog.DebugWrite("OnStartLocalPlayer", MessageType.Info);
|
2020-07-27 23:13:43 +00:00
|
|
|
|
LocalInstance = this;
|
|
|
|
|
}
|
2020-08-20 18:31:10 +00:00
|
|
|
|
|
2020-07-27 23:13:43 +00:00
|
|
|
|
protected override Transform InitLocalTransform()
|
|
|
|
|
{
|
|
|
|
|
var body = Locator.GetPlayerCamera().gameObject.transform;
|
|
|
|
|
|
2020-08-07 19:39:07 +00:00
|
|
|
|
Player.Camera = body.gameObject;
|
2020-07-27 23:13:43 +00:00
|
|
|
|
|
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
|
|
|
|
|
2020-07-27 23:13:43 +00:00
|
|
|
|
return body;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Transform InitRemoteTransform()
|
|
|
|
|
{
|
2020-09-02 10:17:04 +00:00
|
|
|
|
var body = new GameObject("RemotePlayerCamera");
|
2020-07-27 23:13:43 +00:00
|
|
|
|
|
|
|
|
|
PlayerToolsManager.Init(body.transform);
|
|
|
|
|
|
2020-08-07 19:39:07 +00:00
|
|
|
|
Player.Camera = body;
|
2020-07-27 23:13:43 +00:00
|
|
|
|
|
|
|
|
|
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;
|
2020-07-27 23:13:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|