2020-02-10 22:03:28 +00:00
|
|
|
|
using OWML.Common;
|
|
|
|
|
using OWML.ModHelper;
|
2021-05-09 07:31:16 +00:00
|
|
|
|
using OWML.ModHelper.Input;
|
2020-12-20 10:56:15 +00:00
|
|
|
|
using OWML.Utils;
|
2021-04-29 17:30:45 +00:00
|
|
|
|
using QSB.Animation.NPC;
|
2021-03-29 13:36:16 +00:00
|
|
|
|
using QSB.CampfireSync;
|
2020-09-22 20:11:29 +00:00
|
|
|
|
using QSB.ConversationSync;
|
2021-06-23 11:06:08 +00:00
|
|
|
|
using QSB.DeathSync;
|
2020-08-12 19:58:29 +00:00
|
|
|
|
using QSB.ElevatorSync;
|
2020-08-13 13:32:58 +00:00
|
|
|
|
using QSB.GeyserSync;
|
2021-06-11 13:34:27 +00:00
|
|
|
|
using QSB.Inputs;
|
2021-02-23 14:42:18 +00:00
|
|
|
|
using QSB.ItemSync;
|
2020-09-04 19:54:34 +00:00
|
|
|
|
using QSB.OrbSync;
|
2020-11-03 21:11:10 +00:00
|
|
|
|
using QSB.Patches;
|
2021-02-18 15:36:11 +00:00
|
|
|
|
using QSB.Player;
|
2021-04-11 16:05:02 +00:00
|
|
|
|
using QSB.Player.TransformSync;
|
2021-03-28 18:08:18 +00:00
|
|
|
|
using QSB.PoolSync;
|
2020-12-22 21:39:53 +00:00
|
|
|
|
using QSB.QuantumSync;
|
2020-11-03 22:29:23 +00:00
|
|
|
|
using QSB.SectorSync;
|
2021-04-12 09:37:20 +00:00
|
|
|
|
using QSB.ShipSync;
|
2021-02-28 14:43:05 +00:00
|
|
|
|
using QSB.StatueSync;
|
2020-11-26 13:09:34 +00:00
|
|
|
|
using QSB.TimeSync;
|
2020-12-31 12:10:55 +00:00
|
|
|
|
using QSB.TranslationSync;
|
2020-07-30 20:27:14 +00:00
|
|
|
|
using QSB.Utility;
|
2021-02-18 15:36:11 +00:00
|
|
|
|
using QSB.WorldSync;
|
2020-12-11 13:14:58 +00:00
|
|
|
|
using QuantumUNET;
|
2020-12-07 21:19:16 +00:00
|
|
|
|
using QuantumUNET.Components;
|
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
|
2020-12-19 21:14:05 +00:00
|
|
|
|
Henry Pointer (_nebula / misternebula),
|
|
|
|
|
Aleksander Waage (AmazingAlek),
|
|
|
|
|
Ricardo Lopes (Raicuparta)
|
2020-12-19 16:17:50 +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; }
|
|
|
|
|
public static bool DebugMode { get; private set; }
|
2021-01-31 16:14:17 +00:00
|
|
|
|
public static bool ShowLinesInDebug { get; private set; }
|
2020-12-02 21:29:53 +00:00
|
|
|
|
public static AssetBundle NetworkAssetBundle { get; private set; }
|
|
|
|
|
public static AssetBundle InstrumentAssetBundle { get; private set; }
|
2020-12-24 15:57:25 +00:00
|
|
|
|
public static AssetBundle ConversationAssetBundle { get; private set; }
|
2021-05-19 10:35:17 +00:00
|
|
|
|
public static bool WorldObjectsReady => WorldObjectManager.AllReady && IsInMultiplayer && PlayerTransformSync.LocalInstance != null;
|
2020-12-23 12:58:45 +00:00
|
|
|
|
public static bool IsServer => QNetworkServer.active;
|
2021-02-10 19:34:41 +00:00
|
|
|
|
public static bool IsInMultiplayer => QNetworkManager.singleton.isNetworkActive;
|
2021-03-09 16:43:41 +00:00
|
|
|
|
public static string QSBVersion => Helper.Manifest.Version;
|
2021-02-01 15:44:21 +00:00
|
|
|
|
|
2020-12-14 20:41:56 +00:00
|
|
|
|
public void Awake()
|
2020-12-02 21:29:53 +00:00
|
|
|
|
{
|
|
|
|
|
var instance = TextTranslation.Get().GetValue<TextTranslation.TranslationTable>("m_table");
|
|
|
|
|
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
|
|
|
|
|
2020-12-02 21:29:53 +00:00
|
|
|
|
NetworkAssetBundle = Helper.Assets.LoadBundle("assets/network");
|
|
|
|
|
InstrumentAssetBundle = Helper.Assets.LoadBundle("assets/instruments");
|
2020-12-24 15:57:25 +00:00
|
|
|
|
ConversationAssetBundle = Helper.Assets.LoadBundle("assets/conversation");
|
2020-08-23 13:51:45 +00:00
|
|
|
|
|
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>();
|
2020-12-23 12:58:45 +00:00
|
|
|
|
gameObject.AddComponent<QNetworkManagerHUD>();
|
2020-12-02 21:29:53 +00:00
|
|
|
|
gameObject.AddComponent<DebugActions>();
|
|
|
|
|
gameObject.AddComponent<ConversationManager>();
|
|
|
|
|
gameObject.AddComponent<QSBInputManager>();
|
|
|
|
|
gameObject.AddComponent<TimeSyncUI>();
|
2021-02-19 10:09:14 +00:00
|
|
|
|
gameObject.AddComponent<RepeatingManager>();
|
2021-02-21 21:27:54 +00:00
|
|
|
|
gameObject.AddComponent<PlayerEntanglementWatcher>();
|
2021-06-19 10:24:23 +00:00
|
|
|
|
gameObject.AddComponent<DebugGUI>();
|
2021-06-23 11:06:08 +00:00
|
|
|
|
gameObject.AddComponent<RespawnManager>();
|
2021-03-29 13:36:16 +00:00
|
|
|
|
|
|
|
|
|
// WorldObject managers
|
|
|
|
|
gameObject.AddComponent<QuantumManager>();
|
|
|
|
|
gameObject.AddComponent<SpiralManager>();
|
|
|
|
|
gameObject.AddComponent<ElevatorManager>();
|
|
|
|
|
gameObject.AddComponent<GeyserManager>();
|
|
|
|
|
gameObject.AddComponent<OrbManager>();
|
|
|
|
|
gameObject.AddComponent<QSBSectorManager>();
|
2021-02-23 14:42:18 +00:00
|
|
|
|
gameObject.AddComponent<ItemManager>();
|
2021-02-28 14:43:05 +00:00
|
|
|
|
gameObject.AddComponent<StatueManager>();
|
2021-03-28 18:08:18 +00:00
|
|
|
|
gameObject.AddComponent<PoolManager>();
|
2021-03-29 13:36:16 +00:00
|
|
|
|
gameObject.AddComponent<CampfireManager>();
|
2021-04-26 13:30:21 +00:00
|
|
|
|
gameObject.AddComponent<CharacterAnimManager>();
|
2021-06-19 10:24:53 +00:00
|
|
|
|
gameObject.AddComponent<ShipManager>();
|
2020-10-23 18:06:11 +00:00
|
|
|
|
|
2020-12-24 15:57:25 +00:00
|
|
|
|
DebugBoxManager.Init();
|
|
|
|
|
|
2021-05-09 07:31:16 +00:00
|
|
|
|
Helper.HarmonyHelper.EmptyMethod<ModCommandListener>("Update");
|
|
|
|
|
|
2020-12-02 21:29:53 +00:00
|
|
|
|
// Stop players being able to pause
|
|
|
|
|
Helper.HarmonyHelper.EmptyMethod(typeof(OWTime).GetMethod("Pause"));
|
2021-07-13 17:46:31 +00:00
|
|
|
|
|
|
|
|
|
QSBPatchManager.OnPatchType += OnPatchType;
|
|
|
|
|
QSBPatchManager.OnUnpatchType += OnUnpatchType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnPatchType(QSBPatchTypes type)
|
|
|
|
|
{
|
|
|
|
|
if (type == QSBPatchTypes.OnClientConnect)
|
|
|
|
|
{
|
|
|
|
|
Application.runInBackground = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnUnpatchType(QSBPatchTypes type)
|
|
|
|
|
{
|
|
|
|
|
if (type == QSBPatchTypes.OnClientConnect)
|
|
|
|
|
{
|
|
|
|
|
Application.runInBackground = false;
|
|
|
|
|
}
|
2020-12-02 21:29:53 +00:00
|
|
|
|
}
|
2020-03-02 16:34:01 +00:00
|
|
|
|
|
2020-12-14 21:20:53 +00:00
|
|
|
|
public void Update() =>
|
2020-12-23 12:58:45 +00:00
|
|
|
|
QNetworkIdentity.UNetStaticUpdate();
|
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");
|
|
|
|
|
if (QSBNetworkManager.Instance != null)
|
|
|
|
|
{
|
|
|
|
|
QSBNetworkManager.Instance.networkPort = Port;
|
|
|
|
|
}
|
2021-06-18 21:38:32 +00:00
|
|
|
|
|
2020-12-02 21:29:53 +00:00
|
|
|
|
DebugMode = config.GetSettingsValue<bool>("debugMode");
|
2021-01-31 16:14:17 +00:00
|
|
|
|
ShowLinesInDebug = config.GetSettingsValue<bool>("showLinesInDebug");
|
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
|
|
|
|
|
*
|
|
|
|
|
* 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-06-18 20:54:32 +00:00
|
|
|
|
*/
|