1
0

1 Commits
1.0.0 ... 1.0.1

Author SHA1 Message Date
8830516607 updated to newest game version 2026-04-04 00:06:22 +02:00
4 changed files with 165 additions and 129 deletions

7
.gitignore vendored
View File

@@ -1,5 +1,4 @@
.git/ .git/
bin/ bin/
lib/ obj/
obj/
*.sln *.sln

16
CHANGELOG Normal file
View File

@@ -0,0 +1,16 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.0.1] - 2026-04-04
### Fixed
- fixed to work with the latest game version
## [1.0.0] - 2026-01-10
### Added
- Initial release

176
Plugin.cs
View File

@@ -1,79 +1,97 @@
using BepInEx; using BepInEx;
using BepInEx.Configuration; using BepInEx.Configuration;
using BepInEx.Logging; using BepInEx.Logging;
using BepInEx.Unity.IL2CPP; using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.UnityEngine; using HarmonyLib;
using HarmonyLib; using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.Injection; using UnityEngine;
using UnityEngine;
using KeyCode = BepInEx.Unity.IL2CPP.UnityEngine.KeyCode; namespace UnrestrictedPlacement;
namespace UnrestrictedPlacement; [BepInPlugin(PLUGIN_GUID, PLUGIN_NAME, PLUGIN_VERSION)]
public class Plugin : BasePlugin
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)] {
public class Plugin : BasePlugin public const string PLUGIN_GUID = "de.mpburgmann.UnrestrictedPlacement";
{ public const string PLUGIN_NAME = "Unrestricted Placement";
internal static new ManualLogSource Log; public const string PLUGIN_VERSION = "1.0.1";
public static ConfigEntry<bool> Enabled {get; set;} internal static new ManualLogSource Log;
private static bool Once = false; public static ConfigEntry<bool> Enabled;
public static ConfigEntry<KeyCode> SwitchKey {get; set;} public static ConfigEntry<KeyCode> SwitchKey;
public override void Load() public override void Load()
{ {
Log = base.Log; Log = base.Log;
Log.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!"); Log.LogInfo($"Plugin {PLUGIN_GUID} is loaded!");
Harmony harmony = new(MyPluginInfo.PLUGIN_GUID);
harmony.PatchAll(); ClassInjector.RegisterTypeInIl2Cpp<Behaviour>();
GameObject gameObject = new("UnrestrictedPlacementBehaviour");
ClassInjector.RegisterTypeInIl2Cpp<Plugin.Behaviour>(); Object.DontDestroyOnLoad(gameObject);
GameObject gameObject = new("UnrestrictedPlacementBehaviour"); gameObject.AddComponent<Behaviour>();
Object.DontDestroyOnLoad(gameObject);
gameObject.AddComponent<Plugin.Behaviour>(); Enabled = Config.Bind("Settings", "Enabled", true);
SwitchKey = Config.Bind("Settings", "SwitchKey", KeyCode.F8, "The key with which to enable and disable the mod.");
Enabled = Config.Bind("Settings", "Enabled", true);
SwitchKey = Config.Bind("Settings", "SwitchKey", KeyCode.F8, "The key with which to enable and disable the mod."); Harmony harmony = new(PLUGIN_GUID);
} harmony.PatchAll();
}
public static class UnrestrictedPlacementPatch
{ public static class UnrestrictedPlacementPatch
[HarmonyPatch(typeof(FurniturePlacer), "PlacingRaycast")] {
public static class FurniturePlacer_PlacingRaycast_Patch [HarmonyPatch(typeof(FurniturePlacer), "PlaceFurniture")]
{ public static class FurniturePlacer_PlaceFurniture_Patch
[HarmonyPostfix] {
public static void Postfix(FurniturePlacer __instance) [HarmonyPrefix]
{ public static void Prefix(FurniturePlacer __instance)
if (!Plugin.Enabled.Value) return; {
__instance.m_CurrentPlacingMode.PlacedOnCorrectSurface = true; if (!Enabled.Value) return;
} __instance.m_CurrentPlacingMode.PlacedOnCorrectSurface = true;
} }
}
[HarmonyPatch(typeof(IPlacingMode), "UpdateHologramColor")]
public static class IPlacingMode_UpdateHologramColor_Patch [HarmonyPatch(typeof(FurniturePlacer), "PlacingRaycast")]
{ public static class FurniturePlacer_PlacingRaycast_Patch
[HarmonyPostfix] {
public static void Postfix(IPlacingMode __instance) [HarmonyPostfix]
{ public static void Postfix(FurniturePlacer __instance)
if (!Plugin.Enabled.Value) return; {
__instance.HologramColor = Color.green; if (!Enabled.Value) return;
__instance.m_Triggers.Clear(); __instance.m_CurrentPlacingMode.PlacedOnCorrectSurface = true;
} }
} }
}
[HarmonyPatch(typeof(IPlacingMode), "OverlapBoxes")]
public class Behaviour : MonoBehaviour public static class IPlacingMode_OverlapsBoxes_Patch
{ {
internal void Update() [HarmonyPrefix]
{ public static bool Prefix(IPlacingMode __instance)
if(Input.GetKeyInt(Plugin.SwitchKey.Value) && !Once) {
{ if (!Enabled.Value) return true;
Enabled.Value = !Enabled.Value; __instance.m_Triggers.Clear();
Log.LogError($"Plugin {MyPluginInfo.PLUGIN_GUID} is enabled: {Enabled}"); return false;
Once = true; }
} }
else if(!Input.GetKeyInt(Plugin.SwitchKey.Value) && Once)
{ [HarmonyPatch(typeof(IPlacingMode), "UpdateHologramColor")]
Once = false; public static class IPlacingMode_UpdateHologramColor_Patch
} {
} [HarmonyPostfix]
} public static void Postfix(IPlacingMode __instance)
} {
if (!Enabled.Value) return;
__instance.HologramColor = Color.green;
}
}
}
public class Behaviour : MonoBehaviour
{
internal void Update()
{
if(Input.GetKeyDown(SwitchKey.Value))
{
Enabled.Value = !Enabled.Value;
Log.LogError($"Plugin {PLUGIN_GUID} is enabled: {Enabled.Value}");
}
}
}
}

View File

@@ -1,46 +1,49 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<AssemblyName>UnrestrictedPlacement</AssemblyName> <AssemblyName>UnrestrictedPlacement</AssemblyName>
<Product>Unrestricted Placement</Product> <Product>Unrestricted Placement</Product>
<Version>1.0.0</Version> <Version>1.0.1</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<RestoreAdditionalProjectSources> <RestoreAdditionalProjectSources>
https://api.nuget.org/v3/index.json; https://api.nuget.org/v3/index.json;
https://nuget.bepinex.dev/v3/index.json; https://nuget.bepinex.dev/v3/index.json;
https://nuget.samboy.dev/v3/index.json https://nuget.samboy.dev/v3/index.json
</RestoreAdditionalProjectSources> </RestoreAdditionalProjectSources>
<RootNamespace>UnrestrictedPlacement</RootNamespace> <RootNamespace>UnrestrictedPlacement</RootNamespace>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.*" IncludeAssets="compile" /> <PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.*" IncludeAssets="compile" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="2.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="2.*" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Assembly-CSharp" Publicize="true"> <Reference Include="Assembly-CSharp" Publicize="true">
<HintPath>..\lib\Assembly-CSharp.dll</HintPath> <HintPath>..\lib\Assembly-CSharp.dll</HintPath>
</Reference> </Reference>
<Reference Include="MyBox" Publicize="true"> <Reference Include="MyBox" Publicize="true">
<HintPath>..\lib\MyBox.dll</HintPath> <HintPath>..\lib\MyBox.dll</HintPath>
</Reference> </Reference>
<Reference Include="Il2Cppmscorlib" Publicize="true"> <Reference Include="Il2Cppmscorlib" Publicize="true">
<HintPath>..\lib\Il2Cppmscorlib.dll</HintPath> <HintPath>..\lib\Il2Cppmscorlib.dll</HintPath>
</Reference> </Reference>
<Reference Include="UnityEngine.PhysicsModule" Publicize="true"> <Reference Include="UnityEngine.PhysicsModule" Publicize="true">
<HintPath>..\lib\UnityEngine.PhysicsModule.dll</HintPath> <HintPath>..\lib\UnityEngine.PhysicsModule.dll</HintPath>
</Reference> </Reference>
<Reference Include="UnityEngine.CoreModule" Publicize="true"> <Reference Include="UnityEngine.CoreModule" Publicize="true">
<HintPath>..\lib\UnityEngine.CoreModule.dll</HintPath> <HintPath>..\lib\UnityEngine.CoreModule.dll</HintPath>
</Reference> </Reference>
<Reference Include="Unity.InputSystem" Publicize="true"> <Reference Include="Unity.InputSystem" Publicize="true">
<HintPath>..\lib\Unity.InputSystem.dll</HintPath> <HintPath>..\lib\Unity.InputSystem.dll</HintPath>
</Reference> </Reference>
<Reference Include="UnityEngine.AIModule" Publicize="true"> <Reference Include="UnityEngine.AIModule" Publicize="true">
<HintPath>..\lib\UnityEngine.AIModule.dll</HintPath> <HintPath>..\lib\UnityEngine.AIModule.dll</HintPath>
</Reference> </Reference>
</ItemGroup> <Reference Include="UnityEngine.InputLegacyModule" Publicize="true">
</Project> <HintPath>..\lib\UnityEngine.InputLegacyModule.dll</HintPath>
</Reference>
</ItemGroup>
</Project>