2020-02-21 22:36:07 +00:00
|
|
|
|
using QSB.Animation;
|
|
|
|
|
using QSB.TransformSync;
|
|
|
|
|
using UnityEngine;
|
2020-02-13 19:23:26 +00:00
|
|
|
|
using UnityEngine.Networking;
|
|
|
|
|
|
2020-02-15 19:48:02 +00:00
|
|
|
|
namespace QSB
|
|
|
|
|
{
|
|
|
|
|
public class QSBNetworkManager : NetworkManager
|
|
|
|
|
{
|
2020-02-21 22:36:07 +00:00
|
|
|
|
private AssetBundle _assetBundle;
|
|
|
|
|
private GameObject _shipPrefab;
|
|
|
|
|
|
2020-02-15 19:48:02 +00:00
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
2020-02-21 20:51:58 +00:00
|
|
|
|
_assetBundle = QSB.Helper.Assets.LoadBundle("assets/network");
|
|
|
|
|
playerPrefab = _assetBundle.LoadAsset<GameObject>("assets/networkplayer.prefab");
|
2020-02-21 22:36:07 +00:00
|
|
|
|
playerPrefab.AddComponent<PlayerTransformSync>();
|
2020-02-18 20:39:18 +00:00
|
|
|
|
playerPrefab.AddComponent<AnimationSync>();
|
2020-02-21 20:51:58 +00:00
|
|
|
|
|
|
|
|
|
_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);
|
2020-02-13 19:23:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-15 19:48:02 +00:00
|
|
|
|
public override void OnStartServer()
|
|
|
|
|
{
|
|
|
|
|
WakeUpSync.IsServer = true;
|
2020-02-14 21:14:24 +00:00
|
|
|
|
}
|
2020-02-15 19:48:02 +00:00
|
|
|
|
public override void OnClientConnect(NetworkConnection conn)
|
|
|
|
|
{
|
2020-02-14 21:14:24 +00:00
|
|
|
|
base.OnClientConnect(conn);
|
2020-02-13 19:23:26 +00:00
|
|
|
|
|
2020-02-14 21:14:24 +00:00
|
|
|
|
DebugLog.Screen("OnClientConnect");
|
|
|
|
|
gameObject.AddComponent<WakeUpSync>();
|
2020-02-13 20:23:12 +00:00
|
|
|
|
gameObject.AddComponent<SectorSync>();
|
2020-02-13 19:23:26 +00:00
|
|
|
|
}
|
2020-02-23 17:31:38 +00:00
|
|
|
|
|
2020-02-13 19:23:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|