Decompiled source of RecycleDoors v1.0.0

REPO_RecycleDoors.dll

Decompiled a day ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("REPO_RecycleDoors")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("REPO_RecycleDoors")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8E0E4CE0-2E09-4D1D-8B5A-6C9D6E7BAA11")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace REPO_RecycleDoors;

[BepInPlugin("com.xiaohai.RecycleDoors", "RecycleDoors", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public static class Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(PhysGrabHinge), "HingeBreakRPC")]
		public static void OnDoorBroken(PhysGrabHinge __instance)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			GameObject gameObject = ((Component)__instance).gameObject;
			if (!((Object)(object)gameObject == (Object)null))
			{
				ValuableObject component = gameObject.GetComponent<ValuableObject>();
				NotValuableObject component2 = gameObject.GetComponent<NotValuableObject>();
				if (!((Object)(object)component != (Object)null) && !((Object)(object)component2 == (Object)null))
				{
					PhysAudio audioPreset = component2.audioPreset;
					float audioPresetPitch = component2.audioPresetPitch;
					Gradient particleColors = component2.particleColors;
					Durability durabilityPreset = component2.durabilityPreset;
					PhysAttribute physAttributePreset = component2.physAttributePreset;
					Object.Destroy((Object)(object)component2);
					ValuableObject obj = gameObject.AddComponent<ValuableObject>();
					obj.valuePreset = Instance.CreateValuePreset();
					obj.durabilityPreset = Instance.CreateDurabilityPreset(durabilityPreset);
					obj.audioPreset = audioPreset;
					obj.audioPresetPitch = audioPresetPitch;
					obj.particleColors = particleColors;
					obj.physAttributePreset = physAttributePreset;
				}
			}
		}
	}

	private Harmony _harmony;

	private ConfigEntry<float> _valueMin;

	private ConfigEntry<float> _valueMax;

	private ConfigEntry<float> _durFragility;

	private ConfigEntry<float> _durDurability;

	private static Plugin Instance;

	private void Awake()
	{
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Expected O, but got Unknown
		Instance = this;
		_valueMin = ((BaseUnityPlugin)this).Config.Bind<float>("RecycleDoors", "ValueMin", 50f, "");
		_valueMax = ((BaseUnityPlugin)this).Config.Bind<float>("RecycleDoors", "ValueMax", 500f, "");
		_durFragility = ((BaseUnityPlugin)this).Config.Bind<float>("RecycleDoors", "DurabilityFragility", 50f, "");
		_durDurability = ((BaseUnityPlugin)this).Config.Bind<float>("RecycleDoors", "DurabilityDurability", 100f, "");
		_harmony = new Harmony("con.xiaohai.RecycleDoors");
		_harmony.PatchAll(typeof(Patches));
	}

	internal Value CreateValuePreset()
	{
		Value obj = ScriptableObject.CreateInstance<Value>();
		obj.valueMin = Mathf.Min(_valueMin.Value, _valueMax.Value);
		obj.valueMax = Mathf.Max(_valueMin.Value, _valueMax.Value);
		return obj;
	}

	internal Durability CreateDurabilityPreset(Durability inherit)
	{
		Durability obj = ScriptableObject.CreateInstance<Durability>();
		obj.fragility = Mathf.Clamp(_durFragility.Value, 0f, 100f);
		obj.durability = Mathf.Clamp(_durDurability.Value, 0f, 100f);
		return obj;
	}
}