diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 3166dd5..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Other Installed Mods** -- SomeMod v1.2.3 -- AnotherMod v3.2.1 - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Additional context** -Add any other context about the problem here. diff --git a/.github/workflows/OpenedIssue.yml b/.github/workflows/OpenedIssue.yml deleted file mode 100644 index 1e983ea..0000000 --- a/.github/workflows/OpenedIssue.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Opened Issue -on: - issues: - types: [opened] -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: 'Opened Issue' - uses: umahmood/pushover-actions@main - env: - PUSHOVER_TOKEN: ${{ secrets.PUSHOVER_TOKEN }} - PUSHOVER_USER: ${{ secrets.PUSHOVER_USER }} - with: - title: 'Opened Issue' diff --git a/.idea/.idea.MMOKitchen/.idea/.gitignore b/.idea/.idea.MMOKitchen.dir/.idea/.gitignore similarity index 73% rename from .idea/.idea.MMOKitchen/.idea/.gitignore rename to .idea/.idea.MMOKitchen.dir/.idea/.gitignore index 01ba2b3..625d627 100644 --- a/.idea/.idea.MMOKitchen/.idea/.gitignore +++ b/.idea/.idea.MMOKitchen.dir/.idea/.gitignore @@ -1,4 +1,4 @@ -# Default ignored files +# Default ignored files /shelf/ /workspace.xml # Rider ignored files @@ -11,3 +11,5 @@ # Datasource local storage ignored files /dataSources/ /dataSources.local.xml +# GitHub Copilot persisted chat sessions +/copilot/chatSessions diff --git a/.idea/.idea.MMOKitchen.dir/.idea/encodings.xml b/.idea/.idea.MMOKitchen.dir/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.MMOKitchen.dir/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.MMOKitchen/.idea/indexLayout.xml b/.idea/.idea.MMOKitchen.dir/.idea/indexLayout.xml similarity index 100% rename from .idea/.idea.MMOKitchen/.idea/indexLayout.xml rename to .idea/.idea.MMOKitchen.dir/.idea/indexLayout.xml diff --git a/.idea/.idea.MMOKitchen/.idea/vcs.xml b/.idea/.idea.MMOKitchen/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/.idea.MMOKitchen/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/MMOKitchen/Changelogs/v0.1.6.MD b/Changelogs/Github/v0.1.6.MD similarity index 100% rename from MMOKitchen/Changelogs/v0.1.6.MD rename to Changelogs/Github/v0.1.6.MD diff --git a/MMOKitchen/Changelogs/v0.1.7.MD b/Changelogs/Github/v0.1.7.MD similarity index 100% rename from MMOKitchen/Changelogs/v0.1.7.MD rename to Changelogs/Github/v0.1.7.MD diff --git a/MMOKitchen/Changelogs/v0.1.8.MD b/Changelogs/Github/v0.1.8.MD similarity index 100% rename from MMOKitchen/Changelogs/v0.1.8.MD rename to Changelogs/Github/v0.1.8.MD diff --git a/MMOKitchen/Changelogs/v0.1.9.MD b/Changelogs/Github/v0.1.9.MD similarity index 100% rename from MMOKitchen/Changelogs/v0.1.9.MD rename to Changelogs/Github/v0.1.9.MD diff --git a/MMOKitchen/Changelogs/v0.2.0.MD b/Changelogs/Github/v0.2.0.MD similarity index 100% rename from MMOKitchen/Changelogs/v0.2.0.MD rename to Changelogs/Github/v0.2.0.MD diff --git a/MMOKitchen/Changelogs/v0.2.1.MD b/Changelogs/Github/v0.2.1.MD similarity index 100% rename from MMOKitchen/Changelogs/v0.2.1.MD rename to Changelogs/Github/v0.2.1.MD diff --git a/Changelogs/Github/v0.3.0.MD b/Changelogs/Github/v0.3.0.MD new file mode 100644 index 0000000..9ca97df --- /dev/null +++ b/Changelogs/Github/v0.3.0.MD @@ -0,0 +1,4 @@ +# Release Notes v0.3.0 + +- Rewrote backend. +- Increased player cap to 100 \ No newline at end of file diff --git a/Changelogs/Workshop/v0.3.0.MD b/Changelogs/Workshop/v0.3.0.MD new file mode 100644 index 0000000..a1eff04 --- /dev/null +++ b/Changelogs/Workshop/v0.3.0.MD @@ -0,0 +1,4 @@ +[h1]Release Notes v0.3.0[/h1] + +- Rewrote backend. +- Increased player cap to 100 \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index c62d6e3..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022 StarFluxMods - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/MMOKitchen.csproj b/MMOKitchen.csproj new file mode 100644 index 0000000..2cf881b --- /dev/null +++ b/MMOKitchen.csproj @@ -0,0 +1,31 @@ + + + + net472 + Release;Debug + $(MSBuildProjectName)-Workshop + latest + CS0114 + + + + $(ProjectDir)UnityProject - MMOKitchen\content\mod.assets + + + + + + + + + + + + + + + + + + + diff --git a/MMOKitchen.sln b/MMOKitchen.sln deleted file mode 100644 index 927befc..0000000 --- a/MMOKitchen.sln +++ /dev/null @@ -1,24 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.3.32811.315 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MMOKitchen", "MMOKitchen\MMOKitchen.csproj", "{008489AE-40DC-433A-8037-E846C6EAC883}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {008489AE-40DC-433A-8037-E846C6EAC883}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {008489AE-40DC-433A-8037-E846C6EAC883}.Debug|Any CPU.Build.0 = Debug|Any CPU - {008489AE-40DC-433A-8037-E846C6EAC883}.Release|Any CPU.ActiveCfg = Workshop|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {AA51C7D7-1CC8-4304-9540-D214CFFF8597} - EndGlobalSection -EndGlobal diff --git a/MMOKitchen/MMOKitchen.csproj b/MMOKitchen/MMOKitchen.csproj deleted file mode 100644 index 0ae5110..0000000 --- a/MMOKitchen/MMOKitchen.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - net472 - latest - - - - - - diff --git a/MMOKitchen/Main.cs b/MMOKitchen/Main.cs deleted file mode 100644 index 69ed74a..0000000 --- a/MMOKitchen/Main.cs +++ /dev/null @@ -1,65 +0,0 @@ -using Kitchen; -using KitchenLib; -using KitchenLib.Event; -using KitchenLib.Preferences; -using KitchenMods; -using MMOKitchenReborn.Menus; -using System.Reflection; -using System.Runtime.CompilerServices; -using UnityEngine; - -namespace MMOKitchenReborn -{ - public class Main : BaseMod - { - public const string MOD_ID = "mmokitchen"; - public const string MOD_NAME = "MMO Kitchen"; - public const string MOD_AUTHOR = "StarFluxGames"; - public const string MOD_VERSION = "0.2.1"; - public const string MOD_COMPATIBLE_VERSIONS = ">=1.1.4"; - - public static PreferenceManager manager; - public Main() : base(MOD_ID, MOD_NAME, MOD_AUTHOR, MOD_VERSION, MOD_COMPATIBLE_VERSIONS, Assembly.GetExecutingAssembly()) { } - - protected override void OnPostActivate(Mod mod) - { - manager = new PreferenceManager(MOD_ID); - manager.RegisterPreference(new PreferenceInt("requiredConsentPercentage", 100)); - manager.RegisterPreference(new PreferenceBool("scaleAbove4Players", false)); - manager.RegisterPreference(new PreferenceFloat("scaleAbove4PlayersMultiplier", 0.1f)); - manager.Load(); - - ModsPreferencesMenu.RegisterMenu("MMO Kitchen", typeof(PreferenceMenu), typeof(PauseMenuAction)); - - Events.PreferenceMenu_PauseMenu_CreateSubmenusEvent += (s, args) => - { - args.Menus.Add(typeof(PreferenceMenu), new PreferenceMenu(args.Container, args.Module_list)); - }; - - ModsPreferencesMenu.RegisterMenu("MMO Kitchen", typeof(PreferenceMenu), typeof(MainMenuAction)); - - Events.PreferenceMenu_MainMenu_CreateSubmenusEvent += (s, args) => - { - args.Menus.Add(typeof(PreferenceMenu), new PreferenceMenu(args.Container, args.Module_list)); - }; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void LogInfo(string message) - { - Debug.Log($"[{MOD_NAME}] " + message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void LogWarning(string message) - { - Debug.LogWarning($"[{MOD_NAME}] " + message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void LogError(string message) - { - Debug.LogError($"[{MOD_NAME}] " + message); - } - } -} \ No newline at end of file diff --git a/MMOKitchen/Menus/PreferenceMenu.cs b/MMOKitchen/Menus/PreferenceMenu.cs deleted file mode 100644 index 3dc9200..0000000 --- a/MMOKitchen/Menus/PreferenceMenu.cs +++ /dev/null @@ -1,55 +0,0 @@ -using Kitchen; -using Kitchen.Modules; -using KitchenLib; -using KitchenLib.Preferences; -using System.Collections.Generic; -using UnityEngine; - -namespace MMOKitchenReborn.Menus -{ - public class PreferenceMenu : KLMenu - { - public PreferenceMenu(Transform container, ModuleList module_list) : base(container, module_list) - { - } - - public override void Setup(int player_id) - { - New(true); - AddLabel("Required Consent Percentage"); - AddSelect(requiredPercentage); - requiredPercentage.OnChanged += delegate (object _, int result) - { - Main.manager.GetPreference("requiredConsentPercentage").Set(result); - }; - - New(true); - - AddLabel("Scale Above 4 Players"); - AddSelect(scaleEnabled); - scaleEnabled.OnChanged += delegate (object _, bool result) - { - Main.manager.GetPreference("scaleAbove4Players").Set(result); - }; - - AddLabel("Scale Multiplier"); - AddSelect(scaleMultiplier); - scaleMultiplier.OnChanged += delegate (object _, float result) - { - Main.manager.GetPreference("scaleAbove4PlayersMultiplier").Set(result); - }; - - New(true); - New(true); - - AddButton(base.Localisation["MENU_BACK_SETTINGS"], delegate (int i) - { - Main.manager.Save(); - this.RequestPreviousMenu(); - }, 0, 1f, 0.2f); - } - private Option requiredPercentage = new Option(new List { 25, 50, 75, 100 }, Main.manager.GetPreference("requiredConsentPercentage").Get(), new List { "25%", "50%", "75%", "100%" }); - private Option scaleMultiplier = new Option(new List { 0.1f, 0.2f, 0.3f, 0.4f, 0, 5f, 0.6f, 0.7f, 0.8f, 0.9f, 1f }, Main.manager.GetPreference("scaleAbove4PlayersMultiplier").Get(), new List { "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1.0" }); - private Option scaleEnabled = new Option(new List { true, false }, Main.manager.GetPreference("scaleAbove4Players").Get(), new List { "Enabled", "Disabled" }); - } -} diff --git a/MMOKitchen/Patches/ConsentElement_Patch.cs b/MMOKitchen/Patches/ConsentElement_Patch.cs deleted file mode 100644 index a214348..0000000 --- a/MMOKitchen/Patches/ConsentElement_Patch.cs +++ /dev/null @@ -1,55 +0,0 @@ -using HarmonyLib; -using Kitchen; -using Kitchen.Modules; -using KitchenLib.Preferences; -using KitchenLib.Utils; -using System.Collections.Generic; -using System.Reflection; -using UnityEngine; - -namespace MMOKitchenReborn.Patches -{ - [HarmonyPatch(typeof(ConsentElement), "Update")] - public class ConsentElement_Patch - { - public static bool Prefix(ConsentElement __instance) - { - - PlayerManager pm = Unity.Entities.World.DefaultGameObjectInjectionWorld.GetExistingSystem(); - if (pm == null) - { - return true; - } - - MethodInfo updateBar = ReflectionUtils.GetMethod("UpdateBar"); - MethodInfo getProgressSpeed = ReflectionUtils.GetMethod("GetProgressSpeed"); - FieldInfo progress = ReflectionUtils.GetField("Progress"); - PropertyInfo isCompleted = AccessTools.Property(typeof(ConsentElement), "IsCompleted"); - - FieldInfo consentsSwap = ReflectionUtils.GetField("ConsentsSwap"); - - Dictionary x = (Dictionary)consentsSwap.GetValue(__instance); - - int counter = 0; - foreach (int y in x.Keys) - if (x[y]) - counter++; - - float progressSpeed = (float)getProgressSpeed.Invoke(__instance, new object[] { }); - - if ((((float)counter / (float)x.Count) * 100) >= Main.manager.GetPreference("requiredConsentPercentage").Value) - progressSpeed = 1f; - - if (progressSpeed <= 0f) - progress.SetValue(__instance, (float)progress.GetValue(__instance) - (2f * Time.unscaledDeltaTime)); - else - progress.SetValue(__instance, (float)progress.GetValue(__instance) + (progressSpeed * Time.unscaledDeltaTime)); - - isCompleted.SetValue(__instance, ((float)progress.GetValue(__instance) >= 1f)); - progress.SetValue(__instance, Mathf.Clamp01((float)progress.GetValue(__instance))); - updateBar.Invoke(__instance, new object[] { }); - - return false; - } - } -} diff --git a/MMOKitchen/Patches/DifficultyHelpers_Patch.cs b/MMOKitchen/Patches/DifficultyHelpers_Patch.cs deleted file mode 100644 index f87c48f..0000000 --- a/MMOKitchen/Patches/DifficultyHelpers_Patch.cs +++ /dev/null @@ -1,37 +0,0 @@ -using HarmonyLib; -using Kitchen; -using KitchenLib.Preferences; - -namespace MMOKitchenReborn.Patches -{ - [HarmonyPatch(typeof(DifficultyHelpers))] - public class DifficultyHelpers_Patch - { - [HarmonyPatch("CustomerPlayersRateModifier")] - [HarmonyPostfix] - static void CustomerPlayersRateModifier_Postfix(ref float __result, int player_count) - { - if (Main.manager.GetPreference("scaleAbove4Players").Value) - if (player_count > 4) - __result = 1 + (player_count * Main.manager.GetPreference("scaleAbove4PlayersMultiplier").Value); - } - - [HarmonyPatch("FireSpreadModifier")] - [HarmonyPostfix] - static void FireSpreadModifier_Postfix(ref float __result, int player_count) - { - if (Main.manager.GetPreference("scaleAbove4Players").Value) - if (player_count > 4) - __result = 0.75f + (player_count * Main.manager.GetPreference("scaleAbove4PlayersMultiplier").Value); - } - - [HarmonyPatch("PatiencePlayerCountModifier")] - [HarmonyPostfix] - static void PatiencePlayerCountModifier_Postfix(ref float __result, int player_count) - { - if (Main.manager.GetPreference("scaleAbove4Players").Value) - if (player_count > 4) - __result = 0.75f + (player_count * Main.manager.GetPreference("scaleAbove4PlayersMultiplier").Value); - } - } -} diff --git a/MMOKitchen/Patches/DiscordPlatform_Patch.cs b/MMOKitchen/Patches/DiscordPlatform_Patch.cs deleted file mode 100644 index 9be2e3d..0000000 --- a/MMOKitchen/Patches/DiscordPlatform_Patch.cs +++ /dev/null @@ -1,25 +0,0 @@ -using HarmonyLib; -using Kitchen.NetworkSupport; -using System.Collections.Generic; -using System.Reflection.Emit; - -namespace MMOKitchenReborn.Patches -{ - /* - * This patch is used to change how many players can join the lobby using Discord. - */ - - [HarmonyPatch(typeof(DiscordPlatform), "CreateNewLobby")] - public static class DiscordPlatform_Patch - { - static IEnumerable Transpiler(IEnumerable instructions) - { - var codes = new List(instructions); - for (var i = 0; i < codes.Count; i++) - if (codes[i].opcode == OpCodes.Ldc_I4_4) - codes[i].opcode = OpCodes.Ldc_I4_8; - - return codes; - } - } -} diff --git a/MMOKitchen/Patches/PlayerManager_Patch.cs b/MMOKitchen/Patches/PlayerManager_Patch.cs deleted file mode 100644 index fe130ff..0000000 --- a/MMOKitchen/Patches/PlayerManager_Patch.cs +++ /dev/null @@ -1,17 +0,0 @@ -using HarmonyLib; -using Kitchen; -using KitchenLib.Utils; -using System.Reflection; - -namespace MMOKitchenReborn.Patches -{ - [HarmonyPatch(typeof(PlayerManager), "Initialise")] - public class PlayerManager_Patch - { - static void Prefix(PlayerManager __instance) - { - FieldInfo maxPlayers = ReflectionUtils.GetField("MaxPlayers"); - maxPlayers.SetValue(__instance, 12); - } - } -} diff --git a/MMOKitchen/Patches/SteamPlatform_Patch.cs b/MMOKitchen/Patches/SteamPlatform_Patch.cs deleted file mode 100644 index 5874346..0000000 --- a/MMOKitchen/Patches/SteamPlatform_Patch.cs +++ /dev/null @@ -1,42 +0,0 @@ -using HarmonyLib; -using Kitchen.NetworkSupport; -using Steamworks; -using Steamworks.Data; -using System; -using System.Reflection; -using System.Threading.Tasks; - -namespace MMOKitchenReborn.Patches -{ - /* - * This patch is used to change how many players can join the lobby using Steam. - */ - - [HarmonyPatch(typeof(SteamPlatform), "CreateNewLobby")] - public class SteamPlatform_Patch - { - public static bool Prefix(SteamPlatform __instance, Action callback) - { - if (__instance.IsReady) - { - SteamMatchmaking.CreateLobbyAsync(12).ContinueWith(delegate (Task task) - { - if (task.IsCompleted && task.Result != null) - { - Lobby valueOrDefault = task.Result.GetValueOrDefault(); - __instance.CurrentInviteLobby = valueOrDefault; - - MethodInfo performSetPermissions = AccessTools.Method(typeof(SteamPlatform), "PerformSetPermissions"); - performSetPermissions.Invoke(__instance, new object[] { __instance.Permissions }); - callback(true, valueOrDefault); - } - else - { - callback(false, default(Lobby)); - } - }); - } - return false; - } - } -} diff --git a/MMOKitchen/Systems/AnyProfileEditor.cs b/MMOKitchen/Systems/AnyProfileEditor.cs deleted file mode 100644 index 1141c4b..0000000 --- a/MMOKitchen/Systems/AnyProfileEditor.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Kitchen; -using KitchenMods; - -namespace MMOKitchenReborn.Systems; - -public class AnyProfileEditor : InteractionSystem, IModSystem -{ - protected override bool IsPossible(ref InteractionData data) - { - return Require(data.Target, out Editor); - } - - protected override void Perform(ref InteractionData data) - { - Editor.IsTriggered = true; - Editor.TriggerEntity = data.Interactor; - SetComponent(data.Target, Editor); - } - - private CTriggerProfileEditor Editor; -} \ No newline at end of file diff --git a/Menus/PreferenceMenu.cs b/Menus/PreferenceMenu.cs new file mode 100644 index 0000000..dff29ef --- /dev/null +++ b/Menus/PreferenceMenu.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; +using Kitchen; +using Kitchen.Modules; +using KitchenLib; +using KitchenLib.Preferences; +using UnityEngine; + +namespace MMOKitchen.Menus +{ + public class PreferenceMenu : KLMenu + { + public PreferenceMenu(Transform container, ModuleList module_list) : base(container, module_list) + { + } + + private Option requiredPercentage = new Option(new List { 25, 50, 75, 100 }, Mod.manager.GetPreference("requiredConsentPercentage").Get(), new List { "25%", "50%", "75%", "100%" }); + private Option scaleMultiplier = new Option(new List { 0.1f, 0.2f, 0.3f, 0.4f, 0, 5f, 0.6f, 0.7f, 0.8f, 0.9f, 1f }, Mod.manager.GetPreference("scaleAbove4PlayersMultiplier").Get(), new List { "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1.0" }); + private Option scaleEnabled = new Option(new List { true, false }, Mod.manager.GetPreference("scaleAbove4Players").Get(), new List { "Enabled", "Disabled" }); + + public override void Setup(int player_id) + { + New(true); + AddLabel("Required Consent Percentage"); + AddSelect(requiredPercentage); + requiredPercentage.OnChanged += delegate (object _, int result) + { + Mod.manager.GetPreference("requiredConsentPercentage").Set(result); + }; + + New(true); + + AddLabel("Scale Above 4 Players"); + AddSelect(scaleEnabled); + scaleEnabled.OnChanged += delegate (object _, bool result) + { + Mod.manager.GetPreference("scaleAbove4Players").Set(result); + }; + + AddLabel("Scale Multiplier"); + AddSelect(scaleMultiplier); + scaleMultiplier.OnChanged += delegate (object _, float result) + { + Mod.manager.GetPreference("scaleAbove4PlayersMultiplier").Set(result); + }; + + New(true); + New(true); + + AddButton(base.Localisation["MENU_BACK_SETTINGS"], delegate (int i) + { + Mod.manager.Save(); + this.RequestPreviousMenu(); + }, 0, 1f, 0.2f); + } + } +} diff --git a/Mod.cs b/Mod.cs new file mode 100644 index 0000000..6fb694d --- /dev/null +++ b/Mod.cs @@ -0,0 +1,61 @@ +using KitchenLib; +using KitchenLib.Logging; +using KitchenMods; +using System.Reflection; +using Kitchen; +using KitchenLib.Event; +using KitchenLib.Preferences; +using MMOKitchen.Menus; + +namespace MMOKitchen +{ + public class Mod : BaseMod, IModSystem + { + public const string MOD_GUID = "com.starfluxgames.mmokitchen"; + public const string MOD_NAME = "MMO Kitchen"; + public const string MOD_VERSION = "0.3.0"; + public const string MOD_AUTHOR = "StarFluxGames"; + public const string MOD_GAMEVERSION = ">=1.1.9"; + + public static KitchenLogger Logger; + public static PreferenceManager manager; + + public static int MaxPlayers = 100; + + public Mod() : base(MOD_GUID, MOD_NAME, MOD_AUTHOR, MOD_VERSION, MOD_GAMEVERSION, Assembly.GetExecutingAssembly()) { } + + protected override void OnInitialise() + { + Logger.LogWarning($"{MOD_GUID} v{MOD_VERSION} in use!"); + } + + protected override void OnUpdate() + { + } + + protected override void OnPostActivate(KitchenMods.Mod mod) + { + Logger = InitLogger(); + manager = new PreferenceManager("mmokitchen"); // Keeping the old GUID so we don't have to reset the preferences + manager.RegisterPreference(new PreferenceInt("requiredConsentPercentage", 100)); + manager.RegisterPreference(new PreferenceBool("scaleAbove4Players", false)); + manager.RegisterPreference(new PreferenceFloat("scaleAbove4PlayersMultiplier", 0.1f)); + manager.Load(); + + ModsPreferencesMenu.RegisterMenu(MOD_NAME, typeof(PreferenceMenu), typeof(PauseMenuAction)); + + Events.PreferenceMenu_PauseMenu_CreateSubmenusEvent += (s, args) => + { + args.Menus.Add(typeof(PreferenceMenu), new PreferenceMenu(args.Container, args.Module_list)); + }; + + ModsPreferencesMenu.RegisterMenu(MOD_NAME, typeof(PreferenceMenu), typeof(MainMenuAction)); + + Events.PreferenceMenu_MainMenu_CreateSubmenusEvent += (s, args) => + { + args.Menus.Add(typeof(PreferenceMenu), new PreferenceMenu(args.Container, args.Module_list)); + }; + } + } +} + diff --git a/Patches/ConsentElementPatch.cs b/Patches/ConsentElementPatch.cs new file mode 100644 index 0000000..7f82ee0 --- /dev/null +++ b/Patches/ConsentElementPatch.cs @@ -0,0 +1,55 @@ +using HarmonyLib; +using Kitchen; +using Kitchen.Modules; +using KitchenLib.Preferences; +using KitchenLib.Utils; +using System.Collections.Generic; +using System.Reflection; +using UnityEngine; + +namespace MMOKitchen.Patches +{ + [HarmonyPatch(typeof(ConsentElement), "Update")] + public class ConsentElementPatch + { + public static bool Prefix(ConsentElement __instance) + { + + PlayerManager pm = Unity.Entities.World.DefaultGameObjectInjectionWorld.GetExistingSystem(); + if (pm == null) + { + return true; + } + + MethodInfo updateBar = ReflectionUtils.GetMethod("UpdateBar"); + MethodInfo getProgressSpeed = ReflectionUtils.GetMethod("GetProgressSpeed"); + FieldInfo progress = ReflectionUtils.GetField("Progress"); + PropertyInfo isCompleted = AccessTools.Property(typeof(ConsentElement), "IsCompleted"); + + FieldInfo consentsSwap = ReflectionUtils.GetField("ConsentsSwap"); + + Dictionary x = (Dictionary)consentsSwap.GetValue(__instance); + + int counter = 0; + foreach (int y in x.Keys) + if (x[y]) + counter++; + + float progressSpeed = (float)getProgressSpeed.Invoke(__instance, new object[] { }); + + if ((((float)counter / (float)x.Count) * 100) >= Mod.manager.GetPreference("requiredConsentPercentage").Value) + progressSpeed = 1f; + + if (progressSpeed <= 0f) + progress.SetValue(__instance, (float)progress.GetValue(__instance) - (2f * Time.unscaledDeltaTime)); + else + progress.SetValue(__instance, (float)progress.GetValue(__instance) + (progressSpeed * Time.unscaledDeltaTime)); + + isCompleted.SetValue(__instance, ((float)progress.GetValue(__instance) >= 1f)); + progress.SetValue(__instance, Mathf.Clamp01((float)progress.GetValue(__instance))); + updateBar.Invoke(__instance, new object[] { }); + + return false; + } + } +} diff --git a/Patches/DifficultyHelpersPatch.cs b/Patches/DifficultyHelpersPatch.cs new file mode 100644 index 0000000..c6a5119 --- /dev/null +++ b/Patches/DifficultyHelpersPatch.cs @@ -0,0 +1,37 @@ +using HarmonyLib; +using Kitchen; +using KitchenLib.Preferences; + +namespace MMOKitchen.Patches +{ + [HarmonyPatch(typeof(DifficultyHelpers))] + public class DifficultyHelpersPatch + { + [HarmonyPatch("CustomerPlayersRateModifier")] + [HarmonyPostfix] + static void CustomerPlayersRateModifier_Postfix(ref float __result, int player_count) + { + if (Mod.manager.GetPreference("scaleAbove4Players").Value) + if (player_count > 4) + __result = 1 + (player_count * Mod.manager.GetPreference("scaleAbove4PlayersMultiplier").Value); + } + + [HarmonyPatch("FireSpreadModifier")] + [HarmonyPostfix] + static void FireSpreadModifier_Postfix(ref float __result, int player_count) + { + if (Mod.manager.GetPreference("scaleAbove4Players").Value) + if (player_count > 4) + __result = 0.75f + (player_count * Mod.manager.GetPreference("scaleAbove4PlayersMultiplier").Value); + } + + [HarmonyPatch("PatiencePlayerCountModifier")] + [HarmonyPostfix] + static void PatiencePlayerCountModifier_Postfix(ref float __result, int player_count) + { + if (Mod.manager.GetPreference("scaleAbove4Players").Value) + if (player_count > 4) + __result = 0.75f + (player_count * Mod.manager.GetPreference("scaleAbove4PlayersMultiplier").Value); + } + } +} diff --git a/Patches/PlayerManagerPatch.cs b/Patches/PlayerManagerPatch.cs new file mode 100644 index 0000000..bdde33b --- /dev/null +++ b/Patches/PlayerManagerPatch.cs @@ -0,0 +1,17 @@ +using HarmonyLib; +using Kitchen; +using KitchenLib.Utils; +using System.Reflection; + +namespace MMOKitchen.Patches +{ + [HarmonyPatch(typeof(PlayerManager), "GetLeastUnusedIndex")] + public class PlayerManagerPatch + { + static void Prefix(PlayerManager __instance) + { + FieldInfo info = ReflectionUtils.GetField("MaxPlayers"); + info.SetValue(__instance, Mod.MaxPlayers); + } + } +} diff --git a/Patches/SteamPlatformPatch.cs b/Patches/SteamPlatformPatch.cs new file mode 100644 index 0000000..be3e937 --- /dev/null +++ b/Patches/SteamPlatformPatch.cs @@ -0,0 +1,42 @@ +using HarmonyLib; +using Kitchen.NetworkSupport; +using Steamworks; +using Steamworks.Data; +using System; +using System.Reflection; +using System.Threading.Tasks; + +namespace MMOKitchen.Patches +{ + /* + * This patch is used to change how many players can join the lobby using Steam. + */ + + [HarmonyPatch(typeof(SteamPlatform), "CreateNewLobby")] + public class SteamPlatformPatch + { + public static bool Prefix(SteamPlatform __instance, Action callback) + { + if (__instance.IsReady) + { + SteamMatchmaking.CreateLobbyAsync(Mod.MaxPlayers).ContinueWith(delegate (Task task) + { + if (task.IsCompleted && task.Result != null) + { + Lobby valueOrDefault = task.Result.GetValueOrDefault(); + __instance.CurrentInviteLobby = valueOrDefault; + + MethodInfo performSetPermissions = AccessTools.Method(typeof(SteamPlatform), "PerformSetPermissions"); + performSetPermissions.Invoke(__instance, new object[] { __instance.Permissions }); + callback(true, valueOrDefault); + } + else + { + callback(false, default(Lobby)); + } + }); + } + return false; + } + } +} diff --git a/README.md b/README.md deleted file mode 100644 index 4e07d82..0000000 --- a/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# MMOKitchen - -## Description - -4 Staff just isn't enough? Hire 8 more for your team! - -MMOKitchen allows up to 12 more players to join your game! - -## Requirements - -- KitchenLib >= 0.3.0 - -## Installation - -- Subscribe on the Steam Workshop - -## Credits - -Massive shoutouts to `bedbug1226#5243` , `ava233#3113` , `Aragami_delp_#5775`, and `Caracal#1469` for helping test this mod! - -Massive thanks to `Aragami_delp_#5775` for finding the bug causing Network Players to have problems joining. diff --git a/Systems/ProfileEditorOverride.cs b/Systems/ProfileEditorOverride.cs new file mode 100644 index 0000000..5ff9d03 --- /dev/null +++ b/Systems/ProfileEditorOverride.cs @@ -0,0 +1,22 @@ +using Kitchen; +using KitchenMods; + +namespace MMOKitchen.Systems +{ + public class ProfileEditorOverride : InteractionSystem, IModSystem + { + protected override bool IsPossible(ref InteractionData data) + { + return Require(data.Target, out Editor); + } + + protected override void Perform(ref InteractionData data) + { + Editor.IsTriggered = true; + Editor.TriggerEntity = data.Interactor; + SetComponent(data.Target, Editor); + } + + private CTriggerProfileEditor Editor; + } +} \ No newline at end of file