Decompiled source of AmbientSpite v1.0.0

plugin/AmbientSpite.dll

Decompiled 9 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using IL.RoR2.Artifacts;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("AmbientSpite")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AmbientSpite")]
[assembly: AssemblyTitle("AmbientSpite")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AmbientSpite;

[BepInPlugin("com.kking117.AmbientSpite", "AmbientSpite", "1.0.0")]
public class MainPlugin : BaseUnityPlugin
{
	public const string MODUID = "com.kking117.AmbientSpite";

	public const string MODNAME = "AmbientSpite";

	public const string MODVERSION = "1.0.0";

	public static float BaseDamage;

	public static float LevelDamage;

	public void Awake()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		ReadConfig();
		BombArtifactManager.OnServerCharacterDeath += new Manipulator(IL_CharacterDeath);
	}

	public void ReadConfig()
	{
		BaseDamage = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Base Damage", 12f, "Damage of Spite Bombs at level 1.").Value;
		LevelDamage = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Level Damage", 2.4f, "Damage Spite Bombs gain per additional level.").Value;
	}

	private void IL_CharacterDeath(ILContext il)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		ILCursor val = new ILCursor(il);
		if (val.TryGotoNext(new Func<Instruction, bool>[1]
		{
			(Instruction x) => ILPatternMatchingExt.MatchCallvirt<CharacterBody>(x, "get_damage")
		}))
		{
			val.Remove();
			val.EmitDelegate<Func<CharacterBody, float>>((Func<CharacterBody, float>)delegate
			{
				float num = Math.Max(0f, Run.instance.ambientLevel - 1f);
				return BaseDamage + LevelDamage * num;
			});
		}
		else
		{
			Debug.LogError((object)"AmbientSpite:  IL Hook failed");
		}
	}
}