using OWML.Common; using OWML.ModHelper; using OWML.Utils; using QSB.ConversationSync; using QSB.ElevatorSync; using QSB.GeyserSync; using QSB.OrbSync; using QSB.Patches; using QSB.QuantumSync; using QSB.SectorSync; using QSB.TimeSync; using QSB.TranslationSync; using QSB.Utility; using QuantumUNET; using QuantumUNET.Components; using System.Linq; using UnityEngine; /* Copyright (C) 2020 - 2021 Henry Pointer (_nebula / misternebula), Aleksander Waage (AmazingAlek), Ricardo Lopes (Raicuparta) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/. */ namespace QSB { public class QSBCore : ModBehaviour { 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 bool ShowLinesInDebug { get; private set; } public static AssetBundle NetworkAssetBundle { get; private set; } public static AssetBundle InstrumentAssetBundle { get; private set; } public static AssetBundle ConversationAssetBundle { get; private set; } public static bool HasWokenUp { get; set; } public static bool IsServer => QNetworkServer.active; public 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..."; } public 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"); ConversationAssetBundle = Helper.Assets.LoadBundle("assets/conversation"); QSBPatchManager.Init(); QSBPatchManager.DoPatchType(QSBPatchTypes.OnModStart); gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); DebugBoxManager.Init(); // Stop players being able to pause Helper.HarmonyHelper.EmptyMethod(typeof(OWTime).GetMethod("Pause")); } public void Update() => QNetworkIdentity.UNetStaticUpdate(); 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"); if (!DebugMode) { FindObjectsOfType().ToList().ForEach(x => Destroy(x.gameObject)); } ShowLinesInDebug = config.GetSettingsValue("showLinesInDebug"); } } }