quantum-space-buddies/QSB/TransformSync/PlayerTransformSync.cs
Aleksander Waage 91f9e5b9dc cleanup
2020-08-15 21:16:21 +02:00

55 lines
1.3 KiB
C#

using QSB.Animation;
using UnityEngine;
namespace QSB.TransformSync
{
public class PlayerTransformSync : TransformSync
{
public static PlayerTransformSync LocalInstance { get; private set; }
static PlayerTransformSync()
{
AnimControllerPatch.Init();
}
public override void OnStartLocalPlayer()
{
LocalInstance = this;
}
public override uint PlayerId => netId.Value - 0;
private Transform GetPlayerModel()
{
return Locator.GetPlayerTransform().Find("Traveller_HEA_Player_v2");
}
protected override Transform InitLocalTransform()
{
var body = GetPlayerModel();
GetComponent<AnimationSync>().InitLocal(body);
Player.Body = body.gameObject;
return body;
}
protected override Transform InitRemoteTransform()
{
var body = Instantiate(GetPlayerModel());
GetComponent<AnimationSync>().InitRemote(body);
var marker = body.gameObject.AddComponent<PlayerHUDMarker>();
marker.Init(Player);
Player.Body = body.gameObject;
return body;
}
public override bool IsReady => Locator.GetPlayerTransform() != null && Player != null && Player.IsReady;
}
}