Decompiled source of PowerfulRugrat v1.0.0

plugins/yazirushi-PowerfulRugrat/PowerfulRugrat.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("PowerfulRugrat")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PowerfulRugrat")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("718cc956-56bc-4a09-8bb6-c5ecec00d050")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PowerfulRugrat;

[BepInPlugin("yazirushi.PowerfulRugrat", "PowerfulRugrat", "1.0.0")]
public class PowerfulRugrat : BaseUnityPlugin
{
	private readonly Harmony harmony = new Harmony("yazirushi.PowerfulRugrat");

	internal static ManualLogSource mls;

	public static ConfigEntry<int> Rugrat_Strength;

	public static ConfigEntry<bool> EnableLogging;

	private void Awake()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		Rugrat_Strength = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Rugrat Strength", 6, new ConfigDescription("A size that can be carried by Rugrat", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 6), Array.Empty<object>()));
		EnableLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("ConsoleLog", "EnableLogging", false, "ログの有効化");
		mls = ((BaseUnityPlugin)this).Logger;
		mls.LogInfo((object)"PowerfulRugratが起動しました!");
		mls.LogWarning((object)"Settings cannot be changed during gameplay!");
		mls.LogInfo((object)$"PowerfulRugrat:Config:Rugrat_Strength = {Rugrat_Strength.Value}");
		mls.LogInfo((object)$"PowerfulRugrat:Config:EnableLogging = {EnableLogging.Value}");
		harmony.PatchAll();
	}
}
[HarmonyPatch(typeof(EnemyValuableThrower), "StateGetValuable")]
public class RugratStrengthPatch
{
	[CompilerGenerated]
	private sealed class <Transpiler>d__0 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private CodeInstruction <>2__current;

		private int <>l__initialThreadId;

		private IEnumerable<CodeInstruction> instructions;

		public IEnumerable<CodeInstruction> <>3__instructions;

		private IEnumerator<CodeInstruction> <>s__1;

		private CodeInstruction <code>5__2;

		CodeInstruction IEnumerator<CodeInstruction>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <Transpiler>d__0(int <>1__state)
		{
			this.<>1__state = <>1__state;
			<>l__initialThreadId = Environment.CurrentManagedThreadId;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			int num = <>1__state;
			if (num == -3 || num == 1)
			{
				try
				{
				}
				finally
				{
					<>m__Finally1();
				}
			}
			<>s__1 = null;
			<code>5__2 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			try
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>s__1 = instructions.GetEnumerator();
					<>1__state = -3;
					break;
				case 1:
					<>1__state = -3;
					<code>5__2 = null;
					break;
				}
				if (<>s__1.MoveNext())
				{
					<code>5__2 = <>s__1.Current;
					if (<code>5__2.opcode == OpCodes.Ldc_I4 && Convert.ToInt32(<code>5__2.operand) == 3)
					{
						<code>5__2.operand = PowerfulRugrat.Rugrat_Strength.Value;
						if (PowerfulRugrat.EnableLogging.Value)
						{
							PowerfulRugrat.mls.LogInfo((object)$"PowerfulRugrat:Ldc_I4 3 -> {PowerfulRugrat.Rugrat_Strength.Value}");
						}
					}
					else if (<code>5__2.opcode == OpCodes.Ldc_I4_3)
					{
						<code>5__2.opcode = OpCodes.Ldc_I4;
						<code>5__2.operand = PowerfulRugrat.Rugrat_Strength.Value;
						if (PowerfulRugrat.EnableLogging.Value)
						{
							PowerfulRugrat.mls.LogInfo((object)$"PowerfulRugrat:Ldc_I4_3 -> Ldc_I4 {PowerfulRugrat.Rugrat_Strength.Value}");
						}
					}
					<>2__current = <code>5__2;
					<>1__state = 1;
					return true;
				}
				<>m__Finally1();
				<>s__1 = null;
				return false;
			}
			catch
			{
				//try-fault
				((IDisposable)this).Dispose();
				throw;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		private void <>m__Finally1()
		{
			<>1__state = -1;
			if (<>s__1 != null)
			{
				<>s__1.Dispose();
			}
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}

		[DebuggerHidden]
		IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
		{
			<Transpiler>d__0 <Transpiler>d__;
			if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
			{
				<>1__state = 0;
				<Transpiler>d__ = this;
			}
			else
			{
				<Transpiler>d__ = new <Transpiler>d__0(0);
			}
			<Transpiler>d__.instructions = <>3__instructions;
			return <Transpiler>d__;
		}

		[DebuggerHidden]
		IEnumerator IEnumerable.GetEnumerator()
		{
			return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
		}
	}

	[IteratorStateMachine(typeof(<Transpiler>d__0))]
	private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <Transpiler>d__0(-2)
		{
			<>3__instructions = instructions
		};
	}
}