From 2cf179704dd5809ecd55e7f923c883800768120f Mon Sep 17 00:00:00 2001 From: Lachlan Leone Date: Tue, 1 Nov 2022 06:18:35 +1100 Subject: [PATCH] v0.1.0 --- .gitignore | 4 + MMOKitchen.sln | 22 +++++ MMOKitchen/MMOKitchen.csproj | 82 +++++++++++++++++++ MMOKitchen/Mod.cs | 11 +++ MMOKitchen/Patches/CreateBedrooms_Patch.cs | 66 +++++++++++++++ MMOKitchen/Patches/CreateGarage_Patch.cs | 59 +++++++++++++ .../Patches/FeaturesFromTexture_Patch.cs | 18 ++++ MMOKitchen/Patches/LayoutBuilder_Patch.cs | 17 ++++ MMOKitchen/Patches/NewFromTexture_Patch.cs | 24 ++++++ MMOKitchen/Properties/AssemblyInfo.cs | 4 + 10 files changed, 307 insertions(+) create mode 100644 .gitignore create mode 100644 MMOKitchen.sln create mode 100644 MMOKitchen/MMOKitchen.csproj create mode 100644 MMOKitchen/Mod.cs create mode 100644 MMOKitchen/Patches/CreateBedrooms_Patch.cs create mode 100644 MMOKitchen/Patches/CreateGarage_Patch.cs create mode 100644 MMOKitchen/Patches/FeaturesFromTexture_Patch.cs create mode 100644 MMOKitchen/Patches/LayoutBuilder_Patch.cs create mode 100644 MMOKitchen/Patches/NewFromTexture_Patch.cs create mode 100644 MMOKitchen/Properties/AssemblyInfo.cs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..22e48f4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +bin/ +obj/ +.vs/ +.DS_Store diff --git a/MMOKitchen.sln b/MMOKitchen.sln new file mode 100644 index 0000000..f405929 --- /dev/null +++ b/MMOKitchen.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30114.105 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MMOKitchen", "MMOKitchen\MMOKitchen.csproj", "{03768998-4709-4988-B37F-ECC5D44DF280}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {03768998-4709-4988-B37F-ECC5D44DF280}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {03768998-4709-4988-B37F-ECC5D44DF280}.Debug|Any CPU.Build.0 = Debug|Any CPU + {03768998-4709-4988-B37F-ECC5D44DF280}.Release|Any CPU.ActiveCfg = Release|Any CPU + {03768998-4709-4988-B37F-ECC5D44DF280}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/MMOKitchen/MMOKitchen.csproj b/MMOKitchen/MMOKitchen.csproj new file mode 100644 index 0000000..958c48c --- /dev/null +++ b/MMOKitchen/MMOKitchen.csproj @@ -0,0 +1,82 @@ + + + + net4.7.1 + + + + F:\SteamLibrary\steamapps\common\PlateUp\PlateUp + + + + /Users/lachlanleone/Desktop/PlateUp + + + + + $(PlateUpGameFolder)\MelonLoader\0Harmony.dll + + + $(PlateUpGameFolder)\PlateUp_Data\Managed\Kitchen.RestaurantMode.dll + + + $(PlateUpGameFolder)\PlateUp_Data\Managed\KitchenMode.dll + + + $(PlateUpGameFolder)\MelonLoader\MelonLoader.dll + + + $(PlateUpGameFolder)\PlateUp_Data\Managed\Kitchen.Common.dll + + + $(PlateUpGameFolder)\PlateUp_Data\Managed\Kitchen.Networking.dll + + + $(PlateUpGameFolder)\PlateUp_Data\Managed\Kitchen.GameData.dll + + + $(PlateUpGameFolder)\PlateUp_Data\Managed\Sirenix.Serialization.dll + + + $(PlateUpGameFolder)\PlateUp_Data\Managed\Kitchen.FranchiseMode.dll + + + $(PlateUpGameFolder)\PlateUp_Data\Managed\Kitchen.Layouts.dll + + + $(PlateUpGameFolder)\PlateUp_Data\Managed\Unity.Entities.dll + + + $(PlateUpGameFolder)\PlateUp_Data\Managed\UnityEngine.dll + + + $(PlateUpGameFolder)\PlateUp_Data\Managed\UnityEngine.PhysicsModule.dll + + + $(PlateUpGameFolder)\PlateUp_Data\Managed\UnityEngine.AssetBundleModule.dll + + + $(PlateUpGameFolder)\PlateUp_Data\Managed\UnityEngine.CoreModule.dll + + + $(PlateUpGameFolder)\PlateUp_Data\Managed\UnityEngine.InputLegacyModule.dll + + + $(PlateUpGameFolder)\PlateUp_Data\Managed\UnityEngine.ImageConversionModule.dll + + + $(PlateUpGameFolder)\PlateUp_Data\Managed\UnityEngine.InputModule.dll + + + $(PlateUpGameFolder)\PlateUp_Data\Managed\UnityEngine.AudioModule.dll + + + $(PlateUpGameFolder)\Mods\KitchenLib.dll + + + + + + + + diff --git a/MMOKitchen/Mod.cs b/MMOKitchen/Mod.cs new file mode 100644 index 0000000..63c5913 --- /dev/null +++ b/MMOKitchen/Mod.cs @@ -0,0 +1,11 @@ +using KitchenLib; +using UnityEngine; +using System.IO; + +namespace MMOKitchen +{ + public class Mod : BaseMod + { + public Mod() : base("politecustomers", "1.1.0") {} + } +} \ No newline at end of file diff --git a/MMOKitchen/Patches/CreateBedrooms_Patch.cs b/MMOKitchen/Patches/CreateBedrooms_Patch.cs new file mode 100644 index 0000000..9409608 --- /dev/null +++ b/MMOKitchen/Patches/CreateBedrooms_Patch.cs @@ -0,0 +1,66 @@ +using HarmonyLib; +using Kitchen; +using Unity.Entities; +using System.Reflection; +using KitchenLib.Utils; +using UnityEngine; +using KitchenData; +using Unity.Collections; + +namespace MMOKitchen +{ + [HarmonyPatch(typeof(CreateBedrooms), "OnUpdate")] + public class CreateBedrooms_Patch + { + public static bool Prefix(CreateBedrooms __instance) + { + MethodInfo createAssigned = ReflectionUtils.GetMethod("CreateAssigned"); + MethodInfo placeSpawnMarker = ReflectionUtils.GetMethod("PlaceSpawnMarker"); + MethodInfo getComponent = ReflectionUtils.GetMethod("GetComponent").MakeGenericMethod(typeof(CPlayer)); + FieldInfo players = ReflectionUtils.GetField("Players"); + NativeArray nativeArray = ((EntityQuery)players.GetValue(__instance)).ToEntityArray(Allocator.Temp); + Vector3[] array = new Vector3[] + { + new Vector3(9f, 0f, 5f), + new Vector3(9f, 0f, 2f), + new Vector3(9f, 0f, -3f), + new Vector3(9f, 0f, -6f), + new Vector3(14f, 0f, 5f), + new Vector3(14f, 0f, 2f), + new Vector3(14f, 0f, -3f), + new Vector3(14f, 0f, -6f), + new Vector3(-12f, 0f, 5f), + new Vector3(-12f, 0f, 2f), + new Vector3(-12f, 0f, -3f), + new Vector3(-12f, 0f, -6f) + }; + for (int i = 0; i < 12; i++) + { + Entity target = (Entity)createAssigned.Invoke(__instance, new object[] { i, GameData.Main.Get(AssetReference.Bed), array[i] + new Vector3(0f, 0f, 0f), Vector3.forward }); + Entity entity = (Entity)createAssigned.Invoke(__instance, new object[] { i, GameData.Main.Get(AssetReference.InteractionProxy), array[i] + new Vector3(0f, 0f, 0f), Vector3.forward }); + EntityUtils.GetEntityManager().AddComponentData(entity, new CInteractionProxy + { + Target = target, + IsActive = true + }); + createAssigned.Invoke(__instance, new object[] { i, GameData.Main.Get(AssetReference.OutfitStation), array[i] + new Vector3(-2f, 0f, 1f), Vector3.forward }); + createAssigned.Invoke(__instance, new object[] { i, GameData.Main.Get(AssetReference.CosmeticStation), array[i] + new Vector3(-2f, 0f, -1f), Vector3.forward }); + createAssigned.Invoke(__instance, new object[] { i, GameData.Main.Get(AssetReference.ColourStation), array[i] + new Vector3(-3f, 0f, 1f), Vector3.forward }); + createAssigned.Invoke(__instance, new object[] { i, GameData.Main.Get(AssetReference.OccupationIndicator), array[i] + new Vector3(1f, 0f, 0f), Vector3.forward }); + placeSpawnMarker.Invoke(__instance, new object[] { i, array[i] + new Vector3(-1f, 0f, 0f) }); + foreach (Entity entity2 in nativeArray) + { + //bool flag = i == base.GetComponent(entity2).Index; + bool flag = i == ((CPlayer)getComponent.Invoke(__instance, new object[] { entity2 })).Index; + if (flag) + { + EntityUtils.GetEntityManager().SetComponentData(entity2, new CPosition(array[i] + new Vector3(-1f, 0f, 0f))); + break; + } + } + } + nativeArray.Dispose(); + return false; + } + } +} \ No newline at end of file diff --git a/MMOKitchen/Patches/CreateGarage_Patch.cs b/MMOKitchen/Patches/CreateGarage_Patch.cs new file mode 100644 index 0000000..93c0bfb --- /dev/null +++ b/MMOKitchen/Patches/CreateGarage_Patch.cs @@ -0,0 +1,59 @@ +using HarmonyLib; +using Kitchen; +using Unity.Entities; +using System.Reflection; +using KitchenLib.Utils; +using UnityEngine; +using System; +using KitchenData; + +namespace MMOKitchen +{ + [HarmonyPatch(typeof(CreateGarage), "OnUpdate")] + public class CreateGarage_Patch + { + public static bool Prefix(CreateGarage __instance) + { + MethodInfo create = AccessTools.Method(typeof(CreateGarage), "Create", new Type[] {typeof(Appliance), typeof(Vector3), typeof(Vector3)}); + FieldInfo crates = ReflectionUtils.GetField("Crates"); + + GameObject garageDecorations = GameObjectUtils.GetChildObject(GameData.Main.Get(AssetReference.GarageDecorations).Prefab, "LoadoutDoor"); + GameObject doorLight = GameObjectUtils.GetChildObject(GameData.Main.Get(AssetReference.GarageDecorations).Prefab, "Door Light"); + doorLight.SetActive(false); + garageDecorations.SetActive(false); + create.Invoke(__instance, new object[]{GameData.Main.Get(AssetReference.GarageDecorations), new Vector3(-8f, 0f, -2f), Vector3.forward}); + + Mod.Log(GameData.Main.Get(AssetReference.GarageDecorations).Prefab.name); + Entity entity = default(Entity); + entity = (Entity)create.Invoke(__instance, new object[]{GameData.Main.Get(AssetReference.LoadoutPedestal), new Vector3(-8.5f, 0f, -4f), Vector3.right}); + EntityUtils.GetEntityManager().AddComponent(entity); + entity = (Entity)create.Invoke(__instance, new object[]{GameData.Main.Get(AssetReference.LoadoutPedestal), new Vector3(-9.5f, 0f, -4f), Vector3.right}); + bool isEmpty = ((EntityQuery)crates.GetValue(__instance)).IsEmpty; + if (!isEmpty) + { + for (int i = 0; i < 6; i++) + { + bool flag = i == 2; + if (!flag) + { + for (int j = 0; j < 5; j++) + { + Vector3 facing = (j % 2 == 1) ? Vector3.forward : Vector3.back; + Entity entity2 = (Entity)create.Invoke(__instance, new object[]{GameData.Main.Get(AssetReference.GarageShelf), new Vector3((float)(-5 - i), 0f, (float)(1 - j)), facing}); + EntityUtils.GetEntityManager().AddComponentData(entity2, new CPersistentItemStorageLocation + { + Type = PersistentStorageType.Crate + }); + bool flag2 = j % 2 == 1; + if (flag2) + { + create.Invoke(__instance, new object[]{GameData.Main.Get(AssetReference.GarageDivider), new Vector3((float)(-5 - i), 0f, (float)(1 - j)), Vector3.forward}); + } + } + } + } + } + return false; + } + } +} \ No newline at end of file diff --git a/MMOKitchen/Patches/FeaturesFromTexture_Patch.cs b/MMOKitchen/Patches/FeaturesFromTexture_Patch.cs new file mode 100644 index 0000000..49992c3 --- /dev/null +++ b/MMOKitchen/Patches/FeaturesFromTexture_Patch.cs @@ -0,0 +1,18 @@ +using HarmonyLib; +using KitchenLib.Utils; +using UnityEngine; +using Kitchen.Layouts.Modules; +using System.IO; + +namespace MMOKitchen +{ + + [HarmonyPatch(typeof(FeaturesFromTexture), "ActOn")] + public class FeaturesFromTexture_Patch + { + public static void Prefix(NewFromTexture __instance) + { + __instance.SourceTexture = ResourceUtils.LoadTextureFromFile(Path.Combine(Application.streamingAssetsPath, "FeaturesFromTexture.png")); + } + } +} \ No newline at end of file diff --git a/MMOKitchen/Patches/LayoutBuilder_Patch.cs b/MMOKitchen/Patches/LayoutBuilder_Patch.cs new file mode 100644 index 0000000..27124fe --- /dev/null +++ b/MMOKitchen/Patches/LayoutBuilder_Patch.cs @@ -0,0 +1,17 @@ +using HarmonyLib; +using Kitchen; +using UnityEngine; + +namespace MMOKitchen +{ + [HarmonyPatch(typeof(LayoutBuilder), "BuildWallBetween")] + public class LayoutBuilder_Patch + { + public static bool Prefix(LayoutBuilder __instance, Vector2 tile1, Vector2 tile2) + { + if (tile1 == new Vector2(-11, -5) || tile1 == new Vector2(-11, -6)) + return false; + return true; + } + } +} \ No newline at end of file diff --git a/MMOKitchen/Patches/NewFromTexture_Patch.cs b/MMOKitchen/Patches/NewFromTexture_Patch.cs new file mode 100644 index 0000000..ce4067a --- /dev/null +++ b/MMOKitchen/Patches/NewFromTexture_Patch.cs @@ -0,0 +1,24 @@ +using HarmonyLib; +using UnityEngine; +using Kitchen.Layouts.Modules; +using Kitchen; +using System.Reflection; +using Unity.Entities; +using KitchenLib.Utils; +using System.IO; +namespace MMOKitchen +{ + [HarmonyPatch(typeof(NewFromTexture), "ActOn")] + public class NewFromTexture_Patch + { + public static void Prefix(NewFromTexture __instance) + { + PlayerManager playerManager = World.DefaultGameObjectInjectionWorld.GetExistingSystem(); + FieldInfo finfo = typeof(PlayerManager).GetField("MaxPlayers", BindingFlags.Instance | BindingFlags.Public); + if (finfo == null) Mod.Log("finfo is null"); + finfo.SetValue(playerManager, 12); + + __instance.SourceTexture = ResourceUtils.LoadTextureFromFile(Path.Combine(Application.streamingAssetsPath, "NewFromTexture.png")); + } + } +} \ No newline at end of file diff --git a/MMOKitchen/Properties/AssemblyInfo.cs b/MMOKitchen/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..66aa71a --- /dev/null +++ b/MMOKitchen/Properties/AssemblyInfo.cs @@ -0,0 +1,4 @@ +using MelonLoader; + +[assembly: MelonInfo(typeof(MMOKitchen.Mod), "MMO Kitchen", "0.1.0", "StarFluxGames")] +[assembly: MelonGame("It's Happening", "PlateUp")] \ No newline at end of file