From e454653c297138b92d604cb2bd29cb95104fe01e Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Thu, 13 Feb 2020 20:34:51 +0100 Subject: [PATCH] Custom network manager configures itself --- QSB/QSB.cs | 11 +++-------- QSB/QSBNetworkManager.cs | 14 +++++++------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/QSB/QSB.cs b/QSB/QSB.cs index 0b535114..4ca48ed2 100644 --- a/QSB/QSB.cs +++ b/QSB/QSB.cs @@ -6,6 +6,7 @@ using UnityEngine.Networking; namespace QSB { public class QSB: ModBehaviour { + public static IModHelper Helper; static QSB _instance; public static Dictionary playerSectors; @@ -22,17 +23,11 @@ namespace QSB { void Start () { _instance = this; + Helper = ModHelper; playerSectors = new Dictionary(); - var assetBundle = ModHelper.Assets.LoadBundle("assets/network"); - //var networkManager = Instantiate(assetBundle.LoadAsset("assets/networkmanager.prefab")); - var networkPlayerPrefab = assetBundle.LoadAsset("assets/networkplayer.prefab"); - networkPlayerPrefab.AddComponent(); - - var networkManager = gameObject.AddComponent(); - networkManager.playerPrefab = networkPlayerPrefab; - + gameObject.AddComponent(); gameObject.AddComponent(); ModHelper.HarmonyHelper.AddPrefix("OnAddSector", typeof(Patches), "OnAddSector"); diff --git a/QSB/QSBNetworkManager.cs b/QSB/QSBNetworkManager.cs index 56934b67..cf350737 100644 --- a/QSB/QSBNetworkManager.cs +++ b/QSB/QSBNetworkManager.cs @@ -1,18 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using UnityEngine; using UnityEngine.Networking; namespace QSB { class QSBNetworkManager: NetworkManager { void Awake () { + var assetBundle = QSB.Helper.Assets.LoadBundle("assets/network"); + playerPrefab = assetBundle.LoadAsset("assets/networkplayer.prefab"); + playerPrefab.AddComponent(); } - public override void OnClientConnect (NetworkConnection conn) { - base.OnClientConnect(conn); + public override void OnStartClient (NetworkClient client) { + base.OnStartClient(client); - QSB.Log("OnClientConnect"); + QSB.Log("start client"); } } }