Decompiled source of FasterRoads v1.0.0

FasterRoads.dll

Decompiled 2 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using Eremite.Controller;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("FasterRoads")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Example Mod for Against The Storm")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d6ada77561ccfe85ca4c2c807fd24c8c3fc0d51c")]
[assembly: AssemblyProduct("FasterRoads")]
[assembly: AssemblyTitle("FasterRoads")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 FasterRoads
{
	[BepInPlugin("FasterRoads", "FasterRoads", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin Instance;

		public static ConfigEntry<float> RoadSpeedMultiplier;

		private void Awake()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			Instance = this;
			RoadSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Movement Settings", "FasterRoadsMultiplier", 1.5f, "The multiplier applied to villager movement speed when walking on roads.");
			Harmony val = new Harmony("FasterRoads");
			try
			{
				Type type = AccessTools.TypeByName("Eremite.Services.EffectsService");
				if (type == null)
				{
					type = AccessTools.TypeByName("Eremite.Services.RoadsService");
				}
				if (type != null)
				{
					MethodInfo methodInfo = AccessTools.Method(type, "GetActorSpeed", (Type[])null, (Type[])null);
					MethodInfo methodInfo2 = AccessTools.Method(typeof(Plugin), "IncreaseRoadSpeed", (Type[])null, (Type[])null);
					val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Road Speed Mod: Successfully patched with {RoadSpeedMultiplier.Value}x.");
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Road Speed Mod: Patch Failed! " + ex.Message));
			}
		}

		private static void IncreaseRoadSpeed(ref float __result, bool onRoad)
		{
			if (onRoad)
			{
				__result *= RoadSpeedMultiplier.Value;
			}
		}

		[HarmonyPatch(typeof(MainController), "OnServicesReady")]
		[HarmonyPostfix]
		private static void HookMainControllerSetup()
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)"Road Speed Mod: Services Ready.");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "FasterRoads";

		public const string PLUGIN_NAME = "FasterRoads";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}