quantum-space-buddies/QSB/NetworkPlayer.cs

43 lines
1.2 KiB
C#
Raw Normal View History

using UnityEngine;
2020-02-10 23:03:28 +01:00
2020-02-15 20:48:02 +01:00
namespace QSB
{
public class NetworkPlayer : TransformSync
2020-02-15 20:48:02 +01:00
{
public static NetworkPlayer LocalInstance { get; private set; }
2020-02-10 23:03:28 +01:00
private Transform _playerModel;
2020-02-15 20:48:02 +01:00
private Transform GetPlayerModel()
2020-02-15 20:48:02 +01:00
{
if (!_playerModel)
2020-02-15 20:48:02 +01:00
{
_playerModel = Locator.GetPlayerBody().transform.Find("Traveller_HEA_Player_v2");
2020-02-15 20:48:02 +01:00
}
return _playerModel;
}
protected override Transform InitLocalTransform()
2020-02-15 20:48:02 +01:00
{
LocalInstance = this;
var body = GetPlayerModel();
GetComponent<AnimationSync>().Init(body);
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());
body.GetComponent<PlayerAnimController>().enabled = false;
body.Find("player_mesh_noSuit:Traveller_HEA_Player/player_mesh_noSuit:Player_Head").gameObject.layer = 0;
body.Find("Traveller_Mesh_v01:Traveller_Geo/Traveller_Mesh_v01:PlayerSuit_Helmet").gameObject.layer = 0;
GetComponent<AnimationSync>().Init(body);
return body;
2020-02-10 23:03:28 +01:00
}
}
}