Decompiled source of HexRowFaster v1.1.0

Plugins/HexRowFaster.dll

Decompiled a day ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("HexRowFaster")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HexRowFaster")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a7a3b18f-1ccb-45d1-8f8c-344070327601")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HexRowFaster
{
	[BepInPlugin("com.hex.rowfaster", "HexRowFaster", "1.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string PluginGuid = "com.hex.rowfaster";

		private const string PluginName = "HexRowFaster";

		private const string PluginVersion = "1.1.0";

		private ConfigEntry<bool> _isModEnabled;

		private ConfigEntry<ForceMultiplier> _forceMultiplier;

		internal static ManualLogSource Log;

		internal static Plugin Instance;

		internal static Harmony HarmonyInstance;

		internal static bool IsModEnabled => Instance?._isModEnabled.Value ?? false;

		internal static ForceMultiplier ForceMultiplier => Instance?._forceMultiplier.Value ?? ForceMultiplier.Cruising;

		private void Awake()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			_isModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable", true, "Enables or disables HexRowFaster for newly spawned ships.");
			_forceMultiplier = ((BaseUnityPlugin)this).Config.Bind<ForceMultiplier>("General", "Force Multiplier", ForceMultiplier.Cruising, "How fast do you want to go?");
			HarmonyInstance = new Harmony("com.hex.rowfaster");
			HarmonyInstance.PatchAll();
			Log.LogInfo((object)"Plugin HexRowFaster v1.1.0 loaded.");
		}

		private void OnDestroy()
		{
			Log.LogInfo((object)"Plugin HexRowFaster v1.1.0 unloaded.");
			Harmony harmonyInstance = HarmonyInstance;
			if (harmonyInstance != null)
			{
				harmonyInstance.UnpatchSelf();
			}
			HarmonyInstance = null;
			Instance = null;
		}
	}
	public enum ForceMultiplier
	{
		Vanilla = 1,
		LittleFaster = 5,
		Cruising = 10,
		Speeding = 20,
		Insane = 40
	}
}
namespace HexRowFaster.Patches
{
	[HarmonyPatch(typeof(Ship), "CustomFixedUpdate")]
	internal static class PatchShip
	{
		[HarmonyPrefix]
		private static void ModifyBackwardForceValue(Ship __instance, ref float? __state)
		{
			__state = null;
			if (!((Object)(object)Plugin.Instance == (Object)null) && !((Object)(object)__instance == (Object)null) && Plugin.IsModEnabled && Plugin.ForceMultiplier != ForceMultiplier.Vanilla && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)Player.m_localPlayer.GetControlledShip() != (Object)(object)__instance))
			{
				__state = __instance.m_backwardForce;
				__instance.m_backwardForce *= (float)Plugin.ForceMultiplier;
			}
		}

		[HarmonyPostfix]
		private static void RestoreBackwardForceValue(Ship __instance, float? __state)
		{
			if (!((Object)(object)Plugin.Instance == (Object)null) && !((Object)(object)__instance == (Object)null) && __state.HasValue)
			{
				__instance.m_backwardForce = __state.Value;
			}
		}
	}
}