Decompiled source of AutoFire v1.7.0

AutoFire.dll

Decompiled 6 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
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: AssemblyTitle("AutoFire")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AutoFire")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a1328614-8f9d-44fa-999d-08f1d7357d4a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RoR2AutoPlay;

[BepInPlugin("com.geminimod.autoplay", "AutoPlay", "1.7.0")]
public class AutoPlayMod : BaseUnityPlugin
{
	private readonly Dictionary<string, List<SkillSlot>> ignoredSkillsPerCharacter = new Dictionary<string, List<SkillSlot>>
	{
		{
			"COMMANDO_BODY_NAME",
			new List<SkillSlot> { (SkillSlot)2 }
		},
		{
			"HUNTRESS_BODY_NAME",
			new List<SkillSlot> { (SkillSlot)2 }
		},
		{
			"BANDIT2_BODY_NAME",
			new List<SkillSlot> { (SkillSlot)2 }
		},
		{
			"LOADER_BODY_NAME",
			new List<SkillSlot>
			{
				(SkillSlot)1,
				(SkillSlot)2
			}
		},
		{
			"CAPTAIN_BODY_NAME",
			new List<SkillSlot>()
		},
		{
			"TOOLBOT_BODY_NAME",
			new List<SkillSlot> { (SkillSlot)2 }
		},
		{
			"CROCO_BODY_NAME",
			new List<SkillSlot> { (SkillSlot)2 }
		},
		{
			"MERC_BODY_NAME",
			new List<SkillSlot> { (SkillSlot)2 }
		},
		{
			"VOIDSURVIVOR_BODY_NAME",
			new List<SkillSlot> { (SkillSlot)2 }
		},
		{
			"SEEKER_BODY_NAME",
			new List<SkillSlot> { (SkillSlot)2 }
		},
		{
			"CHEF_BODY_NAME",
			new List<SkillSlot> { (SkillSlot)2 }
		}
	};

	public void Awake()
	{
		((BaseUnityPlugin)this).Logger.LogInfo((object)"AutoPlay Mod (1.7.0) Active: Forcing Skill Execution (Movement excluded, Range: 100m).");
	}

	public void LateUpdate()
	{
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		if (PlayerCharacterMasterController.instances.Count == 0)
		{
			return;
		}
		CharacterMaster master = PlayerCharacterMasterController.instances[0].master;
		if ((Object)(object)master == (Object)null)
		{
			return;
		}
		CharacterBody body = master.GetBody();
		if ((Object)(object)body == (Object)null || (Object)(object)body.healthComponent == (Object)null || !body.healthComponent.alive)
		{
			return;
		}
		InputBankTest component = ((Component)body).GetComponent<InputBankTest>();
		SkillLocator component2 = ((Component)body).GetComponent<SkillLocator>();
		if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null)
		{
			return;
		}
		TeamIndex myTeam = body.teamComponent.teamIndex;
		CharacterBody val = ((IEnumerable<CharacterBody>)(from b in CharacterBody.readOnlyInstancesList
			where b.teamComponent.teamIndex != myTeam && b.healthComponent.alive
			orderby Vector3.Distance(body.corePosition, b.corePosition)
			select b)).FirstOrDefault((Func<CharacterBody, bool>)((CharacterBody b) => Vector3.Distance(body.corePosition, b.corePosition) <= 100f));
		if ((Object)(object)val != (Object)null)
		{
			Vector3 val2 = val.corePosition - body.corePosition;
			component.aimDirection = ((Vector3)(ref val2)).normalized;
			List<SkillSlot> list = new List<SkillSlot>();
			if (ignoredSkillsPerCharacter.TryGetValue(body.baseNameToken, out var value))
			{
				list = value;
			}
			if ((Object)(object)component2.primary != (Object)null && !list.Contains((SkillSlot)0))
			{
				component2.primary.ExecuteIfReady();
			}
			if ((Object)(object)component2.secondary != (Object)null && !list.Contains((SkillSlot)1))
			{
				component2.secondary.ExecuteIfReady();
			}
			if ((Object)(object)component2.utility != (Object)null && !list.Contains((SkillSlot)2))
			{
				component2.utility.ExecuteIfReady();
			}
			if ((Object)(object)component2.special != (Object)null && !list.Contains((SkillSlot)3))
			{
				component2.special.ExecuteIfReady();
			}
		}
	}
}