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 NoWoodWaterDamage v1.1.2
Cjayride.NoWoodWaterDamage.dll
Decompiled a week agousing 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 HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")] [assembly: AssemblyCompany("Cjayride.NoWoodWaterDamage")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+62e74d3bf61a3206e3b177da754604b2b0d28e95")] [assembly: AssemblyProduct("Cjayride.NoWoodWaterDamage")] [assembly: AssemblyTitle("Cjayride.NoWoodWaterDamage")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Cjayride.NoWoodWaterDamage { [BepInPlugin("cjayride.NoWoodWaterDamage", "No Wood Water Damage", "1.1.2")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "cjayride.NoWoodWaterDamage"; public const string PluginName = "No Wood Water Damage"; public const string PluginVersion = "1.1.2"; internal static bool PreventAll; internal static bool ProtectWaterline; public static ConfigEntry<bool> PreventAllWeatherDamage { get; private set; } public static ConfigEntry<bool> ProtectAtWaterline { get; private set; } private void Awake() { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) PreventAllWeatherDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PreventAllWeatherDamage", true, "When enabled, ALL wood/hardwood/timberwood pieces are immune to rain and weather damage everywhere, not just at the waterline. Set to false to only protect at the waterline."); ProtectAtWaterline = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ProtectAtWaterline", true, "Protect wood pieces at the waterline (docks, shore). Leave this true even if PreventAllWeatherDamage is true."); PreventAll = PreventAllWeatherDamage.Value; ProtectWaterline = ProtectAtWaterline.Value; PreventAllWeatherDamage.SettingChanged += delegate { PreventAll = PreventAllWeatherDamage.Value; }; ProtectAtWaterline.SettingChanged += delegate { ProtectWaterline = ProtectAtWaterline.Value; }; ((BaseUnityPlugin)this).Config.Save(); new Harmony("cjayride.NoWoodWaterDamage").PatchAll(); if (PreventAll) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"All wood/hardwood/timberwood pieces are fully immune to rain and weather damage everywhere."); } else if (ProtectWaterline) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Wood protection limited to the waterline only. Rain on dry land still causes wear."); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"All wood protection disabled in config. Wood will take normal weather damage."); } } } [HarmonyPatch(typeof(WearNTear), "IsWet")] internal static class SkipSubmergedWood { private const float WaterlineMargin = 2.5f; private static readonly ConditionalWeakTable<WearNTear, object> ShipLookup = new ConditionalWeakTable<WearNTear, object>(); private static readonly object ShipYes = new object(); private static readonly object ShipNo = new object(); private static bool Prefix(WearNTear __instance, ref bool __result) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 if ((Object)(object)__instance == (Object)null) { return true; } if (!Plugin.PreventAll && !Plugin.ProtectWaterline) { return true; } MaterialType materialType = __instance.m_materialType; if ((int)materialType != 0 && (int)materialType != 3 && (int)materialType != 8) { return true; } if (IsOnShip(__instance)) { return true; } if (Plugin.PreventAll) { __result = false; return false; } return true; } private static void Postfix(WearNTear __instance, ref bool __result) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 if (__result && !((Object)(object)__instance == (Object)null) && !Plugin.PreventAll && Plugin.ProtectWaterline) { MaterialType materialType = __instance.m_materialType; if (((int)materialType == 0 || (int)materialType == 3 || (int)materialType == 8) && !IsOnShip(__instance) && IsAtWaterline(__instance)) { __result = false; } } } private static bool IsOnShip(WearNTear wear) { if (ShipLookup.TryGetValue(wear, out var value)) { return value == ShipYes; } bool flag = false; Transform transform = ((Component)wear).transform; if ((Object)(object)transform != (Object)null) { Transform root = transform.root; flag = (Object)(object)root != (Object)null && (Object)(object)((Component)root).GetComponent<Ship>() != (Object)null; } ShipLookup.Add(wear, flag ? ShipYes : ShipNo); return flag; } private static bool IsAtWaterline(WearNTear piece) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)piece).transform; if ((Object)(object)transform == (Object)null) { return false; } Vector3 position = transform.position; WaterVolume val = null; float waterLevel = Floating.GetWaterLevel(position, ref val); if (waterLevel < -1000f) { return false; } return position.y <= waterLevel + 2.5f; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }