Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of HideSail v1.0.7
HideSail.dll
Decompiled 4 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [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.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("HideSail")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("HideSail")] [assembly: AssemblyTitle("HideSail")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 HideSail { [BepInPlugin("zenox.hidesail", "HideSail", "1.0.7")] public class HideSailPlugin : BaseUnityPlugin { public const string PluginGUID = "zenox.hidesail"; public const string PluginName = "HideSail"; public const string PluginVersion = "1.0.7"; public static ConfigEntry<KeyboardShortcut> HideSailKey; public static ConfigEntry<float> SailHiddenAlpha; public static ConfigEntry<float> UpdateInterval; private readonly Harmony harmony = new Harmony("zenox.hidesail"); private const string SailHiddenZdoKey = "hidesail_hidden"; private Ship currentShip; private float shipCheckTimer; private bool appliedSailHidden; private void Awake() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) HideSailKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Sailing", "HideSailKey", new KeyboardShortcut((KeyCode)104, Array.Empty<KeyCode>()), "Key to toggle the visibility of your current ship's sail (visual only, does not affect sailing speed)."); SailHiddenAlpha = ((BaseUnityPlugin)this).Config.Bind<float>("Sailing", "SailHiddenAlpha", 0.01f, "How transparent the sail becomes when hidden (0 = fully invisible, 1 = fully opaque). A small value like 0.01 keeps a faint hint of the sail's up/down position."); UpdateInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Sailing", "UpdateInterval", 0.1f, "Seconds between checks for which ship you're currently on."); harmony.PatchAll(Assembly.GetExecutingAssembly()); ((BaseUnityPlugin)this).Logger.LogInfo((object)"HideSail v1.0.7 loaded."); } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } private void Update() { //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { currentShip = null; return; } Ship val = currentShip; shipCheckTimer += Time.deltaTime; if (shipCheckTimer >= UpdateInterval.Value) { shipCheckTimer = 0f; currentShip = FindPlayerShip(localPlayer); if ((Object)(object)currentShip != (Object)null) { ZNetView component = ((Component)currentShip).GetComponent<ZNetView>(); if ((Object)(object)component != (Object)null && component.IsValid()) { bool flag = component.GetZDO().GetBool("hidesail_hidden", false); if ((Object)(object)currentShip != (Object)(object)val || flag != appliedSailHidden) { ApplySailVisibility(currentShip, flag); } } } } if (!((Object)(object)currentShip != (Object)null)) { return; } KeyboardShortcut value = HideSailKey.Value; if (!((KeyboardShortcut)(ref value)).IsDown()) { return; } ZNetView component2 = ((Component)currentShip).GetComponent<ZNetView>(); if ((Object)(object)component2 != (Object)null && component2.IsValid()) { if (!component2.IsOwner()) { component2.ClaimOwnership(); } bool flag2 = !component2.GetZDO().GetBool("hidesail_hidden", false); component2.GetZDO().Set("hidesail_hidden", flag2); ApplySailVisibility(currentShip, flag2); } } private void ApplySailVisibility(Ship ship, bool hidden) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) List<Renderer> sailRenderers = GetSailRenderers(ship); if (sailRenderers.Count == 0) { return; } float num = (hidden ? SailHiddenAlpha.Value : 1f); foreach (Renderer item in sailRenderers) { Color color = item.material.color; item.material.color = new Color(color.r, color.g, color.b, num); } appliedSailHidden = hidden; } private static List<Renderer> GetSailRenderers(Ship ship) { List<Renderer> list = new List<Renderer>(); if ((Object)(object)ship.m_sailObject != (Object)null) { list.AddRange(ship.m_sailObject.GetComponentsInChildren<Renderer>(true)); } if ((Object)(object)ship.m_sailCloth != (Object)null) { Renderer[] componentsInChildren = ((Component)ship.m_sailCloth).GetComponentsInChildren<Renderer>(true); foreach (Renderer item in componentsInChildren) { if (!list.Contains(item)) { list.Add(item); } } } return list; } private static Ship FindPlayerShip(Player player) { Ship[] array = Object.FindObjectsByType<Ship>((FindObjectsSortMode)0); foreach (Ship val in array) { if (val.IsPlayerInBoat(player)) { return val; } } return null; } } }