2022-03-17 22:54:22 -07:00
using HarmonyLib ;
using Mirror ;
2022-01-14 22:54:18 -08:00
using OWML.Common ;
2020-02-10 23:03:28 +01:00
using OWML.ModHelper ;
2022-06-29 15:00:44 -07:00
using QSB.Localization ;
2021-06-04 11:31:09 +01:00
using QSB.Menus ;
2022-11-07 20:14:03 +00:00
using QSB.Messaging ;
2020-11-03 21:11:10 +00:00
using QSB.Patches ;
2022-01-18 15:50:20 -08:00
using QSB.QuantumSync ;
2022-08-07 20:02:45 +01:00
using QSB.SaveSync ;
2022-11-07 20:14:03 +00:00
using QSB.ServerSettings ;
2020-07-30 22:27:14 +02:00
using QSB.Utility ;
2021-02-18 15:36:11 +00:00
using QSB.WorldSync ;
2023-06-09 23:57:11 +01:00
using Steamworks ;
2022-02-10 04:18:30 -08:00
using System ;
2022-03-29 17:34:44 -07:00
using System.Collections.Generic ;
2023-10-29 23:55:44 +00:00
using System.Diagnostics ;
2022-01-28 18:37:28 -08:00
using System.IO ;
2021-12-07 15:56:08 +00:00
using System.Linq ;
2022-01-28 18:37:28 -08:00
using System.Reflection ;
2023-07-29 01:26:12 +01:00
using QSB.API ;
2023-10-30 00:05:28 +00:00
using QSB.BodyCustomization ;
2023-09-28 23:50:22 +01:00
using QSB.Player.Messages ;
2020-02-10 23:03:28 +01:00
using UnityEngine ;
2022-01-18 16:19:49 -08:00
using UnityEngine.InputSystem ;
2020-02-10 23:03:28 +01:00
2020-12-17 23:18:47 +00:00
/ *
2023-01-01 14:40:28 +00:00
Copyright ( C ) 2020 - 2023
2021-11-09 17:56:45 -08:00
Henry Pointer ( _nebula / misternebula ) ,
2021-12-19 21:19:11 -08:00
Will Corby ( JohnCorby ) ,
2021-11-09 17:56:45 -08:00
Aleksander Waage ( AmazingAlek ) ,
2020-12-19 21:14:05 +00:00
Ricardo Lopes ( Raicuparta )
2021-11-09 17:56:45 -08: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/.
2022-05-22 07:13:38 +01:00
This work is unofficial Fan Content created under permission from the Mobius Digital Fan Content Policy .
It includes materials which are the property of Mobius Digital and it is neither approved nor endorsed by Mobius Digital .
2020-12-17 23:18:47 +00:00
* /
2022-03-02 19:46:33 -08:00
namespace QSB ;
public class QSBCore : ModBehaviour
2020-02-15 20:48:02 +01:00
{
2022-03-02 19:46:33 -08:00
public static IModHelper Helper { get ; private set ; }
public static string DefaultServerIP ;
public static AssetBundle NetworkAssetBundle { get ; private set ; }
public static AssetBundle ConversationAssetBundle { get ; private set ; }
public static AssetBundle DebugAssetBundle { get ; private set ; }
2023-02-10 12:01:19 +00:00
public static AssetBundle HUDAssetBundle { get ; private set ; }
2022-03-02 19:46:33 -08:00
public static bool IsHost = > NetworkServer . active ;
2022-07-22 13:39:00 +01:00
public static bool IsInMultiplayer ;
2022-03-25 19:38:33 -07:00
public static string QSBVersion = > Helper . Manifest . Version ;
2022-03-17 22:54:22 -07:00
public static string GameVersion = >
// ignore the last patch numbers like the title screen does
Application . version . Split ( '.' ) . Take ( 3 ) . Join ( delimiter : "." ) ;
2022-03-02 19:46:33 -08:00
public static bool DLCInstalled = > EntitlementsManager . IsDlcOwned ( ) = = EntitlementsManager . AsyncOwnershipStatus . Owned ;
2023-05-06 18:44:20 -07:00
public static bool UseKcpTransport { get ; private set ; }
2022-05-11 00:04:53 +01:00
public static bool IncompatibleModsAllowed { get ; private set ; }
2022-12-02 22:27:23 +00:00
public static bool ShowPlayerNames { get ; private set ; }
2022-11-19 01:21:28 -08:00
public static bool ShipDamage { get ; private set ; }
2023-05-06 18:44:20 -07:00
public static bool ShowExtraHUDElements { get ; private set ; }
2023-06-22 20:40:37 +01:00
public static bool TextChatInput { get ; private set ; }
2023-09-28 23:50:22 +01:00
public static string SkinVariation { get ; private set ; }
public static string JetpackVariation { get ; private set ; }
2022-08-07 20:02:45 +01:00
public static GameVendor GameVendor { get ; private set ; } = GameVendor . None ;
public static bool IsStandalone = > GameVendor is GameVendor . Epic or GameVendor . Steam ;
public static IProfileManager ProfileManager = > IsStandalone
? QSBStandaloneProfileManager . SharedInstance
: QSBMSStoreProfileManager . SharedInstance ;
2022-03-02 19:46:33 -08:00
public static IMenuAPI MenuApi { get ; private set ; }
public static DebugSettings DebugSettings { get ; private set ; } = new ( ) ;
2022-11-11 14:42:04 +00:00
2022-06-13 10:18:44 -07:00
public static readonly string [ ] IncompatibleMods =
2022-05-11 00:04:53 +01:00
{
// incompatible mods
"Raicuparta.NomaiVR" ,
2023-07-27 13:05:53 +01:00
"xen.NewHorizons" ,
2022-08-13 12:18:53 +01:00
"Vesper.AutoResume" ,
"Vesper.OuterWildsMMO" ,
"_nebula.StopTime" ,
"PacificEngine.OW_Randomizer" ,
2022-05-11 00:04:53 +01:00
} ;
2023-10-29 23:55:44 +00:00
public static event Action OnSkinsBundleLoaded ;
2023-07-29 01:26:12 +01:00
public override object GetApi ( ) = > new QSBAPI ( ) ;
2022-08-07 20:02:45 +01:00
private static void DetermineGameVendor ( )
{
var gameAssemblyTypes = typeof ( AstroObject ) . Assembly . GetTypes ( ) ;
var isEpic = gameAssemblyTypes . Any ( x = > x . Name = = "EpicEntitlementRetriever" ) ;
var isSteam = gameAssemblyTypes . Any ( x = > x . Name = = "SteamEntitlementRetriever" ) ;
var isUWP = gameAssemblyTypes . Any ( x = > x . Name = = "MSStoreEntitlementRetriever" ) ;
if ( isEpic & & ! isSteam & & ! isUWP )
{
GameVendor = GameVendor . Epic ;
}
else if ( ! isEpic & & isSteam & & ! isUWP )
{
GameVendor = GameVendor . Steam ;
}
else if ( ! isEpic & & ! isSteam & & isUWP )
{
GameVendor = GameVendor . Gamepass ;
}
else
{
// ???
DebugLog . ToConsole ( $"FATAL - Could not determine game vendor." , MessageType . Fatal ) ;
}
2023-06-09 23:57:11 +01:00
DebugLog . ToConsole ( $"Determined game vendor as {GameVendor}" , MessageType . Info ) ;
2022-08-07 20:02:45 +01:00
}
2023-06-09 23:57:11 +01:00
private bool _steamworksInitialized ;
2022-03-02 19:46:33 -08:00
public void Awake ( )
2020-12-02 21:29:53 +00:00
{
2022-06-30 10:20:36 +01:00
// no, we cant localize this - languages are loaded after the splash screen
2022-06-08 21:57:16 +01:00
UIHelper . ReplaceUI ( UITextType . PleaseUseController ,
"<color=orange>Quantum Space Buddies</color> is best experienced with friends..." ) ;
2022-08-07 20:02:45 +01:00
DetermineGameVendor ( ) ;
QSBPatchManager . Init ( ) ;
QSBPatchManager . DoPatchType ( QSBPatchTypes . OnModStart ) ;
2023-06-09 23:57:11 +01:00
if ( GameVendor ! = GameVendor . Steam )
{
2023-09-18 09:48:25 +01:00
DebugLog . DebugWrite ( $"Not steam, initializing Steamworks..." ) ;
2023-06-09 23:57:11 +01:00
if ( ! Packsize . Test ( ) )
{
DebugLog . ToConsole ( "[Steamworks.NET] Packsize Test returned false, the wrong version of Steamworks.NET is being run in this platform." , MessageType . Error ) ;
}
if ( ! DllCheck . Test ( ) )
{
DebugLog . ToConsole ( "[Steamworks.NET] DllCheck Test returned false, One or more of the Steamworks binaries seems to be the wrong version." , MessageType . Error ) ;
}
2023-06-10 00:33:30 +01:00
// from facepunch.steamworks SteamClient.cs
2023-09-18 09:48:25 +01:00
// Normally, Steam sets these env vars when launching the game through the Steam library.
// These would also be set when running the .exe directly, thanks to Steam's "DRM" in the exe.
// We're setting these manually to 480 - an AppID that every Steam account owns by default.
// This tells Steam and Steamworks that the user is playing a game they own.
// This lets anyone use Steamworks, even if they don't own Outer Wilds.
// We also don't have to worry about Steam achievements or DLC in this case.
2023-06-10 00:33:30 +01:00
Environment . SetEnvironmentVariable ( "SteamAppId" , "480" ) ;
Environment . SetEnvironmentVariable ( "SteamGameId" , "480" ) ;
2023-06-09 23:57:11 +01:00
if ( ! SteamAPI . Init ( ) )
{
2023-11-04 22:59:04 +00:00
DebugLog . ToConsole ( $"FATAL - SteamAPI.Init() failed. Do you have Steam open, and are you logged in?" , MessageType . Fatal ) ;
2023-06-09 22:32:56 -07:00
return ;
2023-06-09 23:57:11 +01:00
}
_steamworksInitialized = true ;
}
2023-06-10 01:18:17 +01:00
else
{
2023-06-09 23:54:55 -07:00
SteamRerouter . ModSide . Interop . Init ( ) ;
2023-06-09 20:57:38 -07:00
2023-09-18 09:48:25 +01:00
DebugLog . DebugWrite ( $"Is steam - overriding AppID" ) ;
2023-06-10 01:18:17 +01:00
OverrideAppId ( ) ;
}
}
public void OverrideAppId ( )
{
2023-09-18 09:48:25 +01:00
// Normally, Steam sets env vars when launching the game through the Steam library.
// These would also be set when running the .exe directly, thanks to Steam's "DRM" in the exe.
// However, for Steam players to be able to join non-Steam players, everyone has to be using Steamworks with the same AppID.
// At this point, OW has already initialized Steamworks.
// Since we handle achievements and DLC ownership in the rerouter, we need to re-initialize Steamworks with the new AppID.
// (Also, Mobius forgor to change some default Steamworks code, so sometimes these env vars aren't set at all.
// In this instance the overlay and achievements also don't work, but we can't fix that here.)
// reset steamworks instance
2023-06-10 01:18:17 +01:00
SteamManager . s_EverInitialized = false ;
var instance = SteamManager . s_instance ;
instance . m_bInitialized = false ;
SteamManager . s_instance = null ;
2023-09-18 09:48:25 +01:00
// Releases pointers and frees memory used by Steam to manage the current game.
// Does not unhook the overlay, so we dont have to worry about that :peepoHappy:
2023-06-10 01:18:17 +01:00
SteamAPI . Shutdown ( ) ;
2023-09-18 09:48:25 +01:00
// Set the env vars to an AppID that everyone owns by default.
// from facepunch.steamworks SteamClient.cs
2023-06-10 01:42:26 +01:00
Environment . SetEnvironmentVariable ( "SteamAppId" , "480" ) ;
Environment . SetEnvironmentVariable ( "SteamGameId" , "480" ) ;
2023-06-10 01:18:17 +01:00
2023-09-18 09:48:25 +01:00
// Re-initialize Steamworks.
2023-06-10 01:18:17 +01:00
instance . InitializeOnAwake ( ) ;
2023-09-18 09:48:25 +01:00
2023-06-09 18:41:04 -07:00
// TODO also reregister hook and gamepad thing or else i think that wont work
2023-06-09 23:57:11 +01:00
}
public void OnDestroy ( )
{
if ( _steamworksInitialized )
{
SteamAPI . Shutdown ( ) ;
}
2022-03-02 19:46:33 -08:00
}
public void Start ( )
{
Helper = ModHelper ;
DebugLog . ToConsole ( $"* Start of QSB version {QSBVersion} - authored by {Helper.Manifest.Author}" , MessageType . Info ) ;
2020-02-10 23:03:28 +01:00
2022-11-11 14:42:04 +00:00
CheckCompatibilityMods ( ) ;
2022-03-02 19:46:33 -08:00
DebugSettings = Helper . Storage . Load < DebugSettings > ( "debugsettings.json" ) ? ? new DebugSettings ( ) ;
if ( DebugSettings . HookDebugLogs )
2022-02-27 04:40:44 -08:00
{
2022-03-02 19:46:33 -08:00
Application . logMessageReceived + = ( condition , stackTrace , logType ) = >
2022-03-09 15:22:41 -08:00
DebugLog . ToConsole (
$"[Debug] {condition}" +
( stackTrace ! = string . Empty ? $"\nStacktrace: {stackTrace}" : string . Empty ) ,
logType switch
{
LogType . Error = > MessageType . Error ,
LogType . Assert = > MessageType . Error ,
LogType . Warning = > MessageType . Warning ,
LogType . Log = > MessageType . Message ,
LogType . Exception = > MessageType . Error ,
_ = > throw new ArgumentOutOfRangeException ( nameof ( logType ) , logType , null )
}
) ;
2022-02-27 04:40:44 -08:00
}
2020-12-02 18:40:38 +00:00
2022-06-07 10:44:56 -07:00
if ( DebugSettings . AutoStart )
{
2023-05-06 18:44:20 -07:00
UseKcpTransport = true ;
2022-06-07 10:44:56 -07:00
DebugSettings . DebugMode = true ;
}
2022-04-01 16:23:15 -07:00
RegisterAddons ( ) ;
InitAssemblies ( ) ;
2022-03-02 19:46:33 -08:00
2022-12-14 11:47:01 +00:00
// init again to get addon patches
QSBPatchManager . Init ( ) ;
2022-06-29 15:20:26 -07:00
MenuApi = ModHelper . Interaction . TryGetModApi < IMenuAPI > ( ModHelper . Manifest . Dependencies [ 0 ] ) ;
2022-03-02 19:46:33 -08:00
2023-10-29 23:55:44 +00:00
LoadBundleAsync ( "qsb_network_big" ) ;
2023-10-30 00:05:28 +00:00
LoadBundleAsync ( "qsb_skins" , request = > BodyCustomizer . Instance . OnBundleLoaded ( request . assetBundle ) ) ;
2022-03-04 05:15:54 -08:00
2023-10-29 23:55:44 +00:00
NetworkAssetBundle = LoadBundle ( "qsb_network" ) ;
ConversationAssetBundle = LoadBundle ( "qsb_conversation" ) ;
DebugAssetBundle = LoadBundle ( "qsb_debug" ) ;
HUDAssetBundle = LoadBundle ( "qsb_hud" ) ;
2022-03-02 19:46:33 -08:00
2023-10-29 23:55:44 +00:00
if ( NetworkAssetBundle = = null | | ConversationAssetBundle = = null | | DebugAssetBundle = = null | | HUDAssetBundle = = null )
2022-06-30 16:50:23 +01:00
{
DebugLog . ToConsole ( $"FATAL - An assetbundle is missing! Re-install mod or contact devs." , MessageType . Fatal ) ;
return ;
}
2022-04-22 20:00:52 -07:00
DeterministicManager . Init ( ) ;
2022-06-08 14:00:37 -07:00
QSBLocalization . Init ( ) ;
2022-03-02 19:46:33 -08:00
var components = typeof ( IAddComponentOnStart ) . GetDerivedTypes ( )
. Select ( x = > gameObject . AddComponent ( x ) )
. ToArray ( ) ;
QSBWorldSync . Managers = components . OfType < WorldObjectManager > ( ) . ToArray ( ) ;
QSBPatchManager . OnPatchType + = OnPatchType ;
QSBPatchManager . OnUnpatchType + = OnUnpatchType ;
}
2023-10-29 23:55:44 +00:00
private AssetBundle LoadBundle ( string name )
{
var timer = new Stopwatch ( ) ;
timer . Start ( ) ;
2023-11-12 17:23:17 -08:00
var ret = Helper . Assets . LoadBundle ( Path . Combine ( "AssetBundles" , name ) ) ;
2023-10-29 23:55:44 +00:00
timer . Stop ( ) ;
DebugLog . ToConsole ( $"Bundle {name} loaded in {timer.ElapsedMilliseconds} ms!" , MessageType . Success ) ;
return ret ;
}
private void LoadBundleAsync ( string bundleName , Action < AssetBundleCreateRequest > runOnLoaded = null )
{
DebugLog . DebugWrite ( $"Loading {bundleName}..." , MessageType . Info ) ;
var timer = new Stopwatch ( ) ;
timer . Start ( ) ;
2023-11-12 17:23:17 -08:00
var path = Path . Combine ( ModHelper . Manifest . ModFolderPath , "AssetBundles" , name ) ;
2023-10-29 23:55:44 +00:00
var request = AssetBundle . LoadFromFileAsync ( path ) ;
request . completed + = _ = >
{
timer . Stop ( ) ;
DebugLog . ToConsole ( $"Bundle {bundleName} loaded in {timer.ElapsedMilliseconds} ms!" , MessageType . Success ) ;
runOnLoaded ? . Invoke ( request ) ;
} ;
}
2022-03-02 19:46:33 -08:00
private static void OnPatchType ( QSBPatchTypes type )
{
if ( type = = QSBPatchTypes . OnClientConnect )
2021-02-18 15:36:11 +00:00
{
2022-03-02 19:46:33 -08:00
Application . runInBackground = true ;
2021-07-13 18:46:31 +01:00
}
2022-03-02 19:46:33 -08:00
}
2021-02-21 18:25:25 +00:00
2022-03-02 19:46:33 -08:00
private static void OnUnpatchType ( QSBPatchTypes type )
{
if ( type = = QSBPatchTypes . OnClientConnect )
2021-07-13 18:46:31 +01:00
{
2022-03-02 19:46:33 -08:00
Application . runInBackground = false ;
2021-02-18 15:36:11 +00:00
}
2022-03-02 19:46:33 -08:00
}
2021-02-18 15:36:11 +00:00
2022-04-01 16:23:15 -07:00
public static readonly SortedDictionary < string , IModBehaviour > Addons = new ( ) ;
2023-07-28 21:53:18 +01:00
public static readonly List < string > CosmeticAddons = new ( ) ;
2022-04-01 16:23:15 -07:00
2022-06-13 10:18:44 -07:00
private void RegisterAddons ( )
2022-03-02 19:46:33 -08:00
{
2022-06-13 10:18:44 -07:00
var addons = GetDependants ( ) ;
2022-04-01 16:23:15 -07:00
foreach ( var addon in addons )
{
2022-12-14 11:47:01 +00:00
DebugLog . DebugWrite ( $"Registering addon {addon.ModHelper.Manifest.UniqueName}" ) ;
2022-04-01 16:23:15 -07:00
Addons . Add ( addon . ModHelper . Manifest . UniqueName , addon ) ;
}
}
2023-07-28 21:53:18 +01:00
/// <summary>
/// Registers an addon that shouldn't be considered for hash checks when joining.
2023-09-01 12:17:27 -07:00
/// This addon MUST NOT create any WorldObjects or NetworkBehaviours.
2023-07-28 21:53:18 +01:00
/// </summary>
/// <param name="addon">The behaviour of the addon.</param>
2023-07-31 21:22:54 +01:00
public static void RegisterNotRequiredForAllPlayers ( IModBehaviour addon )
2023-07-28 21:53:18 +01:00
{
var uniqueName = addon . ModHelper . Manifest . UniqueName ;
var addonAssembly = addon . GetType ( ) . Assembly ;
foreach ( var type in addonAssembly . GetTypes ( ) )
{
2023-08-08 20:26:46 -07:00
if ( typeof ( WorldObjectManager ) . IsAssignableFrom ( type ) | |
typeof ( IWorldObject ) . IsAssignableFrom ( type ) | |
typeof ( NetworkBehaviour ) . IsAssignableFrom ( type ) )
2023-07-28 21:53:18 +01:00
{
2023-08-03 14:42:21 -07:00
DebugLog . ToConsole ( $"Addon \" { uniqueName } \ " cannot be cosmetic, as it creates networking objects." , MessageType . Error ) ;
2023-07-28 21:53:18 +01:00
return ;
}
}
DebugLog . DebugWrite ( $"Registering {uniqueName} as a cosmetic addon." ) ;
CosmeticAddons . Add ( uniqueName ) ;
}
2022-04-01 16:23:15 -07:00
private static void InitAssemblies ( )
{
static void Init ( Assembly assembly )
2022-01-28 18:37:28 -08:00
{
2022-03-02 19:46:33 -08:00
DebugLog . DebugWrite ( assembly . ToString ( ) ) ;
assembly
. GetTypes ( )
. SelectMany ( x = > x . GetMethods ( BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static | BindingFlags . DeclaredOnly ) )
. Where ( x = > x . IsDefined ( typeof ( RuntimeInitializeOnLoadMethodAttribute ) ) )
. ForEach ( x = > x . Invoke ( null , null ) ) ;
2022-01-28 18:37:28 -08:00
}
2022-04-01 16:23:15 -07:00
DebugLog . DebugWrite ( "Running RuntimeInitializeOnLoad methods for our assemblies" , MessageType . Info ) ;
foreach ( var path in Directory . EnumerateFiles ( Helper . Manifest . ModFolderPath , "*.dll" ) )
{
var assembly = Assembly . LoadFile ( path ) ;
Init ( assembly ) ;
}
foreach ( var addon in Addons . Values )
{
var assembly = addon . GetType ( ) . Assembly ;
Init ( assembly ) ;
}
2022-03-02 19:46:33 -08:00
DebugLog . DebugWrite ( "Assemblies initialized" , MessageType . Success ) ;
}
2022-01-18 15:50:20 -08:00
2022-05-11 00:04:53 +01:00
public override void Configure ( IModConfig config )
{
2023-05-06 20:05:54 -07:00
UseKcpTransport = config . GetSettingsValue < bool > ( "useKcpTransport" ) | | DebugSettings . AutoStart ;
2023-05-06 20:05:55 -07:00
QSBNetworkManager . UpdateTransport ( ) ;
2023-05-06 18:44:20 -07:00
2022-05-11 00:04:53 +01:00
DefaultServerIP = config . GetSettingsValue < string > ( "defaultServerIP" ) ;
IncompatibleModsAllowed = config . GetSettingsValue < bool > ( "incompatibleModsAllowed" ) ;
2022-12-02 22:27:23 +00:00
ShowPlayerNames = config . GetSettingsValue < bool > ( "showPlayerNames" ) ;
ShipDamage = config . GetSettingsValue < bool > ( "shipDamage" ) ;
2023-03-03 20:05:15 +00:00
ShowExtraHUDElements = config . GetSettingsValue < bool > ( "showExtraHud" ) ;
2023-06-22 20:40:37 +01:00
TextChatInput = config . GetSettingsValue < bool > ( "textChatInput" ) ;
2023-09-28 23:50:22 +01:00
SkinVariation = config . GetSettingsValue < string > ( "skinType" ) ;
JetpackVariation = config . GetSettingsValue < string > ( "jetpackType" ) ;
2022-12-02 22:27:23 +00:00
if ( IsHost )
2022-11-07 20:14:03 +00:00
{
2022-12-02 22:27:23 +00:00
ServerSettingsManager . ServerShowPlayerNames = ShowPlayerNames ;
new ServerSettingsMessage ( ) . Send ( ) ;
2022-11-07 20:14:03 +00:00
}
2023-09-28 23:50:22 +01:00
if ( IsInMultiplayer )
{
new PlayerInformationMessage ( ) . Send ( ) ;
}
2022-05-11 00:04:53 +01:00
}
2022-03-02 19:46:33 -08:00
private void Update ( )
{
2022-09-10 22:43:11 -07:00
if ( Keyboard . current [ Key . Q ] . isPressed & & Keyboard . current [ Key . NumpadEnter ] . wasPressedThisFrame )
2022-01-18 15:50:20 -08:00
{
2022-03-02 19:46:33 -08:00
DebugSettings . DebugMode = ! DebugSettings . DebugMode ;
2022-01-18 15:50:20 -08:00
2022-03-02 19:46:33 -08:00
GetComponent < DebugActions > ( ) . enabled = DebugSettings . DebugMode ;
2022-03-19 21:09:39 -07:00
GetComponent < DebugGUI > ( ) . enabled = DebugSettings . DebugMode ;
2022-03-02 19:46:33 -08:00
QuantumManager . UpdateFromDebugSetting ( ) ;
DebugCameraSettings . UpdateFromDebugSetting ( ) ;
2022-01-18 15:50:20 -08:00
2022-03-02 19:46:33 -08:00
DebugLog . ToConsole ( $"DEBUG MODE = {DebugSettings.DebugMode}" ) ;
2022-01-18 15:50:20 -08:00
}
2023-06-09 23:57:11 +01:00
if ( _steamworksInitialized )
{
SteamAPI . RunCallbacks ( ) ;
}
2020-12-02 21:29:53 +00:00
}
2022-11-11 14:42:04 +00:00
private void CheckCompatibilityMods ( )
{
var mainMod = "" ;
var compatMod = "" ;
var missingCompat = false ;
2023-07-28 18:12:15 +01:00
/ * if ( Helper . Interaction . ModExists ( NEW_HORIZONS ) & & ! Helper . Interaction . ModExists ( NEW_HORIZONS_COMPAT ) )
2022-11-11 14:42:04 +00:00
{
mainMod = NEW_HORIZONS ;
compatMod = NEW_HORIZONS_COMPAT ;
missingCompat = true ;
2023-07-28 18:12:15 +01:00
} * /
2022-11-11 14:42:04 +00:00
if ( missingCompat )
{
DebugLog . ToConsole ( $"FATAL - You have mod \" { mainMod } \ " installed, which is not compatible with QSB without the compatibility mod \"{compatMod}\". " +
$"Either disable the mod, or install/enable the compatibility mod." , MessageType . Fatal ) ;
}
}
2021-06-18 21:54:32 +01:00
}