Initial Commit
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
.git/
|
||||||
|
bin/
|
||||||
|
lib/
|
||||||
|
obj/
|
||||||
|
*.sln
|
||||||
79
Plugin.cs
Normal file
79
Plugin.cs
Normal file
@@ -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<bool> Enabled {get; set;}
|
||||||
|
private static bool Once = false;
|
||||||
|
public static ConfigEntry<KeyCode> 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<Plugin.Behaviour>();
|
||||||
|
GameObject gameObject = new("UnrestrictedPlacementBehaviour");
|
||||||
|
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.");
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
46
UnrestrictedPlacement.csproj
Normal file
46
UnrestrictedPlacement.csproj
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<AssemblyName>UnrestrictedPlacement</AssemblyName>
|
||||||
|
<Product>Unrestricted Placement</Product>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
<RestoreAdditionalProjectSources>
|
||||||
|
https://api.nuget.org/v3/index.json;
|
||||||
|
https://nuget.bepinex.dev/v3/index.json;
|
||||||
|
https://nuget.samboy.dev/v3/index.json
|
||||||
|
</RestoreAdditionalProjectSources>
|
||||||
|
<RootNamespace>UnrestrictedPlacement</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.*" IncludeAssets="compile" />
|
||||||
|
<PackageReference Include="BepInEx.PluginInfoProps" Version="2.*" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Assembly-CSharp" Publicize="true">
|
||||||
|
<HintPath>..\lib\Assembly-CSharp.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="MyBox" Publicize="true">
|
||||||
|
<HintPath>..\lib\MyBox.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Il2Cppmscorlib" Publicize="true">
|
||||||
|
<HintPath>..\lib\Il2Cppmscorlib.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.PhysicsModule" Publicize="true">
|
||||||
|
<HintPath>..\lib\UnityEngine.PhysicsModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.CoreModule" Publicize="true">
|
||||||
|
<HintPath>..\lib\UnityEngine.CoreModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.InputSystem" Publicize="true">
|
||||||
|
<HintPath>..\lib\Unity.InputSystem.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.AIModule" Publicize="true">
|
||||||
|
<HintPath>..\lib\UnityEngine.AIModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
Reference in New Issue
Block a user