diff --git a/Centrifuge.Mods.Distance.sln b/Centrifuge.Mods.Distance.sln
index 3376d4a..32b9dae 100644
--- a/Centrifuge.Mods.Distance.sln
+++ b/Centrifuge.Mods.Distance.sln
@@ -35,10 +35,13 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Distance.CustomDeathMessage
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Distance.NoServerLimit", "Distance.NoServerLimit\Distance.NoServerLimit.csproj", "{249F576D-6A84-46D7-BAC7-308810DDDF8B}"
EndProject
+Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Distance.NoServerLimit.Content", "Distance.NoServerLimit.Content\Distance.NoServerLimit.Content.shproj", "{260FE22A-730A-4723-A744-DD06302F92CB}"
+EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Distance.TextureModifier.Content\Distance.TextureModifier.Content.projitems*{06a78a9a-7a66-431f-8023-36eaa5d0fbaf}*SharedItemsImports = 4
Distance.TextureModifier.Content\Distance.TextureModifier.Content.projitems*{07d04eb9-6ab9-46cf-a3c3-a2e1d24fbeef}*SharedItemsImports = 13
+ Distance.NoServerLimit.Content\Distance.NoServerLimit.Content.projitems*{260fe22a-730a-4723-a744-dd06302f92cb}*SharedItemsImports = 13
Distance.CustomDeathMessages.Content\Distance.CustomDeathMessages.Content.projitems*{57657ebc-1f29-4357-b4ef-45b2b22f5a3f}*SharedItemsImports = 13
Distance.TrackMusic.Content\Distance.TrackMusic.Content.projitems*{58bfee58-73a0-4451-9da7-0fb51f1c53ea}*SharedItemsImports = 13
Distance.SceneDumper.Content\Distance.SceneDumper.Content.projitems*{e84718c2-200c-415f-ad1d-0cc133c38e70}*SharedItemsImports = 13
diff --git a/Distance.NoServerLimit.Content/Distance.NoServerLimit.Content.projitems b/Distance.NoServerLimit.Content/Distance.NoServerLimit.Content.projitems
new file mode 100644
index 0000000..f263d0a
--- /dev/null
+++ b/Distance.NoServerLimit.Content/Distance.NoServerLimit.Content.projitems
@@ -0,0 +1,16 @@
+
+
+
+ $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
+ true
+ 260fe22a-730a-4723-a744-dd06302f92cb
+
+
+ Distance.NoServerLimit.Content
+
+
+
+ Always
+
+
+
\ No newline at end of file
diff --git a/Distance.NoServerLimit.Content/Distance.NoServerLimit.Content.shproj b/Distance.NoServerLimit.Content/Distance.NoServerLimit.Content.shproj
new file mode 100644
index 0000000..9c207bc
--- /dev/null
+++ b/Distance.NoServerLimit.Content/Distance.NoServerLimit.Content.shproj
@@ -0,0 +1,13 @@
+
+
+
+ 260fe22a-730a-4723-a744-dd06302f92cb
+ 14.0
+
+
+
+
+
+
+
+
diff --git a/Distance.NoServerLimit/mod.json b/Distance.NoServerLimit.Content/Mod/mod.json
similarity index 82%
rename from Distance.NoServerLimit/mod.json
rename to Distance.NoServerLimit.Content/Mod/mod.json
index be9912f..8e949d9 100644
--- a/Distance.NoServerLimit/mod.json
+++ b/Distance.NoServerLimit.Content/Mod/mod.json
@@ -2,7 +2,7 @@
"FriendlyName": "No Server Limit",
"Author": "Ciastex",
"Contact": "Discord: Ciastex#6170",
- "ModuleFileName": "NoServerLimit.dll",
+ "ModuleFileName": "Distance.NoServerLimit.dll",
"Priority": 10,
"SkipLoad": false,
"Dependencies": [],
diff --git a/Distance.NoServerLimit/ConfigurationLogic.cs b/Distance.NoServerLimit/ConfigurationLogic.cs
new file mode 100644
index 0000000..78e3615
--- /dev/null
+++ b/Distance.NoServerLimit/ConfigurationLogic.cs
@@ -0,0 +1,52 @@
+using Reactor.API.Configuration;
+using System;
+using UnityEngine;
+
+namespace Distance.NoServerLimit
+{
+ public class ConfigurationLogic : MonoBehaviour
+ {
+ #region Properties
+ public int MaxPlayerCount
+ {
+ get => Get("MaxPlayerCount");
+ set => Set("MaxPlayerCount", value);
+ }
+ #endregion
+
+ internal Settings Config;
+
+ public event Action OnChanged;
+
+ private void Load()
+ {
+ Config = new Settings("Server");
+ }
+
+ public void Awake()
+ {
+ Load();
+
+ Get("MaxPlayerCount", 32);
+
+ Save();
+ }
+
+ public T Get(string key, T @default = default)
+ {
+ return Config.GetOrCreate(key, @default);
+ }
+
+ public void Set(string key, T value)
+ {
+ Config[key] = value;
+ Save();
+ }
+
+ public void Save()
+ {
+ Config?.Save();
+ OnChanged?.Invoke(this);
+ }
+ }
+}
diff --git a/Distance.NoServerLimit/Distance.NoServerLimit.csproj b/Distance.NoServerLimit/Distance.NoServerLimit.csproj
index 3e8ef7f..6cc582b 100644
--- a/Distance.NoServerLimit/Distance.NoServerLimit.csproj
+++ b/Distance.NoServerLimit/Distance.NoServerLimit.csproj
@@ -67,15 +67,65 @@
-
-
+
+
+
+
-
- Always
-
+
+
+ SET MODNAME=Distance No Server Limit
+SET INCLUDE=$(SolutionDir)Distance.NoServerLimit.Content
+
+SET BUILD=$(ProjectDir)$(OutDir)
+SET PACKAGES=$(SolutionDir)Build\%25MODNAME%25\Centrifuge
+
+SET MOD=%25PACKAGES%25\Mods\%25MODNAME%25
+
+REM ===== COPY MOD FILES =====
+
+CALL :MAKEDIR "%25MOD%25"
+
+CALL :COPYDIR "%25INCLUDE%25\Mod" "%25MOD%25"
+CALL :COPY "%25BUILD%25Distance.NoServerLimit.dll" "%25MOD%25"
+
+CALL :INCLUDEGSL Centrifuge.Distance
+
+EXIT 0
+
+REM ===== BUILD SUBROUTINES =====
+
+:MAKEDIR
+IF NOT EXIST %251 MKDIR %251
+GOTO :EOF
+
+:COPY
+ECHO NUL > %252
+XCOPY /s /Y /v %251 %252
+GOTO :EOF
+
+:COPYDIR
+XCOPY /i /s /Y /v %251 %252
+GOTO :EOF
+
+:INCLUDEGSL
+CALL :MAKEDIR "%25PACKAGES%25\GameSupport"
+CALL :COPY "%25BUILD%25%251.dll" "%25PACKAGES%25\GameSupport"
+GOTO :EOF
+
+:INCLUDEDEPENDENCY
+CALL :MAKEDIR "%25MOD%25\Dependencies"
+CALL :COPY "%25BUILD%25%251.dll" "%25MOD%25\Dependencies"
+GOTO :EOF
+
+:INCLUDEDEPENDENCYRENAME
+CALL :MAKEDIR "%25MOD%25\Dependencies"
+CALL :COPY "%25BUILD%25%251.dll" "%25MOD%25\Dependencies\%252.dll"
+GOTO :EOF
+
\ No newline at end of file
diff --git a/Distance.NoServerLimit/Mod.cs b/Distance.NoServerLimit/Entry.cs
similarity index 51%
rename from Distance.NoServerLimit/Mod.cs
rename to Distance.NoServerLimit/Entry.cs
index 86ff4b3..42f4447 100644
--- a/Distance.NoServerLimit/Mod.cs
+++ b/Distance.NoServerLimit/Entry.cs
@@ -2,40 +2,38 @@
using Centrifuge.Distance.GUI.Controls;
using Centrifuge.Distance.GUI.Data;
using Reactor.API.Attributes;
-using Reactor.API.Configuration;
using Reactor.API.Interfaces.Systems;
using Reactor.API.Logging;
using Reactor.API.Runtime.Patching;
+using System;
+using UnityEngine;
-namespace ExampleNamespace
+namespace Distance.NoServerLimit
{
- [ModEntryPoint(ModID)]
- public class Mod
+ [ModEntryPoint("eu.vddcore/NoServerLimit")]
+ public class Mod : MonoBehaviour
{
- public const string ModID = "eu.vddcore/NoServerLimit";
+ public static Mod Instance;
- internal static Log Log = LogManager.GetForCurrentAssembly();
- internal static Settings Settings { get; private set; }
+ public IManager Manager { get; set; }
+
+ public Log Logger { get; set; }
+
+ public ConfigurationLogic Config { get; private set; }
public void Initialize(IManager manager)
{
- Settings = new Settings("server");
- ValidateSettings();
- CreateSettingsMenu();
+ Instance = this;
+ Manager = manager;
- RuntimePatcher.AutoPatch();
+ Logger = LogManager.GetForCurrentAssembly();
+ Config = gameObject.AddComponent();
- Log.Info("No Server Limit: Hello, world!");
- }
+ CreateSettingsMenu();
- private void ValidateSettings()
- {
- if (!Settings.ContainsKey("MaxPlayerCount"))
- {
- Settings["MaxPlayerCount"] = 32;
- }
+ RuntimePatcher.AutoPatch();
- Settings.Save();
+ Logger.Info("No Server Limit: Hello, world!");
}
private void CreateSettingsMenu()
@@ -43,19 +41,17 @@ private void CreateSettingsMenu()
MenuTree settingsMenu = new MenuTree("menu.mod.noserverlimit", "No Server Limit Settings")
{
new InputPrompt(MenuDisplayMode.MainMenu, "setting:set_server_limit", "SET MAXIMUM SERVER SLOT COUNT")
- .WithDefaultValue(() => Settings.GetItem("MaxPlayerCount").ToString())
+ .WithDefaultValue(() => Config.MaxPlayerCount.ToString())
.WithSubmitAction((x) => {
- try
+ if (int.TryParse(x, out int result))
{
- Settings["MaxPlayerCount"] = int.Parse(x);
+ Config.MaxPlayerCount = result;
}
- catch
+ else
{
- Log.Warning("Failed to parse user input. Setting defaults.");
- Settings["MaxPlayerCount"] = 32;
+ Logger.Warning("Failed to parse user input. Setting defaults.");
+ Config.MaxPlayerCount = 32;
}
-
- Settings.Save();
})
.WithTitle("ENTER SLOT COUNT")
.WithDescription("Set the maximum supported server slot count.")
diff --git a/Distance.NoServerLimit/Harmony/Assembly-CSharp/HostAGame/IncrementMaxPlayers.cs b/Distance.NoServerLimit/Harmony/Assembly-CSharp/HostAGame/IncrementMaxPlayers.cs
new file mode 100644
index 0000000..d02967f
--- /dev/null
+++ b/Distance.NoServerLimit/Harmony/Assembly-CSharp/HostAGame/IncrementMaxPlayers.cs
@@ -0,0 +1,21 @@
+using Harmony;
+
+namespace Distance.NoServerLimit.Harmony
+{
+ [HarmonyPatch(typeof(HostAGame), "IncrementMaxPlayers")]
+ internal class HostAGame__IncrementMaxPlayers
+ {
+ internal static bool Prefix(HostAGame __instance, int direction)
+ {
+ __instance.internalMaxPlayerCalc_ = GUtils.mod(__instance.internalMaxPlayerCalc_ + direction, Mod.Instance.Config.MaxPlayerCount);
+ __instance.maxPlayersLabel_.text = __instance.MaxPlayers_.ToString();
+
+ if (direction != 0 && AudioManager.Valid())
+ {
+ G.Sys.AudioManager_.PlaySound("ButtonSelect", "Menus", 1f);
+ }
+
+ return false;
+ }
+ }
+}
diff --git a/Distance.NoServerLimit/Harmony/Assembly-CSharp/NetworkingManager/CreateServer.cs b/Distance.NoServerLimit/Harmony/Assembly-CSharp/NetworkingManager/CreateServer.cs
new file mode 100644
index 0000000..06c209e
--- /dev/null
+++ b/Distance.NoServerLimit/Harmony/Assembly-CSharp/NetworkingManager/CreateServer.cs
@@ -0,0 +1,44 @@
+using Harmony;
+using System;
+using UnityEngine;
+
+namespace Distance.NoServerLimit.Harmony
+{
+ [HarmonyPatch(typeof(NetworkingManager), "CreateServer")]
+ internal class NetworkingManager__CreateServer
+ {
+ internal static bool Prefix(NetworkingManager __instance, string serverTitle, string password, int maxPlayerCount)
+ {
+ Network.InitializeSecurity();
+
+ try
+ {
+ __instance.password_ = password;
+ __instance.serverTitle_ = serverTitle;
+
+ G.Sys.GameData_.SetString("ServerTitleDefault", __instance.serverTitle_);
+
+ __instance.maxPlayerCount_ = Mathf.Clamp(maxPlayerCount, 1, Mod.Instance.Config.MaxPlayerCount);
+
+ G.Sys.GameData_.SetInt("MaxPlayersDefault", __instance.maxPlayerCount_);
+
+ int num = 1;
+ int connections = __instance.maxPlayerCount_ - num;
+
+ NetworkConnectionError networkConnectionError = Network.InitializeServer(connections, 32323, true);
+
+ if (networkConnectionError != NetworkConnectionError.NoError)
+ {
+ G.Sys.MenuPanelManager_.ShowError("Failed to create game lobby. Error code: " + networkConnectionError.ToString(), "Network Error", null, UIWidget.Pivot.Center);
+ }
+ }
+ catch (Exception ex)
+ {
+ Debug.LogError(ex.Message);
+ Mod.Instance.Logger.Exception(ex);
+ }
+
+ return false;
+ }
+ }
+}
diff --git a/Distance.NoServerLimit/Patches.cs b/Distance.NoServerLimit/Patches.cs
deleted file mode 100644
index ab80877..0000000
--- a/Distance.NoServerLimit/Patches.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-using ExampleNamespace;
-using Harmony;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using UnityEngine;
-
-namespace Distance.NoServerLimit
-{
- internal static class Patches
- {
- [HarmonyPatch(typeof(NetworkingManager), "CreateServer")]
- public static class CreateServerPatch
- {
- public static bool Prefix(NetworkingManager __instance, string serverTitle, string password, int maxPlayerCount)
- {
- Network.InitializeSecurity();
- try
- {
- __instance.password_ = password;
- __instance.serverTitle_ = serverTitle;
- G.Sys.GameData_.SetString("ServerTitleDefault", __instance.serverTitle_);
- __instance.maxPlayerCount_ = Mathf.Clamp(maxPlayerCount, 1, Mod.Settings.GetItem("MaxPlayerCount"));
- G.Sys.GameData_.SetInt("MaxPlayersDefault", __instance.maxPlayerCount_);
- int num = 1;
- int connections = __instance.maxPlayerCount_ - num;
- NetworkConnectionError networkConnectionError = Network.InitializeServer(connections, 32323, true);
- if (networkConnectionError != NetworkConnectionError.NoError)
- {
- G.Sys.MenuPanelManager_.ShowError("Failed to create game lobby. Error code: " + networkConnectionError.ToString(), "Network Error", null, UIWidget.Pivot.Center);
- }
- }
- catch (Exception ex)
- {
- Debug.LogError(ex.Message);
- }
-
- return false;
- }
-
- [HarmonyPatch(typeof(HostAGame), "IncrementMaxPlayers")]
- public static class IncrementMaxPlayersPatch
- {
- public static bool Prefix(HostAGame __instance, int direction)
- {
- __instance.internalMaxPlayerCalc_ = GUtils.mod(__instance.internalMaxPlayerCalc_ + direction, Mod.Settings.GetItem("MaxPlayerCount"));
- __instance.maxPlayersLabel_.text = __instance.MaxPlayers_.ToString();
- if (direction != 0 && AudioManager.Valid())
- {
- G.Sys.AudioManager_.PlaySound("ButtonSelect", "Menus", 1f);
- }
-
- return false;
- }
- }
- }
- }
-}
diff --git a/Distance.SceneDumper.Content/Mod/mod.json b/Distance.SceneDumper.Content/Mod/mod.json
index 72bb23d..6bc524c 100644
--- a/Distance.SceneDumper.Content/Mod/mod.json
+++ b/Distance.SceneDumper.Content/Mod/mod.json
@@ -1,7 +1,7 @@
{
"FriendlyName": "Scene Dumper",
"Author": "Ciastex",
- "Contact": "ciastex@live.com",
+ "Contact": "Discord: Ciastex#6170",
"ModuleFileName": "Distance.SceneDumper.dll",
"Priority": 10,
"SkipLoad": false,
diff --git a/Distance.SceneDumper/ConfigurationLogic.cs b/Distance.SceneDumper/ConfigurationLogic.cs
index 5716711..1862991 100644
--- a/Distance.SceneDumper/ConfigurationLogic.cs
+++ b/Distance.SceneDumper/ConfigurationLogic.cs
@@ -52,8 +52,8 @@ public void Set(string key, T value)
public void Save()
{
- Config.Save();
- OnChanged(this);
+ Config?.Save();
+ OnChanged?.Invoke(this);
}
}
}
diff --git a/Distance.SceneDumper/Entry.cs b/Distance.SceneDumper/Entry.cs
index 584a820..21459bf 100644
--- a/Distance.SceneDumper/Entry.cs
+++ b/Distance.SceneDumper/Entry.cs
@@ -14,7 +14,7 @@
namespace Distance.SceneDumper
{
- [ModEntryPoint("com.github.ciastex/Distance.SceneDumper")]
+ [ModEntryPoint("eu.vddcore/Distance.SceneDumper")]
public class Mod : MonoBehaviour
{
public static Mod Instance;
diff --git a/Distance.TrackMusic/ConfigurationLogic.cs b/Distance.TrackMusic/ConfigurationLogic.cs
index 5f55ac6..aff4033 100644
--- a/Distance.TrackMusic/ConfigurationLogic.cs
+++ b/Distance.TrackMusic/ConfigurationLogic.cs
@@ -77,8 +77,8 @@ public void Set(string key, T value)
public void Save()
{
- Config.Save();
- OnChanged(this);
+ Config?.Save();
+ OnChanged?.Invoke(this);
}
}
}
\ No newline at end of file