quantum-space-buddies/QSB/QSB.cs

52 lines
1.8 KiB
C#
Raw Normal View History

2020-02-10 22:03:28 +00:00
using OWML.Common;
using OWML.ModHelper;
using UnityEngine;
using UnityEngine.Networking;
namespace QSB {
public class QSB: ModBehaviour {
static QSB _instance;
void Awake () {
Application.runInBackground = true;
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
void Update () {
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
void Start () {
_instance = this;
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>();
networkManager.GetComponent<NetworkManager>().playerPrefab = networkPlayerPrefab;
ModHelper.HarmonyHelper.AddPrefix<PlayerSectorDetector>("OnAddSector", typeof(Patches), "OnAddSector");
2020-02-10 22:03:28 +00:00
}
public static void Log (params string[] strings) {
_instance.ModHelper.Console.WriteLine(string.Join(" ", strings));
}
public static void LogToScreen (params string[] strings) {
var text = string.Join(" ", strings);
NotificationData data = new NotificationData(NotificationTarget.Player, text, 3f, true);
NotificationManager.SharedInstance.PostNotification(data, false);
}
static class Patches {
static void OnAddSector (Sector sector, PlayerSectorDetector __instance) {
if (NetworkPlayer.localInstance != null) {
NetworkPlayer.localInstance.EnterSector(sector);
}
}
}
2020-02-10 22:03:28 +00:00
}
}