using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Wish;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("FasterRaces")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+77d734b911696a6ac16c1e8d174a85ef00e6c7bc")]
[assembly: AssemblyProduct("FasterRaces")]
[assembly: AssemblyTitle("FasterRaces")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 FasterRaces
{
[BepInPlugin("com.azraelgodking.fasterraces", "Faster Races", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static class SpeedPatch
{
public static void Postfix(StatType stat, ref float __result)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
if ((int)stat == 6 && EnableMod != null && EnableMod.Value)
{
float num = ((SpeedBonusPercent != null) ? SpeedBonusPercent.Value : 0f);
if (!(num <= 0f))
{
__result *= 1f + num / 100f;
}
}
}
}
internal static ConfigEntry<bool> EnableMod;
internal static ConfigEntry<float> SpeedBonusPercent;
private Harmony _harmony;
public static ManualLogSource Log { get; private set; }
private void Awake()
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
EnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable Faster Races movement speed bonus. When enabled, Haven's Birthright will not apply its own movement speed bonuses to avoid double speed.");
SpeedBonusPercent = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SpeedBonusPercent", 25f, "Percentage bonus to movement speed (e.g. 25 = +25%). Applied after other mods; Haven's Birthright skips its speed buff when this mod is loaded.");
_harmony = new Harmony("com.azraelgodking.fasterraces");
Type typeFromHandle = typeof(Player);
MethodInfo methodInfo = AccessTools.Method(typeFromHandle, "GetStat", new Type[1] { typeof(StatType) }, (Type[])null);
MethodInfo methodInfo2 = AccessTools.Method(typeof(SpeedPatch), "Postfix", (Type[])null, (Type[])null);
if (methodInfo != null && methodInfo2 != null)
{
_harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Log.LogInfo((object)"Patched Player.GetStat for movement speed");
}
else
{
Log.LogWarning((object)"Could not find Player.GetStat or SpeedPatch.Postfix");
}
Log.LogInfo((object)string.Format("{0} v{1} loaded. Speed bonus: {2}%", "Faster Races", "1.0.0", SpeedBonusPercent.Value));
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "com.azraelgodking.fasterraces";
public const string PLUGIN_NAME = "Faster Races";
public const string PLUGIN_VERSION = "1.0.0";
}
}