using HarmonyLib; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.Rendering.HighDefinition; using UnityEngine.Rendering; namespace ScarletMansionSeichiPatch { public class Patch { public static void Activate() { Plugin.Instance.harmony.PatchAll(typeof(Patch)); } public static Volume GetVolume(){ GameObject[] rootGameObjects = null; for(var i = 0; i < SceneManager.sceneCount; i++){ var scene = SceneManager.GetSceneAt(i); if (scene.name.ToLowerInvariant() == "seichi") { rootGameObjects = scene.GetRootGameObjects(); Plugin.logger.LogInfo("Found Seichi scene"); break; } } if (rootGameObjects == null) return null; foreach(var root in rootGameObjects){ if (root.name.ToLowerInvariant() == "environment") { var item = root.transform.Find("RaphtaliaVolume"); if (item != null) { return item.GetComponentInChildren(true); } } } return null; } [HarmonyPatch(typeof(RoundManager), "SetPowerOffAtStart")] [HarmonyPostfix] public static void ShipLandedPatch(ref RoundManager __instance){ if (!ScarletMansion.DunGenPatch.Patch.active) return; var volume = GetVolume(); if (volume == null) { Plugin.logger.LogWarning($"Couldn't setup SDM/Seichi compatibility feature"); return; } volume.enabled = true; } } }