mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-26 09:35:26 +00:00
59 lines
1.6 KiB
C#
59 lines
1.6 KiB
C#
using QSB.Animation;
|
|
using QSB.Utility;
|
|
using System.Reflection;
|
|
using UnityEngine;
|
|
|
|
namespace QSB.TransformSync
|
|
{
|
|
public class PlayerTransformSync : TransformSync
|
|
{
|
|
public static PlayerTransformSync LocalInstance { get; private set; }
|
|
|
|
protected override uint PlayerIdOffset => 0;
|
|
|
|
static PlayerTransformSync()
|
|
{
|
|
AnimControllerPatch.Init();
|
|
}
|
|
|
|
public override void OnStartLocalPlayer()
|
|
{
|
|
LocalInstance = this;
|
|
}
|
|
|
|
private Transform GetPlayerModel()
|
|
{
|
|
return Locator.GetPlayerTransform().Find("Traveller_HEA_Player_v2");
|
|
}
|
|
|
|
protected override Transform InitLocalTransform()
|
|
{
|
|
DebugLog.ToConsole($"{MethodBase.GetCurrentMethod().Name} for {GetType().Name}");
|
|
var body = GetPlayerModel();
|
|
|
|
GetComponent<AnimationSync>().InitLocal(body);
|
|
|
|
Player.Body = body.gameObject;
|
|
|
|
return body;
|
|
}
|
|
|
|
protected override Transform InitRemoteTransform()
|
|
{
|
|
DebugLog.ToConsole($"{MethodBase.GetCurrentMethod().Name} for {GetType().Name}");
|
|
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 && PlayerRegistry.PlayerExists(PlayerId) && Player.IsReady;
|
|
}
|
|
}
|