Decompiled source of John Big Hat v1.0.0

JohnBigHat.dll

Decompiled 3 days ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using On.RoR2;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using UnityEngine;
using UnityEngine.Events;

[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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("JohnBigHat")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("JohnBigHat")]
[assembly: AssemblyTitle("JohnBigHat")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace JohnBigHat;

[BepInPlugin("com.brynzananas.johnbighat", "John Big Hat", "1.0.0")]
[BepInDependency("com.bepis.r2api", "5.0.10")]
public class Main : BaseUnityPlugin
{
	public const string ModGuid = "com.brynzananas.johnbighat";

	public const string ModName = "John Big Hat";

	public const string ModVer = "1.0.0";

	public static ConfigEntry<bool> FlatSizeIncrease;

	public static ConfigEntry<float> SizeIncreasePerKill;

	public static ConfigEntry<float> InitialSizeIncrease;

	private void Awake()
	{
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Expected O, but got Unknown
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Expected O, but got Unknown
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Expected O, but got Unknown
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Expected O, but got Unknown
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Expected O, but got Unknown
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Expected O, but got Unknown
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Expected O, but got Unknown
		InitialSizeIncrease = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Initial size increase", 3f, "Control the increase of hat");
		FlatSizeIncrease = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Flat size increase", true, "Replace multiplier with flat size increase?");
		SizeIncreasePerKill = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Size increase per kill", 0.1f, "Control the increase of hat per kill");
		ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(InitialSizeIncrease));
		ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(FlatSizeIncrease));
		ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(SizeIncreasePerKill));
		ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("General", "General", "Reset current hat size to initial", "Reset current hat size to initial", new UnityAction(Reset)));
		DeathRewards.OnKilledServer += new hook_OnKilledServer(DeathRewards_OnKilledServer);
		CharacterBody.Start += new hook_Start(CharacterBody_Start);
	}

	private void Reset()
	{
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			CharacterMaster master = NetworkUser.readOnlyLocalPlayersList[0].master;
			GetHat((master != null) ? master.GetBody() : null).localScale = new Vector3(InitialSizeIncrease.Value, InitialSizeIncrease.Value, InitialSizeIncrease.Value);
		}
		catch
		{
		}
	}

	private void CharacterBody_Start(orig_Start orig, CharacterBody self)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		orig.Invoke(self);
		Transform hat = GetHat(self);
		hat.localScale *= InitialSizeIncrease.Value;
	}

	private Transform GetHat(CharacterBody model)
	{
		return ((Component)model.modelLocator._modelTransform).transform.Find("BanditArmature/ROOT/base/stomach/chest/head/hat/Bandit2HatMesh");
	}

	private void DeathRewards_OnKilledServer(orig_OnKilledServer orig, DeathRewards self, DamageReport damageReport)
	{
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		orig.Invoke(self, damageReport);
		if (Object.op_Implicit((Object)(object)damageReport.attacker) && Object.op_Implicit((Object)(object)damageReport.attackerBody) && (Object)(object)BodyCatalog.FindBodyPrefab(((Object)damageReport.attackerBody).name.Replace("(Clone)", "")) == (Object)(object)Survivors.Bandit2.bodyPrefab)
		{
			if (FlatSizeIncrease.Value)
			{
				Transform hat = GetHat(damageReport.attackerBody);
				hat.localScale += new Vector3(SizeIncreasePerKill.Value, SizeIncreasePerKill.Value, SizeIncreasePerKill.Value);
			}
			else
			{
				Transform hat2 = GetHat(damageReport.attackerBody);
				hat2.localScale *= SizeIncreasePerKill.Value;
			}
		}
	}
}