using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("PeachCastleFix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PeachCastleFix")] [assembly: AssemblyTitle("PeachCastleFix")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 PeachCastleFix { [BepInPlugin("themorningstar.peachcastlefix", "PeachCastleFix", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "themorningstar.peachcastlefix"; public const string Version = "1.0.0"; internal static ManualLogSource Log; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; try { new Harmony("themorningstar.peachcastlefix").PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)"PeachCastleFix 1.0.0: Harmony patches applied."); } catch (Exception arg) { Log.LogError((object)$"PeachCastleFix PatchAll failed: {arg}"); } } } [HarmonyPatch(typeof(ExtractionPoint), "Start")] internal static class ExtractionPoint_Start_PeachCastleFix { private const string ScopeA = "PeachCastle"; private const string ScopeB = "StorageExtraction"; private static readonly string[] TargetWallNames = new string[2] { "PeachCastle Pillar Wall 00 (2)", "PeachCastle Pillar Wall 00 (3)" }; private static readonly HashSet _alreadyFixed = new HashSet(); private static void Postfix(ExtractionPoint __instance) { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) Transform val = FindModuleRoot(((Component)__instance).transform); if ((Object)(object)val == (Object)null) { return; } int instanceID = ((Object)((Component)val).gameObject).GetInstanceID(); if (!_alreadyFixed.Add(instanceID)) { return; } Plugin.Log.LogInfo((object)$"[PeachCastleFix] Fixing '{((Object)val).name}' (instanceID={instanceID})"); int num = 0; string[] targetWallNames = TargetWallNames; foreach (string text in targetWallNames) { Transform val2 = FindDeepChild(val, text); if ((Object)(object)val2 == (Object)null) { Plugin.Log.LogWarning((object)("[PeachCastleFix] Named target '" + text + "' not found — mod version may have renamed it. Check the diagnostic dump below.")); continue; } BoxCollider[] components = ((Component)val2).GetComponents(); foreach (BoxCollider val3 in components) { Plugin.Log.LogInfo((object)("[PeachCastleFix] Disabling BoxCollider on '" + text + "'" + $" | center={val3.center} size={val3.size}")); ((Collider)val3).enabled = false; num++; } Renderer component = ((Component)val2).GetComponent(); if ((Object)(object)component != (Object)null) { Plugin.Log.LogInfo((object)("[PeachCastleFix] Disabling Renderer on '" + text + "' (one-sided shader — invisible from chamber interior).")); component.enabled = false; } } Plugin.Log.LogInfo((object)$"[PeachCastleFix] Named pass: {num} BoxCollider(s) disabled."); DumpAllColliders(val); } private static Transform? FindModuleRoot(Transform t) { Transform val = t; while ((Object)(object)val != (Object)null) { if (((Object)val).name.Contains("PeachCastle") && ((Object)val).name.Contains("StorageExtraction")) { return val; } val = val.parent; } return null; } private static Transform? FindDeepChild(Transform root, string name) { for (int i = 0; i < root.childCount; i++) { Transform child = root.GetChild(i); if (((Object)child).name == name) { return child; } Transform val = FindDeepChild(child, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } private static void DumpAllColliders(Transform moduleRoot) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) BoxCollider[] componentsInChildren = ((Component)moduleRoot).GetComponentsInChildren(true); Plugin.Log.LogInfo((object)$"[PeachCastleFix] === Collider dump: {componentsInChildren.Length} BoxColliders in '{((Object)moduleRoot).name}' ==="); BoxCollider[] array = componentsInChildren; foreach (BoxCollider val in array) { Vector3 val2 = ((Component)val).transform.TransformPoint(val.center); Vector3 val3 = Vector3.Scale(val.size, ((Component)val).transform.lossyScale); bool flag = (Object)(object)((Component)val).GetComponent() != (Object)null; Plugin.Log.LogInfo((object)("[PeachCastleFix] '" + ((Object)((Component)val).gameObject).name + "'" + $" wPos=({val2.x:F1},{val2.y:F1},{val2.z:F1})" + $" lossySize=({Mathf.Abs(val3.x):F2},{Mathf.Abs(val3.y):F2},{Mathf.Abs(val3.z):F2})" + $" enabled={((Collider)val).enabled} rend={flag}")); } Plugin.Log.LogInfo((object)"[PeachCastleFix] === End dump ==="); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } }