Decompiled source of RandomOrbExplosion v0.9.0

plugins/yazirushi-RandomOrbExplosion/RandomOrbExplosion.dll

Decompiled a year ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
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("RandomOrbExplosion")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RandomOrbExplosion")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ee363f30-d98d-46d8-9424-b5eb427ab1a5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RandomOrbExplosion;

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

	internal static ManualLogSource mls;

	public static ConfigEntry<int> Explosion_Weight;

	public static ConfigEntry<bool> EnableLogging;

	private void Awake()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		Explosion_Weight = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Explosion Weight", 50, new ConfigDescription("爆発する確率", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
		EnableLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("ConsoleLog", "EnableLogging", false, "ログの有効化");
		mls = ((BaseUnityPlugin)this).Logger;
		mls.LogInfo((object)"RandomOrbExplosionが起動しました!");
		mls.LogInfo((object)$"RandomOrbExplosion:EnableLogging = {EnableLogging.Value}");
		harmony.PatchAll();
	}
}
[HarmonyPatch(typeof(EnemyValuable), "DestroyImpulse")]
public class RandomOrbExplosion_Patch
{
	private static readonly FieldInfo hasExplosionField = AccessTools.Field(typeof(EnemyValuable), "hasExplosion");

	private static bool Prefix(EnemyValuable __instance)
	{
		if (!(bool)hasExplosionField.GetValue(__instance))
		{
			return true;
		}
		int num = Random.Range(1, 101);
		int value = RandomOrbExplosion.Explosion_Weight.Value;
		if (RandomOrbExplosion.EnableLogging.Value)
		{
			RandomOrbExplosion.mls.LogInfo((object)$"lottery = {num},Explode range = 1 ~ {value}");
		}
		if (num <= value)
		{
			if (RandomOrbExplosion.EnableLogging.Value)
			{
				RandomOrbExplosion.mls.LogInfo((object)"RandomOrbExplosion:exploded!\n");
			}
			return true;
		}
		if (RandomOrbExplosion.EnableLogging.Value)
		{
			RandomOrbExplosion.mls.LogInfo((object)"RandomOrbExplosion:didn't explode!\n");
		}
		return false;
	}
}