2022-01-15 06:54:18 +00:00
|
|
|
|
using Mirror;
|
|
|
|
|
using OWML.Common;
|
2020-02-10 22:03:28 +00:00
|
|
|
|
using OWML.ModHelper;
|
2021-05-09 07:31:16 +00:00
|
|
|
|
using OWML.ModHelper.Input;
|
2021-12-23 11:37:37 +00:00
|
|
|
|
using QSB.EyeOfTheUniverse.GalaxyMap;
|
2022-01-13 05:43:57 +00:00
|
|
|
|
using QSB.EyeOfTheUniverse.MaskSync;
|
2021-06-11 13:34:27 +00:00
|
|
|
|
using QSB.Inputs;
|
2021-06-04 10:31:09 +00:00
|
|
|
|
using QSB.Menus;
|
2020-11-03 21:11:10 +00:00
|
|
|
|
using QSB.Patches;
|
2021-02-18 15:36:11 +00:00
|
|
|
|
using QSB.Player;
|
2021-11-25 15:32:34 +00:00
|
|
|
|
using QSB.RespawnSync;
|
2021-11-03 09:18:52 +00:00
|
|
|
|
using QSB.SatelliteSync;
|
2021-02-28 14:43:05 +00:00
|
|
|
|
using QSB.StatueSync;
|
2020-11-26 13:09:34 +00:00
|
|
|
|
using QSB.TimeSync;
|
2020-07-30 20:27:14 +00:00
|
|
|
|
using QSB.Utility;
|
2021-02-18 15:36:11 +00:00
|
|
|
|
using QSB.WorldSync;
|
2021-12-07 15:56:08 +00:00
|
|
|
|
using System.Linq;
|
2020-02-10 22:03:28 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2020-12-17 23:18:47 +00:00
|
|
|
|
/*
|
2021-02-01 10:15:04 +00:00
|
|
|
|
Copyright (C) 2020 - 2021
|
2021-11-10 01:56:45 +00:00
|
|
|
|
Henry Pointer (_nebula / misternebula),
|
2021-12-20 05:19:11 +00:00
|
|
|
|
Will Corby (JohnCorby),
|
2021-11-10 01:56:45 +00:00
|
|
|
|
Aleksander Waage (AmazingAlek),
|
2020-12-19 21:14:05 +00:00
|
|
|
|
Ricardo Lopes (Raicuparta)
|
2021-11-10 01:56:45 +00:00
|
|
|
|
|
2020-12-19 21:14:05 +00:00
|
|
|
|
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/.
|
2020-12-17 23:18:47 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2020-02-15 19:48:02 +00:00
|
|
|
|
namespace QSB
|
|
|
|
|
{
|
2020-12-14 16:24:52 +00:00
|
|
|
|
public class QSBCore : ModBehaviour
|
2020-12-02 21:29:53 +00:00
|
|
|
|
{
|
|
|
|
|
public static IModHelper Helper { get; private set; }
|
2021-03-13 10:17:52 +00:00
|
|
|
|
public static IModUnityEvents UnityEvents => Helper.Events.Unity;
|
2020-12-02 21:29:53 +00:00
|
|
|
|
public static string DefaultServerIP { get; private set; }
|
|
|
|
|
public static int Port { get; private set; }
|
2021-11-25 22:44:15 +00:00
|
|
|
|
public static bool DebugMode => DebugSettings.DebugMode;
|
|
|
|
|
public static bool ShowLinesInDebug => DebugMode && DebugSettings.DrawLines;
|
|
|
|
|
public static bool ShowQuantumVisibilityObjects => DebugMode && DebugSettings.ShowQuantumVisibilityObjects;
|
2021-12-28 18:06:34 +00:00
|
|
|
|
public static bool ShowDebugLabels => DebugMode && DebugSettings.ShowDebugLabels;
|
2021-11-25 22:44:15 +00:00
|
|
|
|
public static bool AvoidTimeSync => DebugMode && DebugSettings.AvoidTimeSync;
|
|
|
|
|
public static bool SkipTitleScreen => DebugMode && DebugSettings.SkipTitleScreen;
|
2021-12-30 13:55:41 +00:00
|
|
|
|
public static bool GreySkybox => DebugMode && DebugSettings.GreySkybox;
|
2021-12-05 01:44:21 +00:00
|
|
|
|
public static AssetBundle NetworkAssetBundle { get; internal set; }
|
2020-12-02 21:29:53 +00:00
|
|
|
|
public static AssetBundle InstrumentAssetBundle { get; private set; }
|
2020-12-24 15:57:25 +00:00
|
|
|
|
public static AssetBundle ConversationAssetBundle { get; private set; }
|
2021-10-18 08:02:48 +00:00
|
|
|
|
public static AssetBundle DebugAssetBundle { get; private set; }
|
2021-12-23 11:37:37 +00:00
|
|
|
|
public static AssetBundle TextAssetsBundle { get; private set; }
|
2022-01-15 06:54:18 +00:00
|
|
|
|
public static bool IsHost => NetworkServer.active;
|
|
|
|
|
public static bool IsInMultiplayer => NetworkManager.singleton.isNetworkActive;
|
2021-03-09 16:43:41 +00:00
|
|
|
|
public static string QSBVersion => Helper.Manifest.Version;
|
2021-08-10 13:54:23 +00:00
|
|
|
|
public static string GameVersion => Application.version;
|
2021-10-21 16:21:54 +00:00
|
|
|
|
public static GamePlatform Platform => typeof(Achievements).Assembly.GetTypes().Any(x => x.Name == "EpicEntitlementRetriever")
|
|
|
|
|
? GamePlatform.Epic
|
|
|
|
|
: GamePlatform.Steam;
|
2021-12-07 13:35:03 +00:00
|
|
|
|
public static bool DLCInstalled => EntitlementsManager.IsDlcOwned() == EntitlementsManager.AsyncOwnershipStatus.Owned;
|
2021-08-23 13:50:08 +00:00
|
|
|
|
public static IMenuAPI MenuApi { get; private set; }
|
2020-02-10 22:03:28 +00:00
|
|
|
|
|
2021-11-25 22:44:15 +00:00
|
|
|
|
private static DebugSettings DebugSettings { get; set; } = new DebugSettings();
|
|
|
|
|
|
2020-12-14 20:41:56 +00:00
|
|
|
|
public void Awake()
|
2020-12-02 21:29:53 +00:00
|
|
|
|
{
|
2021-10-15 20:06:51 +00:00
|
|
|
|
var instance = TextTranslation.Get().m_table;
|
2020-12-02 21:29:53 +00:00
|
|
|
|
instance.theUITable[(int)UITextType.PleaseUseController] =
|
|
|
|
|
"<color=orange>Quantum Space Buddies</color> is best experienced with friends...";
|
|
|
|
|
}
|
2020-02-10 22:03:28 +00:00
|
|
|
|
|
2020-12-14 20:41:56 +00:00
|
|
|
|
public void Start()
|
2020-12-02 21:29:53 +00:00
|
|
|
|
{
|
|
|
|
|
Helper = ModHelper;
|
2021-06-19 10:13:32 +00:00
|
|
|
|
DebugLog.ToConsole($"* Start of QSB version {QSBVersion} - authored by {Helper.Manifest.Author}", MessageType.Info);
|
2020-08-20 18:31:10 +00:00
|
|
|
|
|
2021-10-16 15:57:01 +00:00
|
|
|
|
MenuApi = ModHelper.Interaction.GetModApi<IMenuAPI>("_nebula.MenuFramework");
|
2021-06-04 10:31:09 +00:00
|
|
|
|
|
2021-11-27 02:54:36 +00:00
|
|
|
|
NetworkAssetBundle = Helper.Assets.LoadBundle("AssetBundles/network");
|
|
|
|
|
InstrumentAssetBundle = Helper.Assets.LoadBundle("AssetBundles/instruments");
|
|
|
|
|
ConversationAssetBundle = Helper.Assets.LoadBundle("AssetBundles/conversation");
|
|
|
|
|
DebugAssetBundle = Helper.Assets.LoadBundle("AssetBundles/debug");
|
2021-12-23 11:37:37 +00:00
|
|
|
|
TextAssetsBundle = Helper.Assets.LoadBundle("AssetBundles/textassets");
|
2020-08-23 13:51:45 +00:00
|
|
|
|
|
2021-11-25 22:44:15 +00:00
|
|
|
|
DebugSettings = ModHelper.Storage.Load<DebugSettings>("debugsettings.json");
|
|
|
|
|
|
|
|
|
|
if (DebugSettings == null)
|
|
|
|
|
{
|
|
|
|
|
DebugSettings = new DebugSettings();
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-02 21:29:53 +00:00
|
|
|
|
QSBPatchManager.Init();
|
2020-02-10 22:03:28 +00:00
|
|
|
|
|
2020-12-02 21:29:53 +00:00
|
|
|
|
gameObject.AddComponent<QSBNetworkManager>();
|
|
|
|
|
gameObject.AddComponent<DebugActions>();
|
|
|
|
|
gameObject.AddComponent<QSBInputManager>();
|
|
|
|
|
gameObject.AddComponent<TimeSyncUI>();
|
2021-02-21 21:27:54 +00:00
|
|
|
|
gameObject.AddComponent<PlayerEntanglementWatcher>();
|
2021-06-19 10:24:23 +00:00
|
|
|
|
gameObject.AddComponent<DebugGUI>();
|
2021-10-16 15:57:01 +00:00
|
|
|
|
gameObject.AddComponent<MenuManager>();
|
2021-06-23 11:06:08 +00:00
|
|
|
|
gameObject.AddComponent<RespawnManager>();
|
2021-11-03 09:18:52 +00:00
|
|
|
|
gameObject.AddComponent<SatelliteProjectorManager>();
|
2021-12-11 07:28:42 +00:00
|
|
|
|
gameObject.AddComponent<StatueManager>();
|
2021-12-23 11:37:37 +00:00
|
|
|
|
gameObject.AddComponent<GalaxyMapManager>();
|
2021-12-30 13:55:41 +00:00
|
|
|
|
gameObject.AddComponent<DebugCameraSettings>();
|
2022-01-13 05:43:57 +00:00
|
|
|
|
gameObject.AddComponent<MaskManager>();
|
2021-03-29 13:36:16 +00:00
|
|
|
|
|
|
|
|
|
// WorldObject managers
|
2021-12-11 07:28:42 +00:00
|
|
|
|
foreach (var type in typeof(WorldObjectManager).GetDerivedTypes())
|
|
|
|
|
{
|
|
|
|
|
gameObject.AddComponent(type);
|
|
|
|
|
}
|
2020-10-23 18:06:11 +00:00
|
|
|
|
|
2021-05-09 07:31:16 +00:00
|
|
|
|
Helper.HarmonyHelper.EmptyMethod<ModCommandListener>("Update");
|
|
|
|
|
|
2021-07-13 17:46:31 +00:00
|
|
|
|
QSBPatchManager.OnPatchType += OnPatchType;
|
|
|
|
|
QSBPatchManager.OnUnpatchType += OnUnpatchType;
|
|
|
|
|
}
|
2020-12-02 18:40:38 +00:00
|
|
|
|
|
2021-07-13 17:46:31 +00:00
|
|
|
|
private void OnPatchType(QSBPatchTypes type)
|
2021-02-18 15:36:11 +00:00
|
|
|
|
{
|
2021-07-13 17:46:31 +00:00
|
|
|
|
if (type == QSBPatchTypes.OnClientConnect)
|
2021-02-26 17:07:28 +00:00
|
|
|
|
{
|
2021-07-13 17:46:31 +00:00
|
|
|
|
Application.runInBackground = true;
|
2021-10-25 14:16:03 +00:00
|
|
|
|
if (Locator.GetSceneMenuManager() != null && Locator.GetSceneMenuManager().pauseMenu.IsOpen())
|
2021-10-25 14:00:27 +00:00
|
|
|
|
{
|
|
|
|
|
Locator.GetSceneMenuManager().pauseMenu._pauseMenu.EnableMenu(false);
|
|
|
|
|
}
|
2021-02-21 18:25:25 +00:00
|
|
|
|
}
|
2021-07-13 17:46:31 +00:00
|
|
|
|
}
|
2021-02-21 18:25:25 +00:00
|
|
|
|
|
2021-07-13 17:46:31 +00:00
|
|
|
|
private void OnUnpatchType(QSBPatchTypes type)
|
|
|
|
|
{
|
|
|
|
|
if (type == QSBPatchTypes.OnClientConnect)
|
2021-02-18 15:36:11 +00:00
|
|
|
|
{
|
2021-07-13 17:46:31 +00:00
|
|
|
|
Application.runInBackground = false;
|
2021-02-18 15:36:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-14 21:20:53 +00:00
|
|
|
|
public void Update() =>
|
2022-01-15 06:54:18 +00:00
|
|
|
|
// TODO MIRROR NetworkIdentity.UNetStaticUpdate();
|
|
|
|
|
throw new System.NotImplementedException();
|
2020-12-02 18:40:38 +00:00
|
|
|
|
|
2020-12-14 21:20:53 +00:00
|
|
|
|
public override void Configure(IModConfig config)
|
2020-12-02 21:29:53 +00:00
|
|
|
|
{
|
|
|
|
|
DefaultServerIP = config.GetSettingsValue<string>("defaultServerIP");
|
|
|
|
|
Port = config.GetSettingsValue<int>("port");
|
2022-01-15 06:25:23 +00:00
|
|
|
|
if (QSBNetworkManager.singleton != null)
|
2020-12-02 21:29:53 +00:00
|
|
|
|
{
|
2022-01-15 06:41:13 +00:00
|
|
|
|
// TODO MIRROR QSBNetworkManager.Instance.networkPort = Port;
|
2020-12-02 21:29:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-18 20:54:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* _nebula's music thanks
|
|
|
|
|
* I listen to music constantly while programming/working - here's my thanks to them for keeping me entertained :P
|
2021-11-10 01:56:45 +00:00
|
|
|
|
*
|
2021-06-18 20:54:32 +00:00
|
|
|
|
* Wintergatan
|
|
|
|
|
* HOME
|
|
|
|
|
* C418
|
|
|
|
|
* Lupus Nocte
|
|
|
|
|
* Max Cooper
|
|
|
|
|
* Darren Korb
|
|
|
|
|
* Harry Callaghan
|
|
|
|
|
* Toby Fox
|
|
|
|
|
* Andrew Prahlow
|
|
|
|
|
* Valve (Mike Morasky, Kelly Bailey)
|
|
|
|
|
* Joel Nielsen
|
|
|
|
|
* Vulfpeck
|
|
|
|
|
* Detektivbyrån
|
|
|
|
|
* Ben Prunty
|
|
|
|
|
* ConcernedApe
|
|
|
|
|
* Jake Chudnow
|
|
|
|
|
* Murray Gold
|
|
|
|
|
* Teleskärm
|
2021-06-23 15:46:08 +00:00
|
|
|
|
* Daft Punk
|
2021-07-19 20:01:41 +00:00
|
|
|
|
* Natalie Holt
|
2021-08-17 09:02:19 +00:00
|
|
|
|
* WMD
|
2021-11-10 01:56:45 +00:00
|
|
|
|
*/
|