quantum-space-buddies/QSB/TransformSync/PlayerTransformSync.cs
Ricardo Lopes 170769cefa
Full state sync (#89)
* Sync full state on init

* Sync game state on start

* Show name markers above remote players (#87)

* Showing player markers

* Marker above head

* Use player name on marker

* Remove debug all message
2020-05-19 19:41:33 +02:00

50 lines
1.2 KiB
C#

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