Decompiled source of Agility v1.0.0

Agility.dll

Decompiled a month 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 HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("Agility")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+60f2bf90f6581fe81287aff497c450c8ad66d865")]
[assembly: AssemblyProduct("Agility")]
[assembly: AssemblyTitle("Agility")]
[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 Agility
{
	[BepInPlugin("agility.skill", "Agility", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const SkillType Skill = (SkillType)715293104;

		private static ConfigEntry<float> xpRate;

		private static ConfigEntry<float> maxSpeed;

		private static ConfigEntry<float> maxJump;

		private static ConfigEntry<float> maxFall;

		private Player player;

		private float walk;

		private float jog;

		private float run;

		private float jump;

		private void Awake()
		{
			xpRate = ((BaseUnityPlugin)this).Config.Bind<float>("Agility", "XpMultiplier", 1f, "XP por segundo correndo e por pulo");
			maxSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Agility", "MaxSpeedBonus", 0.3f, "Bônus de velocidade no nível 100 (0.3 = +30%)");
			maxJump = ((BaseUnityPlugin)this).Config.Bind<float>("Agility", "MaxJumpBonus", 0.5f, "Bônus de força do pulo no nível 100 (0.5 = +50%)");
			maxFall = ((BaseUnityPlugin)this).Config.Bind<float>("Agility", "MaxFallDamageReduction", 0.8f, "Redução do dano de queda no nível 100 (0.8 = -80%)");
			Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
		}

		private void Update()
		{
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null))
			{
				if ((Object)(object)localPlayer != (Object)(object)player)
				{
					player = localPlayer;
					walk = ((Character)localPlayer).m_walkSpeed;
					jog = ((Character)localPlayer).m_speed;
					run = ((Character)localPlayer).m_runSpeed;
					jump = ((Character)localPlayer).m_jumpForce;
				}
				float skillFactor = ((Character)localPlayer).GetSkillFactor((SkillType)715293104);
				float num = 1f + skillFactor * maxSpeed.Value;
				((Character)localPlayer).m_walkSpeed = walk * num;
				((Character)localPlayer).m_speed = jog * num;
				((Character)localPlayer).m_runSpeed = run * num;
				((Character)localPlayer).m_jumpForce = jump * (1f + skillFactor * maxJump.Value);
			}
		}

		[HarmonyPatch(typeof(Skills), "Awake")]
		[HarmonyPostfix]
		private static void RegisterSkill(List<SkillDef> ___m_skills)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			___m_skills.Add(new SkillDef
			{
				m_skill = (SkillType)715293104,
				m_description = "Correr e pular aumentam velocidade, altura do pulo e resistência a queda.",
				m_icon = ___m_skills.Find((SkillDef s) => (int)s.m_skill == 102)?.m_icon,
				m_increseStep = 1f
			});
			AccessTools.Method(typeof(Localization), "AddWord", (Type[])null, (Type[])null).Invoke(Localization.instance, new object[2]
			{
				"skill_" + 715293104,
				"Agilidade"
			});
		}

		[HarmonyPatch(typeof(Skills), "IsSkillValid")]
		[HarmonyPostfix]
		private static void KeepOnLoad(SkillType __0, ref bool __result)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			__result |= (int)__0 == 715293104;
		}

		[HarmonyPatch(typeof(Skills), "RaiseSkill")]
		[HarmonyPostfix]
		private static void GainXp(Skills __instance, SkillType __0)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			if ((int)__0 == 102 || (int)__0 == 100)
			{
				__instance.RaiseSkill((SkillType)715293104, xpRate.Value);
			}
		}

		[HarmonyPatch(typeof(Character), "Damage")]
		[HarmonyPrefix]
		private static void FallResist(Character __instance, HitData __0)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)__0.m_hitType == 3 && (Object)(object)__instance == (Object)(object)Player.m_localPlayer)
			{
				__0.m_damage.m_damage *= 1f - __instance.GetSkillFactor((SkillType)715293104) * maxFall.Value;
			}
		}
	}
}