using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0")] [assembly: AssemblyInformationalVersion("1.1.0")] [assembly: AssemblyVersion("1.1.0.0")] namespace FasterBoats; [BepInPlugin("spectralmemories.fasterboats", "Faster Boats", "1.1.0")] [BepInProcess("valheim.exe")] public class FasterBoats : BaseUnityPlugin { public const string GUID = "spectralmemories.fasterboats"; public const string NAME = "Faster Boats"; public const string VERSION = "1.1.0"; private Harmony _harmony; internal static ConfigEntry modEnabled; internal static ConfigEntry boatWindSpeedmultiplier; internal static ConfigEntry boatRudderSpeedmultiplier; private void Awake() { modEnabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Enable this mod"); boatWindSpeedmultiplier = ((BaseUnityPlugin)this).Config.Bind("Speed", "WindSpeed", 2.5f, "The speed multiplier when pushed by wind"); boatRudderSpeedmultiplier = ((BaseUnityPlugin)this).Config.Bind("Speed", "RudderSpeed", 2.25f, "Arbitrary value for rudder additional speed"); ((BaseUnityPlugin)this).Config.Save(); if (modEnabled.Value) { _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "spectralmemories.fasterboats"); } } } [HarmonyPatch(typeof(Ship), "GetSailForce", new Type[] { typeof(float), typeof(float) })] internal static class BoatWindSpeedPatcher { private static void Prefix(ref float sailSize) { if (FasterBoats.modEnabled.Value) { sailSize *= FasterBoats.boatWindSpeedmultiplier.Value; } } } [HarmonyPatch(typeof(Ship), "Start")] internal static class BoatRudderSpeedPatcher { private static void Prefix(Ship __instance) { if (FasterBoats.modEnabled.Value) { __instance.m_backwardForce *= FasterBoats.boatRudderSpeedmultiplier.Value; } } }