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

56 lines
1.3 KiB
C#
Raw Normal View History

2020-07-28 15:59:24 +02:00
using QSB.Animation;
2020-02-21 23:36:07 +01:00
using UnityEngine;
2020-02-10 23:03:28 +01:00
2020-02-21 23:36:07 +01:00
namespace QSB.TransformSync
2020-02-15 20:48:02 +01:00
{
2020-02-21 23:36:07 +01:00
public class PlayerTransformSync : TransformSync
2020-02-15 20:48:02 +01:00
{
2020-02-21 23:36:07 +01:00
public static PlayerTransformSync LocalInstance { get; private set; }
2020-02-10 23:03:28 +01:00
public Transform bodyTransform;
public override void OnStartLocalPlayer()
{
LocalInstance = this;
}
protected override uint PlayerId => netId.Value - 0;
private Transform GetPlayerModel()
2020-02-15 20:48:02 +01:00
{
return Locator.GetPlayerTransform().Find("Traveller_HEA_Player_v2");
}
protected override Transform InitLocalTransform()
2020-02-15 20:48:02 +01:00
{
var body = GetPlayerModel();
bodyTransform = body;
GetComponent<AnimationSync>().InitLocal(body);
Player.Body = body.gameObject;
return body;
2020-02-12 20:05:08 +01:00
}
protected override Transform InitRemoteTransform()
2020-02-15 20:48:02 +01:00
{
var body = Instantiate(GetPlayerModel());
bodyTransform = body;
GetComponent<AnimationSync>().InitRemote(body);
var marker = body.gameObject.AddComponent<PlayerHUDMarker>();
2020-08-08 12:25:09 +02:00
marker.Init(Player);
Player.Body = body.gameObject;
return body;
2020-02-10 23:03:28 +01:00
}
protected override bool IsReady => Locator.GetPlayerTransform() != null && Player != null;
2020-02-10 23:03:28 +01:00
}
}