Decompiled source of Travel Speed v1.0.0

TravelSpeed.dll

Decompiled 2 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("OutwardModTemplate")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OutwardModTemplate")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace TravelSpeed;

[BepInPlugin("Tchernobill.TravelSpeed", "TravelSpeed", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	public class CharacterStats_MovementSpeed
	{
		private static void Postfix(CharacterStats __instance, ref float __result)
		{
			if ((activeSpeedBuff.Value || activeStaminaRegen.Value) && !__instance.m_character.IsAI && (applyInBossArena.Value || !isInBossArena()) && (applyInCombat.Value || !__instance.m_character.InCombat) && (applyCloseToEnemies.Value || !__instance.m_character.IsEnemyClose(valueEnemyDistance.Value)))
			{
				if (activeSpeedBuff.Value)
				{
					__result += valueSpeedBuff.Value / 100f;
				}
				if (activeStaminaRegen.Value)
				{
					__instance.m_character.Stats.GetStat((StatType)6).AddMultiplierStack("staminaOutOfCombat", (0f - valueStaminaRegen.Value) / 100f);
				}
			}
			else
			{
				__instance.m_character.Stats.GetStat((StatType)6).RemoveMultiplierStack("staminaOutOfCombat");
			}
		}
	}

	public const string GUID = "Tchernobill.TravelSpeed";

	public const string NAME = "TravelSpeed";

	public const string VERSION = "1.0.0";

	internal static ManualLogSource Log;

	public static ConfigEntry<bool> activeSpeedBuff;

	public static ConfigEntry<bool> activeStaminaRegen;

	public static ConfigEntry<float> valueSpeedBuff;

	public static ConfigEntry<float> valueStaminaRegen;

	public static ConfigEntry<bool> applyCloseToEnemies;

	public static ConfigEntry<float> valueEnemyDistance;

	public static ConfigEntry<bool> applyInCombat;

	public static ConfigEntry<bool> applyInBossArena;

	internal void Awake()
	{
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		activeSpeedBuff = ((BaseUnityPlugin)this).Config.Bind<bool>("TravelSpeed", "Speed Increase: Activation", true, "");
		valueSpeedBuff = ((BaseUnityPlugin)this).Config.Bind<float>("TravelSpeed", "Speed Increase: Value (%)", 100f, "");
		activeStaminaRegen = ((BaseUnityPlugin)this).Config.Bind<bool>("TravelSpeed", "Stamina Reduction: Activation", true, "");
		valueStaminaRegen = ((BaseUnityPlugin)this).Config.Bind<float>("TravelSpeed", "Stamina Reduction: Value (%)", 70f, "");
		applyCloseToEnemies = ((BaseUnityPlugin)this).Config.Bind<bool>("TravelSpeed", "Close To Enemies: Activation", false, "");
		valueEnemyDistance = ((BaseUnityPlugin)this).Config.Bind<float>("TravelSpeed", "Close To Enemies: Distance", 15f, "");
		applyInCombat = ((BaseUnityPlugin)this).Config.Bind<bool>("TravelSpeed", "In Combat: Activation", false, "");
		applyInBossArena = ((BaseUnityPlugin)this).Config.Bind<bool>("TravelSpeed", "Boss Arena: Activation", false, "");
		new Harmony("Tchernobill.TravelSpeed").PatchAll();
	}

	public static bool isInBossArena()
	{
		return SceneManagerHelper.ActiveSceneName.EndsWith("Bosses");
	}
}