using OWML.Common; using OWML.ModHelper; using OWML.ModHelper.Events; using QSB.ConversationSync; using QSB.ElevatorSync; using QSB.GeyserSync; using QSB.OrbSync; using QSB.Patches; using QSB.SectorSync; using QSB.TimeSync; using QSB.Utility; using UnityEngine; using UnityEngine.Networking; namespace QSB { public class QSB : ModBehaviour { public static IModBehaviour ModBehaviour { get; private set; } public static IModHelper Helper { get; private set; } public static string DefaultServerIP { get; private set; } public static int Port { get; private set; } public static bool DebugMode { get; private set; } public static AssetBundle NetworkAssetBundle { get; private set; } public static AssetBundle InstrumentAssetBundle { get; private set; } public static bool HasWokenUp { get; set; } private void Awake() { Application.runInBackground = true; var instance = TextTranslation.Get().GetValue("m_table"); instance.theUITable[(int)UITextType.PleaseUseController] = "Quantum Space Buddies is best experienced with friends..."; ModBehaviour = this; LogFilter.currentLogLevel = LogFilter.Debug; // Application.logMessageReceived += Application_logMessageReceived; } private void Application_logMessageReceived(string condition, string stackTrace, LogType type) { switch (type) { case LogType.Assert: DebugLog.DebugWrite($"Assert - {condition}", MessageType.Message); break; case LogType.Log: DebugLog.DebugWrite($"Log - {condition}", MessageType.Message); break; case LogType.Warning: DebugLog.DebugWrite($"Warning - {condition}", MessageType.Warning); break; } } private void Start() { Helper = ModHelper; DebugLog.ToConsole($"* Start of QSB version {Helper.Manifest.Version} - authored by {Helper.Manifest.Author}", MessageType.Info); NetworkAssetBundle = Helper.Assets.LoadBundle("assets/network"); InstrumentAssetBundle = Helper.Assets.LoadBundle("assets/instruments"); QSBPatchManager.Init(); QSBPatchManager.DoPatchType(QSBPatchTypes.OnModStart); // Turns out these are very finicky about what order they go. QSBNetworkManager seems to // want to go first-ish, otherwise the NetworkManager complains about the PlayerPrefab being // null (even though it isn't...) gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); // Stop players being able to pause Helper.HarmonyHelper.EmptyMethod(typeof(OWTime).GetMethod("Pause")); } public override void Configure(IModConfig config) { DefaultServerIP = config.GetSettingsValue("defaultServerIP"); Port = config.GetSettingsValue("port"); if (QSBNetworkManager.Instance != null) { QSBNetworkManager.Instance.networkPort = Port; } DebugMode = config.GetSettingsValue("debugMode"); } } }