Decompiled source of Workbench Love v1.0.1

plugins/WorkbenchLove.dll

Decompiled 3 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using Jotunn;
using Jotunn.Entities;
using Jotunn.Managers;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FireSteelSwordMod")]
[assembly: AssemblyDescription("A mod that increases the workbench protect radius.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("proflupin")]
[assembly: AssemblyProduct("WorkbenchLove")]
[assembly: AssemblyCopyright("Copyright © proflupin 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7e61f470-fb41-4c6b-a654-4e199ea7d009")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
namespace WorkbenchRadiusMod;

[BepInPlugin("com.proflupin.workbenchlove", "WorkbenchLove", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class WorkbenchRadiusMod : BaseUnityPlugin
{
	private const string PluginGUID = "com.proflupin.workbenchlove";

	private const string PluginName = "WorkbenchLove";

	private const string PluginVersion = "1.0.0";

	private ConfigEntry<float> workbenchRadius;

	private void Awake()
	{
		workbenchRadius = ((BaseUnityPlugin)this).Config.Bind<float>("General", "WorkbenchRadius", 40f, "The radius of the workbench's protection area (default: 20).");
		PieceManager.OnPiecesRegistered += ModifyWorkbenchRadius;
	}

	private void ModifyWorkbenchRadius()
	{
		CustomPiece piece = PieceManager.Instance.GetPiece("piece_workbench");
		if (piece != null)
		{
			PrivateArea component = piece.PiecePrefab.GetComponent<PrivateArea>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_radius = workbenchRadius.Value;
				Logger.LogInfo((object)$"Workbench protection radius set to {component.m_radius}");
			}
			else
			{
				Logger.LogError((object)"Failed to find PrivateArea component on workbench prefab");
			}
		}
		else
		{
			Logger.LogError((object)"Failed to find workbench prefab");
		}
	}
}