quantum-space-buddies/QSB/QSBNetworkManager.cs
AmazingAlek 797f4de50d
Alek/anim triggers (#26)
* syncing animation triggers
* suit sync
2020-02-23 18:31:38 +01:00

47 lines
1.4 KiB
C#

using QSB.Animation;
using QSB.TransformSync;
using UnityEngine;
using UnityEngine.Networking;
namespace QSB
{
public class QSBNetworkManager : NetworkManager
{
private AssetBundle _assetBundle;
private GameObject _shipPrefab;
private void Awake()
{
_assetBundle = QSB.Helper.Assets.LoadBundle("assets/network");
playerPrefab = _assetBundle.LoadAsset<GameObject>("assets/networkplayer.prefab");
playerPrefab.AddComponent<PlayerTransformSync>();
playerPrefab.AddComponent<AnimationSync>();
_shipPrefab = _assetBundle.LoadAsset<GameObject>("assets/networkship.prefab");
_shipPrefab.AddComponent<ShipTransformSync>();
spawnPrefabs.Add(_shipPrefab);
}
public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
{
base.OnServerAddPlayer(conn, playerControllerId);
NetworkServer.SpawnWithClientAuthority(Instantiate(_shipPrefab), conn);
}
public override void OnStartServer()
{
WakeUpSync.IsServer = true;
}
public override void OnClientConnect(NetworkConnection conn)
{
base.OnClientConnect(conn);
DebugLog.Screen("OnClientConnect");
gameObject.AddComponent<WakeUpSync>();
gameObject.AddComponent<SectorSync>();
}
}
}