diff --git a/MMOKitchen/Changelog.MD b/MMOKitchen/Changelog.MD
new file mode 100644
index 0000000..369d143
--- /dev/null
+++ b/MMOKitchen/Changelog.MD
@@ -0,0 +1,5 @@
+# Release Notes v0.1.6
+
+- Added an extra door inside the workshop
+- Added democratic voting system (Editable in Preferences, default is 50%)
+- Fixed a bug causing some map layouts to not generate correctly
\ No newline at end of file
diff --git a/MMOKitchen/MMOKitchen.csproj b/MMOKitchen/MMOKitchen.csproj
index 53f2619..a2329a8 100644
--- a/MMOKitchen/MMOKitchen.csproj
+++ b/MMOKitchen/MMOKitchen.csproj
@@ -64,6 +64,9 @@
..\..\..\..\Libraries\PlateUp_Data\Managed\KitchenMods.dll
+
+ ..\..\..\..\Libraries\PlateUp_Data\Managed\Sirenix.Serialization.dll
+
..\..\..\..\Libraries\PlateUp_Data\Managed\Unity.Entities.dll
diff --git a/MMOKitchen/Main.cs b/MMOKitchen/Main.cs
index 6f2e294..20ab262 100644
--- a/MMOKitchen/Main.cs
+++ b/MMOKitchen/Main.cs
@@ -3,9 +3,16 @@ using System.Reflection;
using KitchenLib.Utils;
using UnityEngine;
using System;
+using Kitchen;
+using KitchenLib.Event;
+using MMOKitchen.Menus;
+
#if BEPINEX
using BepInEx;
#endif
+#if WORKSHOP
+using KitchenMods;
+#endif
namespace MMOKitchen
{
@@ -18,10 +25,28 @@ namespace MMOKitchen
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.1.5";
+ public const string MOD_VERSION = "0.1.6";
public const string MOD_COMPATIBLE_VERSIONS = "1.1.2";
+
+ public const string CONSENT_REQUIRED_ID = "requiredConsent";
+
+ public int RequiredConsentPercentage;
public Main() : base(MOD_ID, MOD_NAME, MOD_AUTHOR, MOD_VERSION, MOD_COMPATIBLE_VERSIONS, Assembly.GetExecutingAssembly()) { }
+#if BEPINEX
+ protected override void OnInitialise()
+#endif
+#if WORKSHOP
+ protected override void OnPostActivate(Mod mod)
+#endif
+ {
+ KitchenLib.IntPreference requiredConsent = PreferenceUtils.Register(MOD_ID, CONSENT_REQUIRED_ID, "Required Consent Percentage");
+ requiredConsent.Value = 50;
+ PreferenceUtils.Load();
+ RequiredConsentPercentage = PreferenceUtils.Get(MOD_ID, CONSENT_REQUIRED_ID).Value;
+ SetupPreferences();
+ }
+
public static Texture2D LoadImage(string base64)
{
byte[] bytes = Convert.FromBase64String(base64);
@@ -30,5 +55,36 @@ namespace MMOKitchen
return image;
}
+
+ private void SetupPreferences()
+ {
+ Events.PreferenceMenu_MainMenu_SetupEvent += (s, args) =>
+ {
+ Type type = args.instance.GetType().GetGenericArguments()[0];
+ args.mInfo.Invoke(args.instance, new object[] { MOD_NAME, typeof(MMOKitchenPreferences<>).MakeGenericType(type), false });
+ };
+
+ Events.PreferenceMenu_MainMenu_CreateSubmenusEvent += (s, args) =>
+ {
+ args.Menus.Add(typeof(MMOKitchenPreferences), new MMOKitchenPreferences(args.Container, args.Module_list));
+ };
+
+ //Setting Up For Pause Menu
+ Events.PreferenceMenu_PauseMenu_SetupEvent += (s, args) =>
+ {
+ Type type = args.instance.GetType().GetGenericArguments()[0];
+ args.mInfo.Invoke(args.instance, new object[] { MOD_NAME, typeof(MMOKitchenPreferences<>).MakeGenericType(type), false });
+ };
+ Events.PreferenceMenu_PauseMenu_CreateSubmenusEvent += (s, args) =>
+ {
+ args.Menus.Add(typeof(MMOKitchenPreferences), new MMOKitchenPreferences(args.Container, args.Module_list));
+ };
+
+ Events.PreferencesSaveEvent += (s, args) =>
+ {
+ int consentPercentage = PreferenceUtils.Get(MOD_ID, CONSENT_REQUIRED_ID).Value;
+ RequiredConsentPercentage = consentPercentage;
+ };
+ }
}
}
\ No newline at end of file
diff --git a/MMOKitchen/Menus/MMOKitchenPreferences.cs b/MMOKitchen/Menus/MMOKitchenPreferences.cs
new file mode 100644
index 0000000..d7d5cb3
--- /dev/null
+++ b/MMOKitchen/Menus/MMOKitchenPreferences.cs
@@ -0,0 +1,50 @@
+using Kitchen.Modules;
+using Kitchen;
+using KitchenLib.Utils;
+using KitchenLib;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace MMOKitchen.Menus
+{
+ public class MMOKitchenPreferences : KLMenu
+ {
+ public MMOKitchenPreferences(Transform container, ModuleList module_list) : base(container, module_list)
+ {
+ }
+ public override void Setup(int player_id)
+ {
+ this.Percentage = new Option(
+ new List
+ {
+ 25, 50, 75, 100
+ },
+ PreferenceUtils.Get(Main.MOD_ID, Main.CONSENT_REQUIRED_ID).Value,
+ new List
+ {
+ "25%", "50%", "75%", "100%"
+ });
+
+ AddLabel("Required Consent Percentage");
+ Add(this.Percentage).OnChanged += delegate (object _, int f)
+ {
+ PreferenceUtils.Get(Main.MOD_ID, Main.CONSENT_REQUIRED_ID).Value = f;
+ };
+
+ New();
+ New();
+
+ AddButton("Apply", delegate
+ {
+ PreferenceUtils.Save();
+ });
+
+ AddButton(base.Localisation["MENU_BACK_SETTINGS"], delegate
+ {
+ RequestPreviousMenu();
+ });
+ }
+
+ private Option Percentage;
+ }
+}
diff --git a/MMOKitchen/Patches/ConsentElement_Patch.cs b/MMOKitchen/Patches/ConsentElement_Patch.cs
new file mode 100644
index 0000000..29c92f2
--- /dev/null
+++ b/MMOKitchen/Patches/ConsentElement_Patch.cs
@@ -0,0 +1,52 @@
+using HarmonyLib;
+using Kitchen;
+using Kitchen.Modules;
+using KitchenLib.Utils;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using UnityEngine;
+
+namespace MMOKitchen.Patches
+{
+ [HarmonyPatch(typeof(ConsentElement), "Update")]
+ public class ConsentElement_Patch
+ {
+ public static bool Prefix(ConsentElement __instance)
+ {
+
+ 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) >= PreferenceUtils.Get(Main.MOD_ID, Main.CONSENT_REQUIRED_ID).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/FeaturesFromTexture_Patch.cs b/MMOKitchen/Patches/FeaturesFromTexture_Patch.cs
index 96570e4..0fa0693 100644
--- a/MMOKitchen/Patches/FeaturesFromTexture_Patch.cs
+++ b/MMOKitchen/Patches/FeaturesFromTexture_Patch.cs
@@ -13,7 +13,7 @@ namespace MMOKitchen
{
public static void Prefix(NewFromTexture __instance)
{
- __instance.SourceTexture = Main.LoadImage("iVBORw0KGgoAAAANSUhEUgAAAB4AAAAQCAMAAAA25D/gAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAMUExURQD/ACQA/+nKIQAAAOiZT8gAAAAEdFJOU////wBAKqn0AAAACXBIWXMAAA6/AAAOvwE4BVMkAAAASUlEQVQoU52MyQ0AIAgEBfrv2StcYTXReSAyLE2u/Og2p7uAjTComihrZ32ITse9U5KuvKSh3kTFrMXSNTkxPV6wAUPgOOaqRToQCQU9rUN4jgAAAABJRU5ErkJggg==");
+ __instance.SourceTexture = Main.LoadImage("iVBORw0KGgoAAAANSUhEUgAAAB4AAAAQCAMAAAA25D/gAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAMUExURQD/ACQA/+nKIQAAAOiZT8gAAAAEdFJOU////wBAKqn0AAAACXBIWXMAAA6/AAAOvwE4BVMkAAAAS0lEQVQoU52MUQ4AIAhCU+9/5yzLbFJb8YGOJxa56geXlpqBixBkTLRjtRH0QXR6vrapDWe9tCE2RcQ8zdu52eRYJ7iAJfAc64pFKggsBTc0VJH0AAAAAElFTkSuQmCC");
}
}
diff --git a/MMOKitchen/Patches/LayoutBuilder_Patch.cs b/MMOKitchen/Patches/LayoutBuilder_Patch.cs
index 32777e2..35ced92 100644
--- a/MMOKitchen/Patches/LayoutBuilder_Patch.cs
+++ b/MMOKitchen/Patches/LayoutBuilder_Patch.cs
@@ -1,20 +1,27 @@
using HarmonyLib;
using Kitchen;
+using KitchenLib.Utils;
+using Unity.Entities;
using UnityEngine;
namespace MMOKitchen
{
- [HarmonyPatch(typeof(LayoutBuilder), "BuildWallBetween")]
+
+ [HarmonyPatch(typeof(LayoutBuilder), "BuildWallBetween")]
public class LayoutBuilder_Patch
{
public static bool Prefix(LayoutBuilder __instance, Vector2 tile1, Vector2 tile2)
- {
- if ((tile1 == new Vector2(-11, -5) && tile2 == new Vector2(-10, -5))
- || (tile1 == new Vector2(-11, -6) && tile2 == new Vector2(-10, -6))
- || (tile1 == new Vector2(-11, -7) && tile2 == new Vector2(-10, -7))
- || (tile1 == new Vector2(-11, -8) && tile2 == new Vector2(-10, -8)))
- return false;
+ {
+ if (__instance.Blueprint.ID == 4771956)
+ {
+ if ((tile1 == new Vector2(-11, -5) && tile2 == new Vector2(-10, -5))
+ || (tile1 == new Vector2(-11, -6) && tile2 == new Vector2(-10, -6))
+ || (tile1 == new Vector2(-11, -7) && tile2 == new Vector2(-10, -7))
+ || (tile1 == new Vector2(-11, -8) && tile2 == new Vector2(-10, -8)))
+ return false;
+ }
+
return true;
}
}