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 TouhouCompany v1.0.3
TouhouCompany.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using TouhouCompany.NetcodePatcher; using Unity.Netcode; using UnityEngine; using UnityEngine.Audio; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.SceneManagement; [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: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: AssemblyCompany("TouhouCompany")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A template for Lethal Company")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+0a51e2ebe50d8b5707a645b4d219e07ce88442ce")] [assembly: AssemblyProduct("TouhouCompany")] [assembly: AssemblyTitle("TouhouCompany")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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 TouhouCompany { public class KoumakanManager : NetworkBehaviour { public static Dictionary<string, GameObject> Objects; private void Awake() { TouhouCompanyPlugin.Instance.AddLog("Awaking KoumakanManager"); Objects = new Dictionary<string, GameObject>(); Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); TouhouCompanyPlugin.Instance.AddLog("KoumakanManager is awake"); } public void Destroy() { Objects.Clear(); } [ServerRpc] public void SpawnKoumakanServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Invalid comparison between Unknown and I4 //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Invalid comparison between Unknown and I4 NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } return; } ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1437523285u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1437523285u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { TouhouCompanyPlugin.Instance.AddLog("Running SpawnKoumakanServerRpc"); EnableKoumakanClientRpc(); } } [ClientRpc] public void EnableKoumakanClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2954063379u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2954063379u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } TouhouCompanyPlugin.Instance.AddLog("Running RearrangeSceneClientRpc"); Scene sceneByName = SceneManager.GetSceneByName("Level4March"); GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects(); try { GameObject[] array = rootGameObjects; foreach (GameObject val3 in array) { TouhouCompanyPlugin.Instance.AddLog("Processing " + ((Object)val3).name + " on Level4March."); string name = ((Object)val3).name; string text = name; if (text == "Environment") { Transform val4 = val3.transform.Find("Map/RoofDome"); ((Renderer)((Component)val4).GetComponent<MeshRenderer>()).enabled = false; ((Collider)((Component)val4).GetComponent<MeshCollider>()).enabled = false; GameObject val5 = Object.Instantiate<GameObject>(TouhouCompanyPlugin.KoumakanPrefeb); val5.transform.SetParent(val4); val5.transform.localPosition = Vector3.zero; val5.transform.localRotation = Quaternion.identity; val5.transform.localScale = Vector3.one; TouhouCompanyPlugin.Instance.AddLog("Enable Koumakan."); Transform val6 = val3.transform.Find("HangingLight (13)"); Transform val7 = val3.transform.Find("HangingLight (14)"); Object.Destroy((Object)(object)((Component)val6).gameObject); Object.Destroy((Object)(object)((Component)val7).gameObject); TouhouCompanyPlugin.Instance.AddLog("Disable HangingLights."); Transform val8 = val3.transform.Find("SteelDoorFake"); Transform val9 = val3.transform.Find("SteelDoorFake (1)"); Transform val10 = val3.transform.Find("DoorFrame (1)"); Object.Destroy((Object)(object)((Component)val8).gameObject); Object.Destroy((Object)(object)((Component)val9).gameObject); Object.Destroy((Object)(object)((Component)val10).gameObject); TouhouCompanyPlugin.Instance.AddLog("Disable SteelDoor."); } } } catch (Exception arg) { TouhouCompanyPlugin.Instance.AddLog($"An error occured when replacing Level4MarchBuilding: {arg}"); } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_KoumakanManager() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(1437523285u, new RpcReceiveHandler(__rpc_handler_1437523285)); NetworkManager.__rpc_func_table.Add(2954063379u, new RpcReceiveHandler(__rpc_handler_2954063379)); } private static void __rpc_handler_1437523285(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_0055: Invalid comparison between Unknown and I4 NetworkManager networkManager = target.NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } } else { target.__rpc_exec_stage = (__RpcExecStage)1; ((KoumakanManager)(object)target).SpawnKoumakanServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2954063379(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)2; ((KoumakanManager)(object)target).EnableKoumakanClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "KoumakanManager"; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.bean.TouhouCompany"; public const string PLUGIN_NAME = "TouhouCompany"; public const string PLUGIN_VERSION = "0.0.2"; } internal class ShrineBuilding : NetworkBehaviour { private Fog fog; private float lowFogWeight = 500f; private float highFogWeight = 0f; private float targetFogWeight = 0f; private float fogFadeVelocity = 0f; private float fogFadeTime = 0.5f; private void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown try { Scene sceneByName = SceneManager.GetSceneByName("CompanyBuilding"); GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { if (!(((Object)val).name == "Environment")) { continue; } Transform val2 = val.transform.Find("Lighting/BrightDay/Sun/SunAnimContainer/Sky and Fog Global Volume"); if (Object.op_Implicit((Object)(object)val2)) { TouhouCompanyPlugin.Instance.AddLog("Found fog gameobject, getting volume component"); fog = (Fog)((Component)val2).GetComponent<Volume>().profile.components.Find((VolumeComponent x) => ((object)x).GetType() == typeof(Fog)); highFogWeight = ((VolumeParameter<float>)(object)fog.meanFreePath).value; targetFogWeight = highFogWeight; } else { TouhouCompanyPlugin.Instance.AddLog("Could not find fog gameobject"); } } } catch { TouhouCompanyPlugin.Instance.AddLog("Wrong scene for fog."); } } private void Update() { ((VolumeParameter<float>)(object)fog.meanFreePath).value = Mathf.SmoothDamp(((VolumeParameter<float>)(object)fog.meanFreePath).value, targetFogWeight, ref fogFadeVelocity, fogFadeTime); } private void OnTriggerEnter(Collider other) { PlayerControllerB val = default(PlayerControllerB); if (((Component)other).gameObject.TryGetComponent<PlayerControllerB>(ref val) && (Object)(object)val == (Object)(object)GameNetworkManager.Instance.localPlayerController) { targetFogWeight = lowFogWeight; } } private void OnTriggerExit(Collider other) { PlayerControllerB val = default(PlayerControllerB); if (((Component)other).gameObject.TryGetComponent<PlayerControllerB>(ref val) && (Object)(object)val == (Object)(object)GameNetworkManager.Instance.localPlayerController) { targetFogWeight = highFogWeight; } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected internal override string __getTypeName() { return "ShrineBuilding"; } } public class ShrineManager : NetworkBehaviour { public static Dictionary<string, GameObject> Objects; public static GameObject newspaper; public static GameObject note; public static Animator sukimaAnimator; private void Awake() { TouhouCompanyPlugin.Instance.AddLog("Awaking ShrineManager"); Objects = new Dictionary<string, GameObject>(); newspaper = null; note = null; sukimaAnimator = null; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); TouhouCompanyPlugin.Instance.AddLog("ShrineManager is awake"); } public void Destroy() { if (((NetworkBehaviour)this).IsServer) { DespawnShrineServerRpc(); GameObject obj = newspaper; if (obj != null) { obj.GetComponent<NetworkObject>().Despawn(true); } GameObject obj2 = note; if (obj2 != null) { obj2.GetComponent<NetworkObject>().Despawn(true); } } } [ServerRpc] public void SpawnShrineServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Invalid comparison between Unknown and I4 //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Invalid comparison between Unknown and I4 //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } return; } ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2162103487u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2162103487u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { TouhouCompanyPlugin.Instance.AddLog("Running SpawnShrineServerRpc"); Objects.Add("Shrine", Spawn(TouhouCompanyPlugin.HakureiShrinePrefeb, new Vector3(-28f, -1.9498372f, -96.44496f), Quaternion.Euler(270f, 90f, 0f), new Vector3(1.7513003f, 1.7513002f, 1.7513001f))); if ((Object)(object)newspaper == (Object)null) { newspaper = Spawn(TouhouCompanyPlugin.NewspaperPrefeb, new Vector3(-42.604f, -0.8589f, -34.657f), Quaternion.Euler(0f, 90f, 180f), new Vector3(0.36530885f, 0.3653086f, 0.36530864f)); } if ((Object)(object)note == (Object)null) { note = Spawn(TouhouCompanyPlugin.NotePrefeb, new Vector3(-37.24687f, 0.43543386f, -36.885f), Quaternion.Euler(-3f, 270f, 0f), new Vector3(0.18259469f, 0.9129729f, 0.18259466f)); } EnableShrineCompanyClientRpc(Objects["Shrine"].GetComponent<NetworkObject>().NetworkObjectId); } } public static GameObject Spawn(GameObject prefeb, Vector3 location, Quaternion rotation, Vector3 scale) { //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_0030: Unknown result type (might be due to invalid IL or missing references) TouhouCompanyPlugin.Instance.AddLog("Instantiating " + ((Object)prefeb).name + "..."); GameObject val = Object.Instantiate<GameObject>(prefeb, location, rotation); val.transform.localScale = scale; NetworkObject component = val.GetComponent<NetworkObject>(); if ((Object)(object)component != (Object)null) { component.Spawn(false); TouhouCompanyPlugin.Instance.AddLog(((Object)val).name + " NetworkObject spawned."); } else { TouhouCompanyPlugin.Instance.AddLog(((Object)val).name + "NetworkObject could not be spawned."); } return val; } [ClientRpc] public void EnableShrineCompanyClientRpc(ulong shrineId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_068d: Unknown result type (might be due to invalid IL or missing references) //IL_06a9: Unknown result type (might be due to invalid IL or missing references) //IL_06c5: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Expected O, but got Unknown //IL_0564: Unknown result type (might be due to invalid IL or missing references) //IL_056b: Expected O, but got Unknown NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2617659191u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, shrineId); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2617659191u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } TouhouCompanyPlugin.Instance.AddLog("Running EnableShrineCompanyClientRpc"); NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(shrineId, out var value); ((Behaviour)((Component)((Component)value).transform).GetComponent<Animator>()).enabled = false; Scene sceneByName = SceneManager.GetSceneByName("CompanyBuilding"); GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects(); try { GameObject[] array = rootGameObjects; foreach (GameObject val3 in array) { TouhouCompanyPlugin.Instance.AddLog("Processing " + ((Object)val3).name + " on CompanyBuilding."); switch (((Object)val3).name) { case "Systems": if (TouhouCompanyPlugin.EnableSkyBoxReplace.Value && (Object)(object)TouhouCompanyPlugin.SkyBoxPrefeb != (Object)null) { Transform val6 = val3.transform.Find("Rendering"); GameObject val7 = Object.Instantiate<GameObject>(TouhouCompanyPlugin.SkyBoxPrefeb, val6); TouhouCompanyPlugin.Instance.AddLog("Init SkyBox."); } break; case "CompanyMonstersAnims": { Transform val8 = val3.transform.Find("TentacleAnimContainer/GrossTentacle/BezierCurve"); Transform val9 = val3.transform.Find("TentacleAnimContainer/GrossTentacle2/BezierCurve"); ((Renderer)((Component)val8).GetComponent<SkinnedMeshRenderer>()).enabled = false; ((Renderer)((Component)val9).GetComponent<SkinnedMeshRenderer>()).enabled = false; TouhouCompanyPlugin.Instance.AddLog("Disable Tentacles."); break; } case "Cube": Object.Destroy((Object)(object)val3); TouhouCompanyPlugin.Instance.AddLog("Destroy Cube."); break; case "DepositCounter": { Object.Destroy((Object)(object)((Component)val3.transform.Find("SpeakerBox")).gameObject); Object.Destroy((Object)(object)((Component)val3.transform.Find("TinyCamera (1)")).gameObject); Transform val10 = val3.transform.Find("DoorAndHookAnim"); ((Collider)((Component)val10).GetComponent<BoxCollider>()).isTrigger = true; Transform val11 = val10.Find("DepositCounterDoor (1)"); ((Renderer)((Component)val11).GetComponent<MeshRenderer>()).enabled = false; Transform val12 = val10.Find("InteractCube"); val12.localPosition = new Vector3(53.063f, -8.747f, 21.462f); val12.localScale = new Vector3(0.93f, 1.4f, 0.75f); InteractTrigger component3 = ((Component)val12).GetComponent<InteractTrigger>(); component3.hoverTip = "Donate item : [LMB]"; sukimaAnimator = ((value != null) ? ((Component)((Component)value).transform.Find("HakureiShrine/Armature/Book殿_Parent")).GetComponent<Animator>() : null); AudioSource component4 = ((Component)val3.transform.Find("Audios/SpeakerAudio")).GetComponent<AudioSource>(); TouhouCompanyPlugin.Instance.AddLog("Disable DepositCounter."); break; } case "Plane": Object.Destroy((Object)(object)val3); TouhouCompanyPlugin.Instance.AddLog("Destroy Plane."); break; case "Environment": { Transform val13 = val3.transform.Find("Map/ShippingContainers"); foreach (Transform item in val13) { Transform val14 = item; bool flag; switch (((Object)val14).name) { case "ShippingContainer": case "ShippingContainer (1)": case "ShippingContainer (3)": case "ShippingContainer (4)": flag = true; break; default: flag = false; break; } if (flag) { Object.Destroy((Object)(object)((Component)val14).gameObject); } } TouhouCompanyPlugin.Instance.AddLog("Destroy ShippingContainers."); Transform val15 = val3.transform.Find("Map/CompanyPlanet/Cube.003"); Object.Destroy((Object)(object)((Component)val15).gameObject); TouhouCompanyPlugin.Instance.AddLog("Destroy Cube.003."); Transform val16 = val3.transform.Find("LightsContainer"); foreach (Transform item2 in val16) { Transform val17 = item2; bool flag; switch (((Object)val17).name) { case "LEDHangingLight (2)": case "LEDHangingLight (3)": case "LEDHangingLight (4)": flag = true; break; default: flag = false; break; } if (flag) { Object.Destroy((Object)(object)((Component)val17).gameObject); } } TouhouCompanyPlugin.Instance.AddLog("Destroy HangingLights."); break; } case "BellDinger": { ((Renderer)((Component)val3.transform.Find("BellDingerAnimContainer/BellTop")).GetComponent<MeshRenderer>()).enabled = false; ((Renderer)((Component)val3.transform.Find("BellDingerAnimContainer/Stand")).GetComponent<MeshRenderer>()).enabled = false; Transform val4 = val3.transform.Find("Trigger"); ((Collider)((Component)val4).GetComponent<BoxCollider>()).isTrigger = true; Transform val5 = ((value != null) ? ((Component)value).transform.Find("HakureiShrine/铃/BellTrigger") : null); if ((Object)(object)val5 != (Object)null) { val4.localPosition = new Vector3(2.304908f, 1.9572053f, -1.7881355f); val4.localRotation = Quaternion.Euler(270f, 270f, 0f); val4.localScale = new Vector3(0.17513005f, 0.20139953f, 3.9404252f); AnimatedObjectTrigger component = ((Component)val4).GetComponent<AnimatedObjectTrigger>(); AnimatedObjectTrigger component2 = ((Component)val5).GetComponent<AnimatedObjectTrigger>(); component.triggerAnimator = component2.triggerAnimator; component.boolFalseAudios = component2.boolFalseAudios; TouhouCompanyPlugin.Instance.AddLog("BellTrigger changed."); } TouhouCompanyPlugin.Instance.AddLog("Disable Bell."); break; } } } } catch (Exception arg) { TouhouCompanyPlugin.Instance.AddLog($"An error occured when replacing the CompanyBuilding: {arg}"); } } [ServerRpc] public void DespawnShrineServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Invalid comparison between Unknown and I4 //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Invalid comparison between Unknown and I4 NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } return; } ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(153946479u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 153946479u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost)) { return; } foreach (KeyValuePair<string, GameObject> @object in Objects) { GameObject value = @object.Value; if (value != null) { value.GetComponent<NetworkObject>().Despawn(true); } } Objects.Clear(); } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_ShrineManager() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(2162103487u, new RpcReceiveHandler(__rpc_handler_2162103487)); NetworkManager.__rpc_func_table.Add(2617659191u, new RpcReceiveHandler(__rpc_handler_2617659191)); NetworkManager.__rpc_func_table.Add(153946479u, new RpcReceiveHandler(__rpc_handler_153946479)); } private static void __rpc_handler_2162103487(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_0055: Invalid comparison between Unknown and I4 NetworkManager networkManager = target.NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } } else { target.__rpc_exec_stage = (__RpcExecStage)1; ((ShrineManager)(object)target).SpawnShrineServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2617659191(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ulong shrineId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref shrineId); target.__rpc_exec_stage = (__RpcExecStage)2; ((ShrineManager)(object)target).EnableShrineCompanyClientRpc(shrineId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_153946479(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_0055: Invalid comparison between Unknown and I4 NetworkManager networkManager = target.NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } } else { target.__rpc_exec_stage = (__RpcExecStage)1; ((ShrineManager)(object)target).DespawnShrineServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "ShrineManager"; } } [BepInPlugin("com.bean.TouhouCompany", "TouhouCompany", "0.0.2")] public class TouhouCompanyPlugin : BaseUnityPlugin { public static TouhouCompanyPlugin Instance; public static GameObject YukuriPrefeb; public static AudioClip YukuriAudio; internal static ConfigEntry<bool> EnableYukuriReplace; internal static ConfigEntry<bool> EnableYukuriAudio; internal static ConfigEntry<float> YukuriAudioVolume; public static GameObject ShanghaiPrefeb; internal static ConfigEntry<bool> EnableShanghaiReplace; public static GameObject MoriyaShrinePrefeb; public static AudioClip NitoriTheme; public static AudioClip NitoriThemeFar; internal static ConfigEntry<bool> EnableMoriyaReplace; internal static ConfigEntry<bool> EnableNitoriTheme; internal static ConfigEntry<float> NitoriThemeVolume; public static GameObject HakureiShrinePrefeb; public static GameObject NewspaperPrefeb; public static GameObject NotePrefeb; internal static ConfigEntry<bool> EnableHakureiReplace; public static GameObject SkyBoxPrefeb; internal static ConfigEntry<bool> EnableSkyBoxReplace; public static AudioMixer TuneMixer; public static GameObject KoumakanPrefeb; internal static ConfigEntry<bool> EnableKoumakanReplace; public static GameObject HangarShipPrefeb; internal static ConfigEntry<bool> EnableHangarShipReplace; private void Awake() { Instance = this; ((BaseUnityPlugin)this).Logger.LogInfo((object)" ______ ____ __ __ __ __ ____ __ __"); ((BaseUnityPlugin)this).Logger.LogInfo((object)" /_ __// __ \\ / / / // / / // __ \\ / / / /"); ((BaseUnityPlugin)this).Logger.LogInfo((object)" / / / / / // / / // /_/ // / / // / / / "); ((BaseUnityPlugin)this).Logger.LogInfo((object)" / / / /_/ // /_/ // __ // /_/ // /_/ / "); ((BaseUnityPlugin)this).Logger.LogInfo((object)"/_/ \\____/ \\____//_/ /_/ \\____/ \\____/ "); ((BaseUnityPlugin)this).Logger.LogInfo((object)""); EnableYukuriReplace = ((BaseUnityPlugin)this).Config.Bind<bool>("1.Pumpkin", "EnableYukuriReplace", true, "Replace the model of Jack'o Lantern to YukuriReimu."); EnableYukuriAudio = ((BaseUnityPlugin)this).Config.Bind<bool>("1.Pumpkin", "EnableYukuriAudio", true, "Replace the audio to \"Yukuri\"."); YukuriAudioVolume = ((BaseUnityPlugin)this).Config.Bind<float>("1.Pumpkin", "YukuriAudioVolume(0.0-1.0)", 0.3f, "Config the volume of \"Yukuri\"."); EnableShanghaiReplace = ((BaseUnityPlugin)this).Config.Bind<bool>("2.PJMan", "EnableShanghaiReplace", true, "Replace the PJMan with 上海人形."); EnableMoriyaReplace = ((BaseUnityPlugin)this).Config.Bind<bool>("3.ItemShip", "EnableMoriyaReplace", true, "Replace the Item Ship with Moriya Shrine."); EnableNitoriTheme = ((BaseUnityPlugin)this).Config.Bind<bool>("3.ItemShip", "EnableNitoriTheme", true, "Replace the default music to Nitori's theme music."); NitoriThemeVolume = ((BaseUnityPlugin)this).Config.Bind<float>("3.ItemShip", "NitoriThemeVolume(0.0-1.0)", 1f, "Config the volume of Nitori's theme music."); EnableHakureiReplace = ((BaseUnityPlugin)this).Config.Bind<bool>("4.CompanyBuilding", "EnableHakureiReplace", true, "Replace the Company Building with Hakurei Shrine."); EnableSkyBoxReplace = ((BaseUnityPlugin)this).Config.Bind<bool>("4.CompanyBuilding", "EnableSkyBoxReplace", true, "Replace the SkyBox."); EnableKoumakanReplace = ((BaseUnityPlugin)this).Config.Bind<bool>("5.March", "EnableKoumakanReplace", true, "Replace the March Building with Koumakan."); EnableHangarShipReplace = ((BaseUnityPlugin)this).Config.Bind<bool>("6.HangarShip", "EnableHangarShipReplace", false, "Replace the HangarShip with 圣辇船. This is not finished. Not recommend."); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Patching all functions."); NetcodeWeaver(); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"All systems ready, begin loading assets."); try { string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); if (directoryName == null) { return; } string text = Path.Combine(directoryName, "shipassets"); AssetBundle val = AssetBundle.LoadFromFile(text); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Loading asset bundle."); if ((Object)(object)val == (Object)null) { return; } if (EnableYukuriReplace.Value) { YukuriPrefeb = val.LoadAsset<GameObject>("YukuriUnlockableContainer.prefab"); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load Yukuri: {(Object)(object)YukuriPrefeb != (Object)null}"); if (EnableYukuriAudio.Value) { YukuriAudio = val.LoadAsset<AudioClip>("yukuri.ogg"); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load YukuriAudio: {(Object)(object)YukuriAudio != (Object)null}"); } } if (EnableShanghaiReplace.Value) { ShanghaiPrefeb = val.LoadAsset<GameObject>("上海人形Container.prefab"); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load Shanghai: {(Object)(object)ShanghaiPrefeb != (Object)null}"); } if (EnableMoriyaReplace.Value) { MoriyaShrinePrefeb = val.LoadAsset<GameObject>("守矢.prefab"); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load Moriya: {(Object)(object)MoriyaShrinePrefeb != (Object)null}"); if (EnableNitoriTheme.Value) { NitoriTheme = val.LoadAsset<AudioClip>("Nitori.mp3"); NitoriThemeFar = val.LoadAsset<AudioClip>("NitoriFar.mp3"); ((BaseUnityPlugin)this).Logger.LogInfo((object)($"Load NitoriTheme: {(Object)(object)NitoriTheme != (Object)null}, " + $"NitoriThemeFar: {(Object)(object)NitoriThemeFar != (Object)null}")); } } if (EnableHakureiReplace.Value) { HakureiShrinePrefeb = val.LoadAsset<GameObject>("Shrine.prefab"); HakureiShrinePrefeb.AddComponent<ShrineBuilding>(); NewspaperPrefeb = val.LoadAsset<GameObject>("Newspaper.prefab"); NotePrefeb = val.LoadAsset<GameObject>("Note.prefab"); TuneMixer = val.LoadAsset<AudioMixer>("Tuner"); ((BaseUnityPlugin)this).Logger.LogInfo((object)($"Load Hakurei: {(Object)(object)HakureiShrinePrefeb != (Object)null}, " + $"Newspaper: {(Object)(object)NewspaperPrefeb != (Object)null}, " + $"Note: {(Object)(object)NotePrefeb != (Object)null}," + $"TuneMixer: {(Object)(object)TuneMixer != (Object)null}")); if (EnableSkyBoxReplace.Value) { SkyBoxPrefeb = val.LoadAsset<GameObject>("SkyBox.prefab"); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load SkyBox: {(Object)(object)SkyBoxPrefeb != (Object)null}"); } } if (EnableKoumakanReplace.Value) { KoumakanPrefeb = val.LoadAsset<GameObject>("Koumakan.prefab"); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load Koumakan: {(Object)(object)KoumakanPrefeb != (Object)null}"); } if (EnableHangarShipReplace.Value) { HangarShipPrefeb = val.LoadAsset<GameObject>("圣辇船.prefab"); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Load HangarShip: {(Object)(object)HangarShipPrefeb != (Object)null}"); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load assetbundle: " + ex.Message)); } } private void Start() { try { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Start is good."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Start not good." + ex.Message)); } } public void AddLog(string info) { ((BaseUnityPlugin)this).Logger.LogInfo((object)info); } private static void NetcodeWeaver() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); foreach (Type type in types) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0) { methodInfo.Invoke(null, null); } } } } } public static class PluginInfo { public const string PLUGIN_GUID = "TouhouCompany"; public const string PLUGIN_NAME = "TouhouCompany"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace TouhouCompany.Patches { [HarmonyPatch(typeof(AutoParentToShip))] internal class AutoParentToShipPatch { [HarmonyPostfix] [HarmonyPatch("Awake")] private static void ReplaceUnlockable(AutoParentToShip __instance) { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) string name = ((Object)((Component)__instance).transform).name; if (name.Contains("PumpkinUnlockableContainer") && (Object)(object)TouhouCompanyPlugin.YukuriPrefeb != (Object)null && TouhouCompanyPlugin.EnableYukuriReplace.Value) { try { Transform obj = ((Component)__instance).transform.Find("PumpkinMesh"); MeshRenderer val = ((obj != null) ? ((Component)obj).GetComponent<MeshRenderer>() : null); if (!((Object)(object)val == (Object)null)) { ((Renderer)val).enabled = false; PlaceableShipObject component = ((Component)((Component)__instance).transform.Find("PlacementCollider")).GetComponent<PlaceableShipObject>(); AnimatedObjectTrigger component2 = ((Component)((Component)__instance).transform.Find("HitPumpkinTrigger")).GetComponent<AnimatedObjectTrigger>(); Transform val2 = Object.Instantiate<GameObject>(TouhouCompanyPlugin.YukuriPrefeb).transform.Find("Yukuri"); val2.SetParent(((Component)__instance).transform); ((Component)val2).transform.localPosition = ((Component)val).transform.localPosition; ((Component)val2).transform.localRotation = ((Component)val).transform.localRotation; ((Component)val2).transform.localScale = Vector3.one; component.mainMesh = ((Component)val2).GetComponent<MeshFilter>(); component2.boolFalseAudios[0] = TouhouCompanyPlugin.YukuriAudio; TouhouCompanyPlugin.Instance.AddLog("Replaced the Pumpkin."); } return; } catch { TouhouCompanyPlugin.Instance.AddLog("Failed to replace the Pumpkin."); return; } } if (!name.Contains("PlushiePJManContainer") || !((Object)(object)TouhouCompanyPlugin.ShanghaiPrefeb != (Object)null) || !TouhouCompanyPlugin.EnableShanghaiReplace.Value) { return; } try { Transform obj3 = ((Component)__instance).transform.Find("PJManPlush"); MeshRenderer val3 = ((obj3 != null) ? ((Component)obj3).GetComponent<MeshRenderer>() : null); if (!((Object)(object)val3 == (Object)null)) { ((Renderer)val3).enabled = false; PlaceableShipObject component3 = ((Component)((Component)__instance).transform.Find("PlacementCollider")).GetComponent<PlaceableShipObject>(); AnimatedObjectTrigger component4 = ((Component)((Component)__instance).transform.Find("TouchTrigger")).GetComponent<AnimatedObjectTrigger>(); Transform val4 = Object.Instantiate<GameObject>(TouhouCompanyPlugin.ShanghaiPrefeb).transform.Find("PJManPlush"); val4.SetParent(((Component)__instance).transform); ((Component)val4).transform.localPosition = ((Component)val3).transform.localPosition; ((Component)val4).transform.localRotation = ((Component)val3).transform.localRotation; ((Component)val4).transform.localScale = ((Component)val3).transform.localScale; component3.mainMesh = ((Component)val4).GetComponent<MeshFilter>(); component4.triggerAnimator = ((Component)val4).GetComponent<Animator>(); TouhouCompanyPlugin.Instance.AddLog("Replaced the Plushie."); } } catch { TouhouCompanyPlugin.Instance.AddLog("Failed to replace the Plushie."); } } } [HarmonyPatch(typeof(GameNetworkManager))] internal class GameNetworkManagerPatch { [HarmonyPatch("Start")] [HarmonyPostfix] public static void StartPatch(GameNetworkManager __instance) { TouhouCompanyPlugin.Instance.AddLog("Adding network prefab"); NetworkManager.Singleton.AddNetworkPrefab(TouhouCompanyPlugin.HakureiShrinePrefeb); NetworkManager.Singleton.AddNetworkPrefab(TouhouCompanyPlugin.NewspaperPrefeb); NetworkManager.Singleton.AddNetworkPrefab(TouhouCompanyPlugin.NotePrefeb); } [HarmonyPostfix] [HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")] public static void StartDisconnectPatch() { TouhouCompanyPlugin.Instance.AddLog("Player disconnected."); } } [HarmonyPatch] internal class InitializeGamePatches { [HarmonyPrefix] [HarmonyPatch(typeof(InitializeGame), "Start")] public static void startInitializeGame(InitializeGame __instance) { if (TouhouCompanyPlugin.EnableHakureiReplace.Value && (Object)(object)TouhouCompanyPlugin.HakureiShrinePrefeb != (Object)null) { try { __instance.playColdOpenCinematic = true; } catch (Exception arg) { TouhouCompanyPlugin.Instance.AddLog($"An error occured when startInitializeGame: {arg}"); } } } [HarmonyPrefix] [HarmonyPatch(typeof(ColdOpenCinematicCutscene), "Start")] public static void startColdOpenCinematic(ColdOpenCinematicCutscene __instance) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Unknown result type (might be due to invalid IL or missing references) //IL_059f: Unknown result type (might be due to invalid IL or missing references) //IL_05c0: Unknown result type (might be due to invalid IL or missing references) if (!TouhouCompanyPlugin.EnableHakureiReplace.Value || !((Object)(object)TouhouCompanyPlugin.HakureiShrinePrefeb != (Object)null)) { return; } try { Scene sceneByName = SceneManager.GetSceneByName("ColdOpen1"); GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects(); GameObject[] array = rootGameObjects; foreach (GameObject val in array) { TouhouCompanyPlugin.Instance.AddLog("Processing " + ((Object)val).name + " on ColdOpen1."); switch (((Object)val).name) { case "ColdOpenMonitorRoom": case "DoorFrame": case "ComputerChairAndShelf": val.SetActive(false); TouhouCompanyPlugin.Instance.AddLog("Disable " + ((Object)val).name + "."); break; case "Systems": if (TouhouCompanyPlugin.EnableSkyBoxReplace.Value && (Object)(object)TouhouCompanyPlugin.SkyBoxPrefeb != (Object)null) { Transform val4 = val.transform.Find("Rendering"); GameObject val5 = Object.Instantiate<GameObject>(TouhouCompanyPlugin.SkyBoxPrefeb, val4); TouhouCompanyPlugin.Instance.AddLog("Init SkyBox."); } break; case "Plane": val.transform.localPosition = new Vector3(-20.424732f, 10.964f, -2.058f); TouhouCompanyPlugin.Instance.AddLog("Set " + ((Object)val).name + "."); break; case "ColdOpen1AnimContainer": { Transform val2 = val.transform.Find("Cube.005"); ((Renderer)((Component)val2).GetComponent<MeshRenderer>()).enabled = false; TouhouCompanyPlugin.Instance.AddLog("Disable " + ((Object)val2).name + "."); val2 = val.transform.Find("MiscProps3/CurtainRod (2)"); val2.localPosition = new Vector3(-15.71f, 7.64701f, -23.859324f); TouhouCompanyPlugin.Instance.AddLog("Set " + ((Object)val2).name + "."); val2 = val.transform.Find("MiscProps3/Cylinder.001 (1)"); val2.localPosition = new Vector3(-13.64f, 2.527f, -8.006232f); TouhouCompanyPlugin.Instance.AddLog("Set " + ((Object)val2).name + "."); val2 = val.transform.Find("MiscProps3/FancyDesk"); ((Renderer)((Component)val2).GetComponent<MeshRenderer>()).enabled = false; TouhouCompanyPlugin.Instance.AddLog("Disable " + ((Object)val2).name + "."); val2 = val.transform.Find("MiscProps3/PottedPlant"); ((Renderer)((Component)val2).GetComponent<MeshRenderer>()).enabled = false; TouhouCompanyPlugin.Instance.AddLog("Disable " + ((Object)val2).name + "."); val2 = val.transform.Find("MiscProps3/Cube.002"); ((Component)val2).gameObject.SetActive(false); TouhouCompanyPlugin.Instance.AddLog("Disable " + ((Object)val2).name + "."); val2 = val.transform.Find("Door"); ((Component)val2).gameObject.SetActive(false); TouhouCompanyPlugin.Instance.AddLog("Disable " + ((Object)val2).name + "."); val2 = val.transform.Find("Lamp"); ((Component)val2).gameObject.SetActive(false); TouhouCompanyPlugin.Instance.AddLog("Disable " + ((Object)val2).name + "."); val2 = val.transform.Find("Remote"); ((Renderer)((Component)val2).GetComponent<MeshRenderer>()).enabled = false; TouhouCompanyPlugin.Instance.AddLog("Disable " + ((Object)val2).name + "."); val2 = val.transform.Find("ShipModels2b"); ((Component)val2).gameObject.SetActive(false); TouhouCompanyPlugin.Instance.AddLog("Disable " + ((Object)val2).name + "."); val2 = val.transform.Find("Desk"); ((Renderer)((Component)val2).GetComponent<MeshRenderer>()).enabled = false; TouhouCompanyPlugin.Instance.AddLog("Disable " + ((Object)val2).name + "."); val2 = val.transform.Find("DeskAddonComponent"); ((Renderer)((Component)val2).GetComponent<MeshRenderer>()).enabled = false; TouhouCompanyPlugin.Instance.AddLog("Disable " + ((Object)val2).name + "."); GameObject val3 = Object.Instantiate<GameObject>(TouhouCompanyPlugin.HakureiShrinePrefeb); Object.Destroy((Object)(object)val3.GetComponent<NetworkObject>()); Object.Destroy((Object)(object)val3.GetComponent<ShrineBuilding>()); OccludeAudio componentInChildren = ((Component)val3.transform.Find("HakureiShrine/Body/RecordPlayerContainer/Audio")).GetComponentInChildren<OccludeAudio>(); Object.Destroy((Object)(object)componentInChildren); componentInChildren = ((Component)val3.transform.Find("HakureiShrine/Body/TelevisionContainer/TVAudio")).GetComponentInChildren<OccludeAudio>(); Object.Destroy((Object)(object)componentInChildren); componentInChildren = ((Component)val3.transform.Find("HakureiShrine/Armature/土Interval_Parent/Toilet/Cube")).GetComponentInChildren<OccludeAudio>(); Object.Destroy((Object)(object)componentInChildren); val3.transform.position = new Vector3(4.1f, 7.198653f, -85.7f); val3.transform.rotation = Quaternion.Euler(270f, 90f, 0f); val3.transform.localScale = new Vector3(2.5f, 2.5f, 2.5f); TouhouCompanyPlugin.Instance.AddLog("Enable Shrine."); break; } } } } catch (Exception arg) { TouhouCompanyPlugin.Instance.AddLog($"An error occured when startColdOpenCinematic: {arg}"); } } [HarmonyPrefix] [HarmonyPatch(typeof(ColdOpenCinematicCutscene), "Update")] public static void updateColdOpenCinematic(ColdOpenCinematicCutscene __instance) { if (!TouhouCompanyPlugin.EnableHakureiReplace.Value || !((Object)(object)TouhouCompanyPlugin.HakureiShrinePrefeb != (Object)null)) { return; } try { if (((ButtonControl)Keyboard.current.escapeKey).wasPressedThisFrame) { __instance.EndColdOpenCutscene(); } } catch (Exception arg) { TouhouCompanyPlugin.Instance.AddLog($"An error occured when updateColdOpenCinematic: {arg}"); } } } [HarmonyPatch(typeof(ItemDropship))] internal class ItemDropshipPatch { [HarmonyPrefix] [HarmonyPatch("Start")] private static void ReplaceItemShip(ItemDropship __instance) { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)TouhouCompanyPlugin.MoriyaShrinePrefeb != (Object)null) || !TouhouCompanyPlugin.EnableMoriyaReplace.Value) { return; } try { ((Collider)((Component)((Component)__instance).transform).GetComponent<BoxCollider>()).enabled = false; Transform val = ((Component)__instance).transform.Find("ItemShip"); ((Renderer)((Component)val).GetComponent<MeshRenderer>()).enabled = false; for (int i = 0; i < val.childCount; i++) { Transform child = val.GetChild(i); if (((Object)child).name.Contains("Door")) { ((Renderer)((Component)child).GetComponent<MeshRenderer>()).enabled = false; } } TouhouCompanyPlugin.Instance.AddLog("Hide ItemDropship model."); GameObject val2 = Object.Instantiate<GameObject>(TouhouCompanyPlugin.MoriyaShrinePrefeb); val2.transform.SetParent(val); val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = new Vector3(0.77f, 0.77f, 0.77f); Transform val3 = val.Find("Point Light"); val3.localPosition = new Vector3(0.037f, 0f, 1.75f); TouhouCompanyPlugin.Instance.AddLog("ItemDropship model replaced."); if (TouhouCompanyPlugin.EnableNitoriTheme.Value && (Object)(object)TouhouCompanyPlugin.NitoriTheme != (Object)null && (Object)(object)TouhouCompanyPlugin.NitoriThemeFar != (Object)null) { Transform val4 = ((Component)__instance).transform.Find("Music"); AudioSource component = ((Component)val4).GetComponent<AudioSource>(); component.clip = TouhouCompanyPlugin.NitoriTheme; component.volume = TouhouCompanyPlugin.NitoriThemeVolume.Value; val4 = val4.Find("Music (1)"); component = ((Component)val4).GetComponent<AudioSource>(); component.clip = TouhouCompanyPlugin.NitoriThemeFar; component.volume = TouhouCompanyPlugin.NitoriThemeVolume.Value; TouhouCompanyPlugin.Instance.AddLog("NitoriTheme replaced."); } } catch (Exception arg) { TouhouCompanyPlugin.Instance.AddLog($"An error occured when replacing the ItemDropship: {arg}"); } } } [HarmonyPatch] internal class OtherPatches { [HarmonyPrefix] [HarmonyPatch(typeof(DepositItemsDesk), "OpenShutDoor")] public static void AngryMeshFix(DepositItemsDesk __instance, bool open) { if (!TouhouCompanyPlugin.EnableHakureiReplace.Value || !((Object)(object)TouhouCompanyPlugin.HakureiShrinePrefeb != (Object)null)) { return; } try { Animator sukimaAnimator = ShrineManager.sukimaAnimator; if (sukimaAnimator != null) { sukimaAnimator.SetBool("doorOpen", open); } } catch (Exception arg) { TouhouCompanyPlugin.Instance.AddLog($"An error occured when enable Sukima: {arg}"); } } [HarmonyPrefix] [HarmonyPatch(typeof(DepositItemsDesk), "Attack")] public static void AngryMeshFix(DepositItemsDesk __instance) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!TouhouCompanyPlugin.EnableHakureiReplace.Value || !((Object)(object)TouhouCompanyPlugin.HakureiShrinePrefeb != (Object)null)) { return; } try { Scene sceneByName = SceneManager.GetSceneByName("CompanyBuilding"); GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects(); GameObject[] array = rootGameObjects; foreach (GameObject val in array) { TouhouCompanyPlugin.Instance.AddLog("Processing " + ((Object)val).name + "."); string name = ((Object)val).name; string text = name; if (text == "CompanyMonstersAnims") { Transform val2 = val.transform.Find("TentacleAnimContainer/GrossTentacle/BezierCurve"); Transform val3 = val.transform.Find("TentacleAnimContainer/GrossTentacle2/BezierCurve"); ((Renderer)((Component)val2).GetComponent<SkinnedMeshRenderer>()).enabled = true; ((Renderer)((Component)val3).GetComponent<SkinnedMeshRenderer>()).enabled = true; TouhouCompanyPlugin.Instance.AddLog("Enable Tentacles."); } } } catch (Exception arg) { TouhouCompanyPlugin.Instance.AddLog($"An error occured when enable CompanyMonster: {arg}"); } } [HarmonyPrefix] [HarmonyPatch(typeof(PlayerControllerB), "SetObjectAsNoLongerHeld")] public static bool TestNoLongerHeld(bool droppedInElevator, bool droppedInShipRoom, Vector3 targetFloorPosition, GrabbableObject dropObject, int floorYRot, PlayerControllerB __instance) { //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) TouhouCompanyPlugin.Instance.AddLog("TestNoLongerHeld: " + ((Object)dropObject).name + "."); if (((Object)dropObject).name != "Note(Clone)" && ((Object)dropObject).name != "Newspaper(Clone)") { TouhouCompanyPlugin.Instance.AddLog("Not processing."); return true; } for (int i = 0; i < __instance.ItemSlots.Length; i++) { if ((Object)(object)__instance.ItemSlots[i] == (Object)(object)dropObject) { __instance.ItemSlots[i] = null; } } dropObject.heldByPlayerOnServer = false; dropObject.parentObject = null; if (((NetworkBehaviour)__instance).IsServer) { if (droppedInElevator) { ((Component)dropObject).transform.SetParent(__instance.playersManager.elevatorTransform, true); } else { ((Component)dropObject).transform.SetParent(__instance.playersManager.propsContainer, true); } } __instance.SetItemInElevator(droppedInShipRoom, droppedInElevator, dropObject); dropObject.EnablePhysics(true); dropObject.EnableItemMeshes(true); ((Component)dropObject).transform.localScale = dropObject.originalScale; dropObject.isHeld = false; dropObject.isPocketed = false; dropObject.fallTime = 0f; if ((Object)(object)((Component)dropObject).transform.parent != (Object)null) { dropObject.startFallingPosition = ((Component)dropObject).transform.parent.InverseTransformPoint(((Component)dropObject).transform.position); } dropObject.targetFloorPosition = targetFloorPosition; dropObject.floorYRot = floorYRot; __instance.twoHanded = false; __instance.twoHandedAnimation = false; __instance.carryWeight -= Mathf.Clamp(dropObject.itemProperties.weight - 1f, 0f, 10f); __instance.isHoldingObject = false; Type type = ((object)__instance).GetType(); FieldInfo field = type.GetField("hasThrownObject", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(__instance, true); } TouhouCompanyPlugin.Instance.AddLog("Replaced method TestNoLongerHeld()."); return false; } } [HarmonyPatch(typeof(RoundManager))] internal class RoundManagerPatch : NetworkBehaviour { public static ShrineManager ShrineManager; public static KoumakanManager KoumakanManager; [HarmonyPatch("Awake")] [HarmonyPostfix] public static void AwakePatch(RoundManager __instance) { TouhouCompanyPlugin.Instance.AddLog("RoundManagerPatch has awoken"); ShrineManager = ((Component)__instance).gameObject.AddComponent<ShrineManager>(); KoumakanManager = ((Component)__instance).gameObject.AddComponent<KoumakanManager>(); } [HarmonyPatch("LoadNewLevelWait")] [HarmonyPrefix] public static void LoadNewLevelWaitPatch(RoundManager __instance) { TouhouCompanyPlugin.Instance.AddLog($"Loading level {__instance.currentLevel.levelID}..."); if (__instance.currentLevel.levelID == 3 && TouhouCompanyPlugin.EnableHakureiReplace.Value && (Object)(object)TouhouCompanyPlugin.HakureiShrinePrefeb != (Object)null) { TouhouCompanyPlugin.Instance.AddLog("Spawning shrine objects"); ShrineManager.SpawnShrineServerRpc(); } if (__instance.currentLevel.levelID == 4 && TouhouCompanyPlugin.EnableKoumakanReplace.Value && (Object)(object)TouhouCompanyPlugin.KoumakanPrefeb != (Object)null) { TouhouCompanyPlugin.Instance.AddLog("Spawning Koumakan objects"); KoumakanManager.SpawnKoumakanServerRpc(); } } [HarmonyPatch("DespawnPropsAtEndOfRound")] [HarmonyPostfix] public static void DespawnPropsAtEndOfRoundPatch(RoundManager __instance) { TouhouCompanyPlugin.Instance.AddLog($"End level {__instance.currentLevel.levelID}..."); if (__instance.currentLevel.levelID == 3 && TouhouCompanyPlugin.EnableHakureiReplace.Value && (Object)(object)TouhouCompanyPlugin.HakureiShrinePrefeb != (Object)null) { TouhouCompanyPlugin.Instance.AddLog("Despawning shrine objects"); if (((NetworkBehaviour)ShrineManager).IsServer) { ShrineManager.DespawnShrineServerRpc(); } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected internal override string __getTypeName() { return "RoundManagerPatch"; } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { public static GameObject vanillaShip; public static GameObject newShip; [HarmonyPostfix] [HarmonyPatch("Start")] private static void StartRoundPatch() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00b6: Unknown result type (might be due to invalid IL or missing references) try { if (TouhouCompanyPlugin.EnableHangarShipReplace.Value && !((Object)(object)TouhouCompanyPlugin.HangarShipPrefeb == (Object)null) && !((Object)(object)newShip != (Object)null)) { vanillaShip = GameObject.Find("Environment/HangarShip"); newShip = Object.Instantiate<GameObject>(TouhouCompanyPlugin.HangarShipPrefeb, vanillaShip.transform); newShip.transform.localPosition = new Vector3(11.1f, 32.6f, -7.22f); newShip.transform.localRotation = Quaternion.Euler(0f, 90f, 0f); newShip.transform.localScale = Vector3.one * 3f; } } catch (Exception arg) { TouhouCompanyPlugin.Instance.AddLog($"An error occured when replacing the HangarShip: {arg}"); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace TouhouCompany.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }