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 RtDBalanceCompatibility v0.1.0
plugins/RtDBalanceCompatibility/RtDBalanceCompatibility.dll
Decompiled 15 hours agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using HarmonyLib; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("RtDBalanceCompatibility")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("RtDBalanceCompatibility")] [assembly: AssemblyTitle("RtDBalanceCompatibility")] [assembly: AssemblyVersion("0.1.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 RtDBalanceCompatibility { internal static class BalanceRules { internal const string RequiredKey = "defeated_queen"; internal static bool CanGate(string name, string currentKey) { if (name == "Belzor_RtD") { if (!string.IsNullOrEmpty(currentKey)) { return currentKey == "defeated_queen"; } return true; } return false; } internal static bool ShouldRestore(float before, float after) { if (before > 0f && !float.IsInfinity(before) && !float.IsNaN(before) && Math.Abs(after - 1500f) < 0.001f) { return Math.Abs(before - after) > 0.001f; } return false; } } [BepInPlugin("vercadi.RtDBalanceCompatibility", "RtD Balance Compatibility", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { internal sealed class BoatState { internal WearNTear Boat; internal float Health; } internal const string Guid = "vercadi.RtDBalanceCompatibility"; private Harmony harmony; internal static ManualLogSource Log; private void Awake() { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown //IL_010a: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; PluginInfo val = Chainloader.PluginInfos["soloredis.rtdocean"]; if (val.Metadata.Version != new Version(2, 2, 47)) { ((BaseUnityPlugin)this).Logger.LogError((object)"Unsupported RtDOcean version; review compatibility before using this helper. No changes applied."); return; } MethodInfo methodInfo = AccessTools.DeclaredMethod(((object)val.Instance).GetType(), "EditBoats", Type.EmptyTypes, (Type[])null); CustomCreature creature = CreatureManager.Instance.GetCreature("Belzor_RtD"); if (methodInfo == null || creature == null || creature.Spawns.Count != 1 || !BalanceRules.CanGate(((Object)creature.Prefab).name, creature.Spawns[0].m_requiredGlobalKey)) { ((BaseUnityPlugin)this).Logger.LogError((object)"RtDOcean structure changed or Belzor has another progression gate; no changes applied."); return; } harmony = new Harmony("vercadi.RtDBalanceCompatibility"); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Plugin), "BeforeEditBoats", (Type[])null), new HarmonyMethod(typeof(Plugin), "AfterEditBoats", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); creature.Spawns[0].m_requiredGlobalKey = "defeated_queen"; ((BaseUnityPlugin)this).Logger.LogInfo((object)"ACTIVE: roaming Belzor requires the world's defeated_queen key; longship base-health preservation armed."); } private static void BeforeEditBoats(out BoatState __state) { __state = null; try { WearNTear prefab = Cache.GetPrefab<WearNTear>("VikingShip"); if (Object.op_Implicit((Object)(object)prefab)) { __state = new BoatState { Boat = prefab, Health = prefab.m_health }; } } catch (Exception ex) { Log.LogError((object)("Cannot capture longship base health: " + ex.Message)); } } private static void AfterEditBoats(BoatState __state) { if (__state != null && Object.op_Implicit((Object)(object)__state.Boat) && BalanceRules.ShouldRestore(__state.Health, __state.Boat.m_health)) { __state.Boat.m_health = __state.Health; Log.LogInfo((object)("Preserved longship base health at " + __state.Health + "; Longship Upgrades retains hull progression. Ocean raft/karve changes retained.")); } } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } } }