Custom network manager configures itself

This commit is contained in:
Ricardo Lopes 2020-02-13 20:34:51 +01:00
parent 65c8943bd8
commit e454653c29
2 changed files with 10 additions and 15 deletions

View File

@ -6,6 +6,7 @@ using UnityEngine.Networking;
namespace QSB {
public class QSB: ModBehaviour {
public static IModHelper Helper;
static QSB _instance;
public static Dictionary<uint, Transform> playerSectors;
@ -22,17 +23,11 @@ namespace QSB {
void Start () {
_instance = this;
Helper = ModHelper;
playerSectors = new Dictionary<uint, Transform>();
var assetBundle = ModHelper.Assets.LoadBundle("assets/network");
//var networkManager = Instantiate(assetBundle.LoadAsset<GameObject>("assets/networkmanager.prefab"));
var networkPlayerPrefab = assetBundle.LoadAsset<GameObject>("assets/networkplayer.prefab");
networkPlayerPrefab.AddComponent<NetworkPlayer>();
var networkManager = gameObject.AddComponent<QSBNetworkManager>();
networkManager.playerPrefab = networkPlayerPrefab;
gameObject.AddComponent<QSBNetworkManager>();
gameObject.AddComponent<NetworkManagerHUD>();
ModHelper.HarmonyHelper.AddPrefix<PlayerSectorDetector>("OnAddSector", typeof(Patches), "OnAddSector");

View File

@ -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<GameObject>("assets/networkplayer.prefab");
playerPrefab.AddComponent<NetworkPlayer>();
}
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");
}
}
}