Decompiled source of Desperadoer v1.0.0

Desperadoer.dll

Decompiled 15 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Desperadoer")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Desperadoer")]
[assembly: AssemblyTitle("Desperadoer")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Desperadoer
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.desperadoer.desperadoer", "Desperadoer", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private ConfigEntry<float> perStack;

		private readonly Dictionary<CharacterBody, List<(Transform t, Vector3 scale, Vector3 pos)>> guns = new Dictionary<CharacterBody, List<(Transform, Vector3, Vector3)>>();

		private void Awake()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			perStack = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Scale per Desperado stack", 0.25f, "Revolver grows by this much of its normal size per stack. Client side only.");
			ModSettingsManager.SetModDescription("Bandit's revolver grows with every Desperado stack. No cap.");
			ModSettingsManager.AddOption((BaseOption)new SliderOption(perStack, new SliderConfig
			{
				min = 0f,
				max = 10f,
				FormatString = "{0:0.00}x"
			}));
		}

		private void LateUpdate()
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
			{
				if (!Object.op_Implicit((Object)(object)readOnlyInstances) || readOnlyInstances.baseNameToken != "BANDIT2_BODY_NAME")
				{
					continue;
				}
				if (!guns.TryGetValue(readOnlyInstances, out List<(Transform, Vector3, Vector3)> value))
				{
					value = Find(readOnlyInstances);
					if (value.Count == 0)
					{
						continue;
					}
					guns[readOnlyInstances] = value;
				}
				float num = 1f + (float)readOnlyInstances.GetBuffCount(Buffs.BanditSkull) * perStack.Value;
				foreach (var (val, val2, localPosition) in value)
				{
					if (Object.op_Implicit((Object)(object)val))
					{
						val.localScale = val2 * num;
						val.localPosition = localPosition;
					}
				}
			}
		}

		private static string Path(Transform t, Transform root)
		{
			if (!((Object)(object)t == (Object)(object)root))
			{
				return Path(t.parent, root) + "/" + ((Object)t).name;
			}
			return ((Object)t).name;
		}

		private static List<(Transform, Vector3, Vector3)> Find(CharacterBody body)
		{
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			List<(Transform, Vector3, Vector3)> list = new List<(Transform, Vector3, Vector3)>();
			Transform val = (Object.op_Implicit((Object)(object)body.modelLocator) ? body.modelLocator.modelTransform : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return list;
			}
			Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val2 in componentsInChildren)
			{
				SkinnedMeshRenderer val3 = (SkinnedMeshRenderer)(object)((val2 is SkinnedMeshRenderer) ? val2 : null);
				object obj;
				if (val3 == null)
				{
					MeshFilter component = ((Component)val2).GetComponent<MeshFilter>();
					obj = ((component != null) ? component.sharedMesh : null);
				}
				else
				{
					obj = val3.sharedMesh;
				}
				Mesh val4 = (Mesh)obj;
				Debug.Log((object)("[Desperadoer] " + ((object)val2).GetType().Name + " path=" + Path(((Component)val2).transform, val) + " mesh=" + (Object.op_Implicit((Object)(object)val4) ? ((Object)val4).name : "-")));
				string text = (((Object)val2).name + " " + (Object.op_Implicit((Object)(object)val4) ? ((Object)val4).name : "")).ToLowerInvariant();
				if ((text.Contains("revolver") || text.Contains("shotgun") || text.Contains("gun")) && !text.Contains("muzzle"))
				{
					list.Add((((Component)val2).transform, ((Component)val2).transform.localScale, ((Component)val2).transform.localPosition));
				}
			}
			return list;
		}
	}
}