From b0ebe0708e19f9a3308e8a3f481bf606dc860961 Mon Sep 17 00:00:00 2001 From: Marc Philipp Burgmann Date: Sat, 10 Jan 2026 16:41:21 +0100 Subject: [PATCH] Initial Commit --- .gitignore | 5 +++ Plugin.cs | 79 ++++++++++++++++++++++++++++++++++++ UnrestrictedPlacement.csproj | 46 +++++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 .gitignore create mode 100644 Plugin.cs create mode 100644 UnrestrictedPlacement.csproj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6af359e --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.git/ +bin/ +lib/ +obj/ +*.sln \ No newline at end of file diff --git a/Plugin.cs b/Plugin.cs new file mode 100644 index 0000000..7026c22 --- /dev/null +++ b/Plugin.cs @@ -0,0 +1,79 @@ +using BepInEx; +using BepInEx.Configuration; +using BepInEx.Logging; +using BepInEx.Unity.IL2CPP; +using BepInEx.Unity.IL2CPP.UnityEngine; +using HarmonyLib; +using Il2CppInterop.Runtime.Injection; +using UnityEngine; +using KeyCode = BepInEx.Unity.IL2CPP.UnityEngine.KeyCode; + +namespace UnrestrictedPlacement; + +[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)] +public class Plugin : BasePlugin +{ + internal static new ManualLogSource Log; + public static ConfigEntry Enabled {get; set;} + private static bool Once = false; + public static ConfigEntry SwitchKey {get; set;} + + public override void Load() + { + Log = base.Log; + Log.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!"); + Harmony harmony = new(MyPluginInfo.PLUGIN_GUID); + harmony.PatchAll(); + + ClassInjector.RegisterTypeInIl2Cpp(); + GameObject gameObject = new("UnrestrictedPlacementBehaviour"); + Object.DontDestroyOnLoad(gameObject); + gameObject.AddComponent(); + + Enabled = Config.Bind("Settings", "Enabled", true); + SwitchKey = Config.Bind("Settings", "SwitchKey", KeyCode.F8, "The key with which to enable and disable the mod."); + } + + public static class UnrestrictedPlacementPatch + { + [HarmonyPatch(typeof(FurniturePlacer), "PlacingRaycast")] + public static class FurniturePlacer_PlacingRaycast_Patch + { + [HarmonyPostfix] + public static void Postfix(FurniturePlacer __instance) + { + if (!Plugin.Enabled.Value) return; + __instance.m_CurrentPlacingMode.PlacedOnCorrectSurface = true; + } + } + + [HarmonyPatch(typeof(IPlacingMode), "UpdateHologramColor")] + public static class IPlacingMode_UpdateHologramColor_Patch + { + [HarmonyPostfix] + public static void Postfix(IPlacingMode __instance) + { + if (!Plugin.Enabled.Value) return; + __instance.HologramColor = Color.green; + __instance.m_Triggers.Clear(); + } + } + } + + public class Behaviour : MonoBehaviour + { + internal void Update() + { + if(Input.GetKeyInt(Plugin.SwitchKey.Value) && !Once) + { + Enabled.Value = !Enabled.Value; + Log.LogError($"Plugin {MyPluginInfo.PLUGIN_GUID} is enabled: {Enabled}"); + Once = true; + } + else if(!Input.GetKeyInt(Plugin.SwitchKey.Value) && Once) + { + Once = false; + } + } + } +} diff --git a/UnrestrictedPlacement.csproj b/UnrestrictedPlacement.csproj new file mode 100644 index 0000000..c404a29 --- /dev/null +++ b/UnrestrictedPlacement.csproj @@ -0,0 +1,46 @@ + + + + net6.0 + UnrestrictedPlacement + Unrestricted Placement + 1.0.0 + true + latest + + https://api.nuget.org/v3/index.json; + https://nuget.bepinex.dev/v3/index.json; + https://nuget.samboy.dev/v3/index.json + + UnrestrictedPlacement + + + + + + + + + + ..\lib\Assembly-CSharp.dll + + + ..\lib\MyBox.dll + + + ..\lib\Il2Cppmscorlib.dll + + + ..\lib\UnityEngine.PhysicsModule.dll + + + ..\lib\UnityEngine.CoreModule.dll + + + ..\lib\Unity.InputSystem.dll + + + ..\lib\UnityEngine.AIModule.dll + + +