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 Echohold Station Fix v3.5.0
EchoholdCompatPatch.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib; using REPOLib.Modules; using REPOLib.Objects.Sdk; using Unity.AI.Navigation; using UnityEngine; using UnityEngine.AI; using UnityEngine.Audio; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Empress")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.6.0")] [assembly: AssemblyInformationalVersion("1.0.6")] [assembly: AssemblyProduct("EchoholdCompatPatch")] [assembly: AssemblyTitle("EchoholdCompatPatch")] [assembly: AssemblyVersion("1.0.6.0")] [module: RefSafetyRules(11)] 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 EchoholdCompatPatch { [BepInPlugin("empress.repo.echoholdcompatpatch", "Empress Echohold Compat Patch", "1.0.6")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class EchoholdCompatPatchPlugin : BaseUnityPlugin { private sealed class EchoholdLoadingGraphic { public AssetBundle Bundle { get; } public Sprite Sprite { get; } public string ResourcePath { get; } public bool CanUsePrefabRef { get; } public EchoholdLoadingGraphic(AssetBundle bundle, Sprite sprite, string resourcePath, bool canUsePrefabRef) { Bundle = bundle; Sprite = sprite; ResourcePath = resourcePath; CanUsePrefabRef = canUsePrefabRef; } } private sealed class EchoholdPrefabBuckets { public List<GameObject> StartRooms { get; set; } = new List<GameObject>(); public List<GameObject> Normal1 { get; set; } = new List<GameObject>(); public List<GameObject> Passage1 { get; set; } = new List<GameObject>(); public List<GameObject> DeadEnd1 { get; set; } = new List<GameObject>(); public List<GameObject> Extraction1 { get; set; } = new List<GameObject>(); public List<GameObject> Normal2 { get; set; } = new List<GameObject>(); public List<GameObject> Passage2 { get; set; } = new List<GameObject>(); public List<GameObject> DeadEnd2 { get; set; } = new List<GameObject>(); public List<GameObject> Extraction2 { get; set; } = new List<GameObject>(); public List<GameObject> Normal3 { get; set; } = new List<GameObject>(); public List<GameObject> Passage3 { get; set; } = new List<GameObject>(); public List<GameObject> DeadEnd3 { get; set; } = new List<GameObject>(); public List<GameObject> Extraction3 { get; set; } = new List<GameObject>(); public int TotalModuleCount => Normal1.Count + Passage1.Count + DeadEnd1.Count + Extraction1.Count + Normal2.Count + Passage2.Count + DeadEnd2.Count + Extraction2.Count + Normal3.Count + Passage3.Count + DeadEnd3.Count + Extraction3.Count; } internal const string PluginGuid = "empress.repo.echoholdcompatpatch"; internal const string PluginName = "Empress Echohold Compat Patch"; internal const string PluginVersion = "1.0.6"; private const string EchoholdBundleFileName = "Echohold.repobundle"; private const string EchoholdLevelName = "Level - Echohold"; private const string EchoholdLevelResourcePath = "Echohold"; private const float EchoholdLevelPointCheckRadius = 0.5f; private const float EchoholdLevelPointRepairRadius = 2f; private const float EchoholdLevelPointConnectDistance = 15f; private const float EchoholdLevelPointConnectForwardDot = -0.8f; private const float EchoholdLevelPointConnectApproachDot = 0.8f; private const float EchoholdLevelPointValidationDelay = 0.5f; private const int EchoholdVehicleVolumeCount = 4; private const float EchoholdVehicleVolumeSideOffset = 2f; private const float EchoholdVehicleVolumeForwardOffset = 2.5f; private const float EchoholdVehicleVolumeForwardSpacing = 2f; private const float EchoholdChargingStationForwardOffset = 6.5f; private static readonly string[] EchoholdLoadingGraphicFieldNames = new string[3] { "LoadingGraphic01", "LoadingGraphic02", "LoadingGraphic03" }; private static readonly string[] EchoholdPreferredLoadingGraphicNames = new string[3] { "level arctic 01", "level arctic 02", "level arctic 03" }; private static readonly List<Sprite> EchoholdLoadingSprites = new List<Sprite>(); private static readonly string[] EchoholdStartRoomNames = new string[1] { "Start Room - Echohold - Lab" }; private static readonly string[] EchoholdNormal1Names = new string[5] { "Module - Echohold - N - 1 - Corridor 2", "Module - Echohold - N - 1 - Main Corridor", "Module - Echohold - N - 1 - Server Room", "Module - Echohold - N - 1 - Zero Gravity Lab", "Module - Echohold - N - 1 - Corridor 3" }; private static readonly string[] EchoholdPassage1Names = new string[4] { "Module - Echohold - P - 1 - Cafeteria", "Module - Echohold - P - 1 - Control Room", "Module - Echohold - P - 1 - Engine Room", "Module - Echohold - P - 1 - Science Lab" }; private static readonly string[] EchoholdDeadEnd1Names = new string[5] { "Module - Echohold - DE - 1 - Crew Quarters", "Module - Echohold - DE - 1 - Crew Quarters 2", "Module - Echohold - DE - 1 - Lab Testing", "Module - Echohold - DE - 1 - Medical Room", "Module - Echohold - DE - 1 - Storage Room" }; private static readonly string[] EchoholdExtraction1Names = new string[1] { "Module - Echohold - E - 1 - Lab" }; private readonly Harmony _echoholdHarmony = new Harmony("empress.repo.echoholdcompatpatch"); private AssetBundle? _echoholdBundle; private bool _echoholdRepairApplied; private bool _echoholdRepairQueued; private bool _echoholdItemsRepairApplied; private bool _echoholdLoggedMissingBundle; private bool _echoholdLoggedMissingPrefabs; private bool _echoholdLoggedDoorMapFallback; internal static EchoholdCompatPatchPlugin? Instance { get; private set; } private void Awake() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) Instance = this; GameObject gameObject = ((Component)this).gameObject; ((Object)gameObject).hideFlags = (HideFlags)(((Object)gameObject).hideFlags | 0x23); BundleLoader.OnAllBundlesLoaded += EchoholdHandleBundlesLoaded; _echoholdHarmony.PatchAll(); EchoholdPatchUnityWarningFilter(); if ((Object)(object)RunManager.instance != (Object)null) { ((MonoBehaviour)this).StartCoroutine(EchoholdRepairWhenReady()); } } private void EchoholdHandleBundlesLoaded() { if (_echoholdRepairQueued || _echoholdRepairApplied) { return; } _echoholdRepairQueued = true; try { EchoholdTryRepairLevel(); } finally { _echoholdRepairQueued = false; } } private void EchoholdPatchUnityWarningFilter() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown Type type = AccessTools.TypeByName("UnityEngine.DebugLogHandler"); if (!(type == null)) { MethodInfo methodInfo = AccessTools.Method(type, "LogFormat", new Type[4] { typeof(LogType), typeof(Object), typeof(string), typeof(object[]) }, (Type[])null); if (methodInfo != null) { _echoholdHarmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(EchoholdCompatPatchPlugin), "EchoholdSuppressMissingScriptWarningPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } MethodInfo methodInfo2 = AccessTools.Method(type, "LogFormat", new Type[5] { typeof(LogType), typeof(LogOption), typeof(Object), typeof(string), typeof(object[]) }, (Type[])null); if (methodInfo2 != null) { _echoholdHarmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(EchoholdCompatPatchPlugin), "EchoholdSuppressMissingScriptWarningPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } private IEnumerator EchoholdRepairWhenReady() { yield return null; for (int attempt = 0; attempt < 120; attempt++) { if (_echoholdRepairApplied) { break; } if (EchoholdTryRepairLevel()) { break; } yield return null; } _echoholdRepairQueued = false; } internal bool EchoholdTryRepairCurrentLevel() { List<Level> list = new List<Level>(); if ((Object)(object)LevelGenerator.Instance != (Object)null && (Object)(object)LevelGenerator.Instance.Level != (Object)null) { list.Add(LevelGenerator.Instance.Level); } if ((Object)(object)RunManager.instance != (Object)null && (Object)(object)RunManager.instance.levelCurrent != (Object)null) { list.Add(RunManager.instance.levelCurrent); } return EchoholdTryRepairLevel(list); } private bool EchoholdTryRepairLevel(IEnumerable<Level>? candidates = null) { if (_echoholdRepairApplied) { return true; } Level val = EchoholdFindLevel(candidates) ?? EchoholdFindLevel(Levels.AllLevels); if ((Object)(object)val == (Object)null) { return false; } AssetBundle val2 = EchoholdGetBundle(); if ((Object)(object)val2 == (Object)null) { if (!_echoholdLoggedMissingBundle) { _echoholdLoggedMissingBundle = true; ((BaseUnityPlugin)this).Logger.LogWarning((object)"Empress Echohold Compat Patch could not locate the Echohold bundle."); } return false; } _echoholdLoggedMissingBundle = false; EchoholdPrefabBuckets echoholdPrefabBuckets = EchoholdCollectPrefabs(val2); if (echoholdPrefabBuckets.StartRooms.Count == 0 || echoholdPrefabBuckets.TotalModuleCount == 0) { if (!_echoholdLoggedMissingPrefabs) { _echoholdLoggedMissingPrefabs = true; ((BaseUnityPlugin)this).Logger.LogError((object)"Empress Echohold Compat Patch could not rebuild the Echohold prefab lists from the original bundle."); } return false; } _echoholdLoggedMissingPrefabs = false; EchoholdApplyHideFlags((Object)(object)val2); EchoholdApplyHideFlags((Object)(object)val); EchoholdEnsureLevelFallbackData(val); EchoholdEnsureLevelLoadingGraphics(val, val2); EchoholdTryRepairItems(val2); EchoholdRegisterLevelObjects(val); val.StartRooms = EchoholdRegisterPrefabs(val, "StartRoom", echoholdPrefabBuckets.StartRooms); val.ModulesNormal1 = EchoholdRegisterPrefabs(val, "Normal", echoholdPrefabBuckets.Normal1); val.ModulesPassage1 = EchoholdRegisterPrefabs(val, "Passage", echoholdPrefabBuckets.Passage1); val.ModulesDeadEnd1 = EchoholdRegisterPrefabs(val, "DeadEnd", echoholdPrefabBuckets.DeadEnd1); val.ModulesExtraction1 = EchoholdRegisterPrefabs(val, "Extraction", echoholdPrefabBuckets.Extraction1); val.ModulesNormal2 = EchoholdRegisterPrefabs(val, "Normal", echoholdPrefabBuckets.Normal2); val.ModulesPassage2 = EchoholdRegisterPrefabs(val, "Passage", echoholdPrefabBuckets.Passage2); val.ModulesDeadEnd2 = EchoholdRegisterPrefabs(val, "DeadEnd", echoholdPrefabBuckets.DeadEnd2); val.ModulesExtraction2 = EchoholdRegisterPrefabs(val, "Extraction", echoholdPrefabBuckets.Extraction2); val.ModulesNormal3 = EchoholdRegisterPrefabs(val, "Normal", echoholdPrefabBuckets.Normal3); val.ModulesPassage3 = EchoholdRegisterPrefabs(val, "Passage", echoholdPrefabBuckets.Passage3); val.ModulesDeadEnd3 = EchoholdRegisterPrefabs(val, "DeadEnd", echoholdPrefabBuckets.DeadEnd3); val.ModulesExtraction3 = EchoholdRegisterPrefabs(val, "Extraction", echoholdPrefabBuckets.Extraction3); _echoholdRepairApplied = val.StartRooms.Count > 0 && EchoholdCountModules(val) > 0; if (_echoholdRepairApplied) { ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Empress Echohold Compat Patch repaired {((Object)val).name} with {val.StartRooms.Count} start rooms and {EchoholdCountModules(val)} modules."); } return _echoholdRepairApplied; } private static Level? EchoholdFindLevel(IEnumerable<Level>? candidates) { if (candidates == null) { return null; } foreach (Level candidate in candidates) { if (EchoholdIsEchoholdLevel(candidate)) { return candidate; } } return null; } private AssetBundle? EchoholdGetBundle() { if ((Object)(object)_echoholdBundle != (Object)null) { return _echoholdBundle; } foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles()) { if (EchoholdBundleMatches(allLoadedAssetBundle)) { _echoholdBundle = allLoadedAssetBundle; return _echoholdBundle; } } string text = Directory.GetFiles(Paths.PluginPath, "Echohold.repobundle", SearchOption.AllDirectories).FirstOrDefault(); if (string.IsNullOrWhiteSpace(text)) { return null; } _echoholdBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)_echoholdBundle != (Object)null) { return _echoholdBundle; } foreach (AssetBundle allLoadedAssetBundle2 in AssetBundle.GetAllLoadedAssetBundles()) { if (EchoholdBundleMatches(allLoadedAssetBundle2)) { _echoholdBundle = allLoadedAssetBundle2; return _echoholdBundle; } } return _echoholdBundle; } private static bool EchoholdBundleMatches(AssetBundle? bundle) { if ((Object)(object)bundle == (Object)null) { return false; } try { if (!string.IsNullOrWhiteSpace(((Object)bundle).name) && ((Object)bundle).name.IndexOf("echohold", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } catch { } try { if (bundle.GetAllAssetNames().Any((string assetName) => assetName.IndexOf("echohold", StringComparison.OrdinalIgnoreCase) >= 0 || assetName.EndsWith("level - echohold.asset", StringComparison.OrdinalIgnoreCase))) { return true; } } catch { } try { Level[] array = bundle.LoadAllAssets<Level>(); for (int i = 0; i < array.Length; i++) { if (EchoholdIsEchoholdLevel(array[i])) { return true; } } } catch { } try { GameObject[] array2 = bundle.LoadAllAssets<GameObject>(); foreach (GameObject val in array2) { if (!((Object)(object)val == (Object)null) && (((Object)val).name.StartsWith("Start Room - Echohold -", StringComparison.OrdinalIgnoreCase) || ((Object)val).name.StartsWith("Module - Echohold -", StringComparison.OrdinalIgnoreCase))) { return true; } } } catch { } return false; } private static EchoholdPrefabBuckets EchoholdCollectPrefabs(AssetBundle bundle) { //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, GameObject> dictionary = new Dictionary<string, GameObject>(StringComparer.OrdinalIgnoreCase); StartRoom[] array = bundle.LoadAllAssets<StartRoom>(); foreach (StartRoom val in array) { EchoholdAddAssetByName(dictionary, ((Object)(object)val != (Object)null) ? ((Component)val).gameObject : null); } Module[] array2 = bundle.LoadAllAssets<Module>(); foreach (Module val2 in array2) { EchoholdAddAssetByName(dictionary, ((Object)(object)val2 != (Object)null) ? ((Component)val2).gameObject : null); } GameObject[] array3 = bundle.LoadAllAssets<GameObject>(); foreach (GameObject prefab in array3) { EchoholdAddAssetByName(dictionary, prefab); } if (!dictionary.Keys.Any((string name) => name.StartsWith("Start Room - Echohold -", StringComparison.OrdinalIgnoreCase)) || !dictionary.Keys.Any((string name) => name.StartsWith("Module - Echohold -", StringComparison.OrdinalIgnoreCase))) { array = Resources.FindObjectsOfTypeAll<StartRoom>(); Scene scene; foreach (StartRoom val3 in array) { if (!((Object)(object)val3 == (Object)null)) { scene = ((Component)val3).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { EchoholdAddAssetByName(dictionary, ((Component)val3).gameObject); } } } array2 = Resources.FindObjectsOfTypeAll<Module>(); foreach (Module val4 in array2) { if (!((Object)(object)val4 == (Object)null)) { scene = ((Component)val4).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { EchoholdAddAssetByName(dictionary, ((Component)val4).gameObject); } } } array3 = Resources.FindObjectsOfTypeAll<GameObject>(); foreach (GameObject val5 in array3) { if (!((Object)(object)val5 == (Object)null)) { scene = val5.scene; if (!((Scene)(ref scene)).IsValid()) { EchoholdAddAssetByName(dictionary, val5); } } } } return new EchoholdPrefabBuckets { StartRooms = EchoholdResolvePrefabs(dictionary, EchoholdStartRoomNames), Normal1 = EchoholdResolvePrefabs(dictionary, EchoholdNormal1Names), Passage1 = EchoholdResolvePrefabs(dictionary, EchoholdPassage1Names), DeadEnd1 = EchoholdResolvePrefabs(dictionary, EchoholdDeadEnd1Names), Extraction1 = EchoholdResolvePrefabs(dictionary, EchoholdExtraction1Names), Normal2 = new List<GameObject>(), Passage2 = new List<GameObject>(), DeadEnd2 = new List<GameObject>(), Extraction2 = new List<GameObject>(), Normal3 = new List<GameObject>(), Passage3 = new List<GameObject>(), DeadEnd3 = new List<GameObject>(), Extraction3 = new List<GameObject>() }; } private static void EchoholdAddAssetByName(IDictionary<string, GameObject> prefabsByName, GameObject? prefab) { if (!((Object)(object)prefab == (Object)null) && !string.IsNullOrWhiteSpace(((Object)prefab).name) && !prefabsByName.ContainsKey(((Object)prefab).name)) { prefabsByName[((Object)prefab).name] = prefab; } } private static List<GameObject> EchoholdResolvePrefabs(IReadOnlyDictionary<string, GameObject> prefabsByName, IEnumerable<string> names) { List<GameObject> list = new List<GameObject>(); foreach (string name in names) { if (prefabsByName.TryGetValue(name, out GameObject value)) { list.Add(value); } } return list; } private static void EchoholdRegisterLevelObjects(Level level) { if (level.ConnectObject != null) { GameObject val = EchoholdResolvePrefab(level.ConnectObject); if ((Object)(object)val != (Object)null) { EchoholdRegisterNetworkPrefab("Level/" + EchoholdGetLevelPath(level) + "/Other/" + EchoholdGetPrefabName(level.ConnectObject, val), val); } } if (level.BlockObject != null) { GameObject val2 = EchoholdResolvePrefab(level.BlockObject); if ((Object)(object)val2 != (Object)null) { EchoholdRegisterNetworkPrefab("Level/" + EchoholdGetLevelPath(level) + "/Other/" + EchoholdGetPrefabName(level.BlockObject, val2), val2); } } } private static string EchoholdGetLevelPath(Level level) { if (!string.IsNullOrWhiteSpace(((Object)level).name)) { return ((Object)level).name; } return "Echohold"; } private static string EchoholdGetPrefabName(PrefabRef prefabRef, GameObject prefab) { if (!string.IsNullOrWhiteSpace(prefabRef.PrefabName)) { return prefabRef.PrefabName; } return ((Object)prefab).name; } private static GameObject? EchoholdResolvePrefab(PrefabRef? prefabRef) { if (prefabRef == null) { return null; } if (prefabRef.IsValid()) { return prefabRef.Prefab; } AssetBundle bundle = prefabRef.Bundle; if ((Object)(object)bundle == (Object)null || string.IsNullOrWhiteSpace(prefabRef.PrefabName)) { return null; } GameObject[] array = bundle.LoadAllAssets<GameObject>(); foreach (GameObject val in array) { if ((Object)(object)val != (Object)null && string.Equals(((Object)val).name, prefabRef.PrefabName, StringComparison.OrdinalIgnoreCase)) { return val; } } return null; } private static List<PrefabRef> EchoholdRegisterPrefabs(Level level, string moduleTypeName, IEnumerable<GameObject> prefabs) { List<PrefabRef> list = new List<PrefabRef>(); foreach (GameObject item in prefabs.OrderBy<GameObject, string>((GameObject gameObject) => ((Object)gameObject).name, StringComparer.OrdinalIgnoreCase)) { PrefabRef val = EchoholdRegisterNetworkPrefab("Level/" + ((Object)level).name + "/" + moduleTypeName + "/" + ((Object)item).name, item); if (val != null) { list.Add(val); } } return list; } private static PrefabRef? EchoholdRegisterNetworkPrefab(string prefabId, GameObject prefab) { PrefabRef val = EchoholdGetRegisteredPrefabRef(prefabId, prefab); if (val != null) { return val; } EchoholdPreparePrefab(prefab); Utilities.FixAudioMixerGroups(prefab); return NetworkPrefabs.RegisterNetworkPrefab(prefabId, prefab); } private static PrefabRef? EchoholdGetRegisteredPrefabRef(string prefabId, GameObject prefab) { if (!NetworkPrefabs.PrefabRefs.TryGetValue(prefabId, out var value) || value == null) { return null; } if ((Object)(object)value.Prefab == (Object)null || (Object)(object)value.Prefab == (Object)(object)prefab) { return value; } return null; } private static void EchoholdPreparePrefab(GameObject prefab) { EchoholdApplyHideFlags((Object)(object)prefab); EchoholdEnsureVehicleSupport(prefab); EchoholdNormalizeBoxColliderSizes(prefab); EchoholdIgnoreUnreadableMeshesForNavMesh(prefab); EchoholdEnsureItemComponentReferences(prefab); EchoholdEnsurePlasmaComponentReferences(prefab); EchoholdAssignFallbackAudioMixerGroups(prefab); EchoholdAssignFallbackPhysAttributes(prefab); } private static void EchoholdEnsureVehicleSupport(GameObject prefab) { if (!((Object)(object)prefab == (Object)null) && EchoholdIsStartRoomPrefab(prefab)) { EchoholdEnsureVehicleItemVolumes(prefab); EchoholdEnsureVehicleChargingStation(prefab); } } private static bool EchoholdIsStartRoomPrefab(GameObject prefab) { GameObject prefab2 = prefab; if (!((Object)(object)prefab2.GetComponentInChildren<StartRoom>(true) != (Object)null)) { return EchoholdStartRoomNames.Any((string name) => string.Equals(((Object)prefab2).name, name, StringComparison.OrdinalIgnoreCase)); } return true; } private static void EchoholdEnsureVehicleItemVolumes(GameObject prefab) { int num = prefab.GetComponentsInChildren<ItemVolume>(true).Count(EchoholdIsVehicleItemVolume); if (num < 4) { Transform parent = EchoholdFindOrCreateVehicleSupportRoot(prefab); Transform anchor = EchoholdFindTruckAnchor(prefab); for (int i = num; i < 4; i++) { EchoholdCreateVehicleItemVolume(parent, anchor, i); } } } private static bool EchoholdIsVehicleItemVolume(ItemVolume itemVolume) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 return (int)EchoholdGetComponentField<itemVolume>((Component)(object)itemVolume, "itemVolume", (itemVolume)0) == 9; } private static void EchoholdCreateVehicleItemVolume(Transform parent, Transform anchor, int index) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0087: 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_00b6: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject((index == 0) ? "Item Volume vehicle" : $"Item Volume vehicle ({index})"); val.SetActive(false); val.transform.SetParent(parent, false); val.transform.SetPositionAndRotation(EchoholdGetVehicleVolumePosition(anchor, index), anchor.rotation); ItemVolume target = val.AddComponent<ItemVolume>(); EchoholdSetComponentField((Component)(object)target, "itemVolume", (object)(itemVolume)9); GameObject val2 = new GameObject("Vehicle"); val2.transform.SetParent(val.transform, false); val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = new Vector3(2.6f, 1.4f, 4f); EchoholdSetComponentField((Component)(object)target, "volumes", new List<GameObject> { val2 }); EchoholdApplyHideFlags((Object)(object)val); } private static Vector3 EchoholdGetVehicleVolumePosition(Transform anchor, int index) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) float num = ((index % 2 == 0) ? (-2f) : 2f); float num2 = 2.5f + (float)(index / 2) * 2f; return anchor.position + anchor.right * num + anchor.forward * num2 + Vector3.up * 0.25f; } private static Transform EchoholdFindTruckAnchor(GameObject prefab) { LevelPoint[] componentsInChildren = prefab.GetComponentsInChildren<LevelPoint>(true); foreach (LevelPoint val in componentsInChildren) { if ((Object)(object)val != (Object)null && EchoholdGetComponentField((Component)(object)val, "Truck", fallback: false)) { return ((Component)val).transform; } } RoomVolume[] componentsInChildren2 = prefab.GetComponentsInChildren<RoomVolume>(true); foreach (RoomVolume val2 in componentsInChildren2) { if ((Object)(object)val2 != (Object)null && EchoholdGetComponentField((Component)(object)val2, "Truck", fallback: false)) { return ((Component)val2).transform; } } return prefab.transform; } private static Transform EchoholdFindOrCreateVehicleSupportRoot(GameObject prefab) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown Transform val = ((IEnumerable<Transform>)prefab.GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform child) => (Object)(object)child != (Object)null && string.Equals(((Object)child).name, "Empress Vehicle Support", StringComparison.OrdinalIgnoreCase))); if ((Object)(object)val != (Object)null) { return val; } GameObject val2 = new GameObject("Empress Vehicle Support"); val2.transform.SetParent(prefab.transform, false); EchoholdApplyHideFlags((Object)val2); return val2.transform; } private static void EchoholdEnsureVehicleChargingStation(GameObject prefab) { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) if (prefab.GetComponentsInChildren<ChargingStation>(true).Any(EchoholdIsVehicleChargingStation)) { return; } ChargingStation val = EchoholdFindFallbackChargingStationTemplate(); if (!((Object)(object)val == (Object)null) && EchoholdIsVehicleChargingStation(val)) { ChargingStation val2 = EchoholdFindLegacyChargingStation(prefab); Transform val3 = EchoholdFindOrCreateVehicleSupportRoot(prefab); Transform val4 = EchoholdFindTruckAnchor(prefab); GameObject val5 = EchoholdCloneInactiveChargingStationTemplate(val); ((Object)val5).name = "Charging Station New"; val5.transform.SetParent(val3, false); if ((Object)(object)val2 != (Object)null) { val5.transform.SetPositionAndRotation(((Component)val2).transform.position, ((Component)val2).transform.rotation); ((Component)val2).gameObject.SetActive(false); } else { val5.transform.SetPositionAndRotation(val4.position + val4.forward * 6.5f + Vector3.up * 0.05f, Quaternion.LookRotation(-val4.forward, Vector3.up)); } Transform val6 = EchoholdFindChildByExactName(val5.transform, "Charge Area"); if ((Object)(object)val6 != (Object)null) { val6.localScale = new Vector3(Mathf.Max(val6.localScale.x, 4f), Mathf.Max(val6.localScale.y, 2f), Mathf.Max(val6.localScale.z, 4f)); } EchoholdApplyHideFlags((Object)(object)val5); Utilities.FixAudioMixerGroups(val5); } } private static GameObject EchoholdCloneInactiveChargingStationTemplate(ChargingStation template) { GameObject gameObject = ((Component)template).gameObject; bool activeSelf = gameObject.activeSelf; try { if (activeSelf) { gameObject.SetActive(false); } GameObject obj = Object.Instantiate<GameObject>(gameObject); obj.SetActive(false); return obj; } finally { if ((Object)(object)gameObject != (Object)null && activeSelf) { gameObject.SetActive(true); } } } internal static void EchoholdActivateVehicleChargingStation(StartRoom? startRoom) { if ((Object)(object)startRoom == (Object)null || !EchoholdIsCurrentLevel() || !EchoholdIsStartRoomPrefab(((Component)startRoom).gameObject)) { return; } ChargingStation[] componentsInChildren = ((Component)startRoom).GetComponentsInChildren<ChargingStation>(true); foreach (ChargingStation val in componentsInChildren) { if ((Object)(object)val != (Object)null && EchoholdIsVehicleChargingStation(val) && string.Equals(((Object)((Component)val).gameObject).name, "Charging Station New", StringComparison.OrdinalIgnoreCase) && !((Component)val).gameObject.activeSelf) { ((Component)val).gameObject.SetActive(true); } } ItemVolume[] componentsInChildren2 = ((Component)startRoom).GetComponentsInChildren<ItemVolume>(true); foreach (ItemVolume val2 in componentsInChildren2) { if ((Object)(object)val2 != (Object)null && EchoholdIsVehicleItemVolume(val2) && !((Component)val2).gameObject.activeSelf) { ((Component)val2).gameObject.SetActive(true); } } } private static ChargingStation? EchoholdFindFallbackChargingStationTemplate() { ChargingStation val = EchoholdFindChargingStationTemplateFromLevels(); if ((Object)(object)val != (Object)null && EchoholdIsVehicleChargingStation(val)) { return val; } return Resources.FindObjectsOfTypeAll<ChargingStation>().Where(delegate(ChargingStation candidate) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)candidate != (Object)null) { Scene scene = ((Component)candidate).gameObject.scene; return !((Scene)(ref scene)).IsValid(); } return false; }).OrderByDescending(EchoholdIsVehicleChargingStation) .FirstOrDefault() ?? val; } private static ChargingStation? EchoholdFindChargingStationTemplateFromLevels() { ChargingStation val = null; if (RunManager.instance?.levels == null) { return val; } foreach (Level level in RunManager.instance.levels) { if ((Object)(object)level == (Object)null || EchoholdIsEchoholdLevel(level) || level.StartRooms == null) { continue; } foreach (PrefabRef startRoom in level.StartRooms) { GameObject val2 = null; try { val2 = EchoholdResolvePrefab(startRoom); } catch { } if ((Object)(object)val2 == (Object)null) { continue; } ChargingStation[] componentsInChildren = val2.GetComponentsInChildren<ChargingStation>(true); foreach (ChargingStation val3 in componentsInChildren) { if (!((Object)(object)val3 == (Object)null)) { if (EchoholdIsVehicleChargingStation(val3)) { return val3; } if (val == null) { val = val3; } } } } } return val; } private static ChargingStation? EchoholdFindLegacyChargingStation(GameObject prefab) { return ((IEnumerable<ChargingStation>)prefab.GetComponentsInChildren<ChargingStation>(true)).FirstOrDefault((Func<ChargingStation, bool>)((ChargingStation candidate) => (Object)(object)candidate != (Object)null && !EchoholdIsVehicleChargingStation(candidate))); } private static bool EchoholdIsVehicleChargingStation(ChargingStation? chargingStation) { if ((Object)(object)chargingStation == (Object)null) { return false; } Transform transform = ((Component)chargingStation).transform; if ((Object)(object)EchoholdFindChildByExactName(transform, "Charge Area") != (Object)null) { return (Object)(object)EchoholdFindChildByExactName(transform, "Line Between Two Points") != (Object)null; } return false; } private static Transform? EchoholdFindChildByExactName(Transform root, string name) { string name2 = name; return ((IEnumerable<Transform>)((Component)root).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform child) => (Object)(object)child != (Object)null && string.Equals(((Object)child).name, name2, StringComparison.OrdinalIgnoreCase))); } private static T EchoholdGetComponentField<T>(Component target, string fieldName, T fallback) { if ((Object)(object)target == (Object)null) { return fallback; } try { if (AccessTools.Field(((object)target).GetType(), fieldName) == null) { return fallback; } return (T)((Traverse.Create((object)target).Field(fieldName).GetValue() is T val) ? ((object)val) : ((object)fallback)); } catch { return fallback; } } private static void EchoholdSetComponentField(Component target, string fieldName, object value) { if ((Object)(object)target == (Object)null) { return; } try { if (!(AccessTools.Field(((object)target).GetType(), fieldName) == null)) { Traverse.Create((object)target).Field(fieldName).SetValue(value); } } catch { } } private static void EchoholdNormalizeBoxColliderSizes(GameObject prefab) { //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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)prefab == (Object)null) { return; } BoxCollider[] componentsInChildren = prefab.GetComponentsInChildren<BoxCollider>(true); Vector3 val2 = default(Vector3); foreach (BoxCollider val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { Vector3 size = val.size; ((Vector3)(ref val2))..ctor(Mathf.Abs(size.x), Mathf.Abs(size.y), Mathf.Abs(size.z)); if (size != val2) { val.size = val2; } } } } private static void EchoholdIgnoreUnreadableMeshesForNavMesh(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { return; } MeshFilter[] componentsInChildren = prefab.GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val in componentsInChildren) { if (!((Object)(object)((val != null) ? val.sharedMesh : null) == (Object)null) && !EchoholdMeshIsReadable(val.sharedMesh)) { EchoholdIgnoreObjectFromNavMeshBuild(((Component)val).gameObject); } } SkinnedMeshRenderer[] componentsInChildren2 = prefab.GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val2 in componentsInChildren2) { if (!((Object)(object)((val2 != null) ? val2.sharedMesh : null) == (Object)null) && !EchoholdMeshIsReadable(val2.sharedMesh)) { EchoholdIgnoreObjectFromNavMeshBuild(((Component)val2).gameObject); } } } private static bool EchoholdMeshIsReadable(Mesh mesh) { try { return mesh.isReadable; } catch { return false; } } private static void EchoholdIgnoreObjectFromNavMeshBuild(GameObject gameObject) { if (!((Object)(object)gameObject == (Object)null)) { NavMeshModifier obj = gameObject.GetComponent<NavMeshModifier>() ?? gameObject.AddComponent<NavMeshModifier>(); obj.ignoreFromBuild = true; obj.applyToChildren = false; } } private static void EchoholdEnsureItemComponentReferences(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { return; } ItemAttributes[] componentsInChildren = prefab.GetComponentsInChildren<ItemAttributes>(true); foreach (ItemAttributes val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { EchoholdSetFieldIfNull((Component)(object)val, "photonView", (Object?)(object)(((Component)val).GetComponent<PhotonView>() ?? ((Component)val).GetComponentInParent<PhotonView>())); EchoholdSetFieldIfNull((Component)(object)val, "roomVolumeCheck", (Object?)(object)(((Component)val).GetComponent<RoomVolumeCheck>() ?? ((Component)val).GetComponentInParent<RoomVolumeCheck>())); EchoholdSetFieldIfNull((Component)(object)val, "itemEquippable", (Object?)(object)(((Component)val).GetComponent<ItemEquippable>() ?? ((Component)val).GetComponentInParent<ItemEquippable>())); EchoholdSetFieldIfNull((Component)(object)val, "physGrabObject", (Object?)(object)(((Component)val).GetComponent<PhysGrabObject>() ?? ((Component)val).GetComponentInChildren<PhysGrabObject>(true) ?? ((Component)val).GetComponentInParent<PhysGrabObject>())); EchoholdSetFieldIfNull((Component)(object)val, "itemToggle", (Object?)(object)(((Component)val).GetComponent<ItemToggle>() ?? ((Component)val).GetComponentInParent<ItemToggle>())); } } } private static void EchoholdEnsurePlasmaComponentReferences(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { return; } Component val = EchoholdFindComponentByTypeName(prefab, "PlasmaEnergySystem"); Component[] componentsInChildren = prefab.GetComponentsInChildren<Component>(true); foreach (Component val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null)) { string name = ((object)val2).GetType().Name; if (string.Equals(name, "ItemPlasmaGun", StringComparison.Ordinal)) { EchoholdSetFieldIfNull(val2, "physGrabObject", (Object?)(object)(val2.GetComponent<PhysGrabObject>() ?? val2.GetComponentInChildren<PhysGrabObject>(true) ?? val2.GetComponentInParent<PhysGrabObject>())); EchoholdSetFieldIfNull(val2, "itemToggle", (Object?)(object)(val2.GetComponent<ItemToggle>() ?? val2.GetComponentInParent<ItemToggle>())); EchoholdSetFieldIfNull(val2, "plasmaEnergySystem", (Object?)(object)(val ?? EchoholdFindComponentByTypeName(val2.gameObject, "PlasmaEnergySystem"))); EchoholdSetFieldIfNull(val2, "photonView", (Object?)(object)(val2.GetComponent<PhotonView>() ?? val2.GetComponentInParent<PhotonView>())); EchoholdSetFieldIfNull(val2, "impactDetector", (Object?)(object)(val2.GetComponent<PhysGrabObjectImpactDetector>() ?? val2.GetComponentInParent<PhysGrabObjectImpactDetector>())); EchoholdSetFieldIfNull(val2, "itemEquippable", (Object?)(object)(val2.GetComponent<ItemEquippable>() ?? val2.GetComponentInParent<ItemEquippable>())); EchoholdSetFieldIfNull(val2, "roomVolumeCheck", (Object?)(object)(val2.GetComponent<RoomVolumeCheck>() ?? val2.GetComponentInParent<RoomVolumeCheck>())); } else if (string.Equals(name, "PlasmaVisualLogic", StringComparison.Ordinal)) { EchoholdSetFieldIfNull(val2, "plasmaEnergySystem", (Object?)(object)(val ?? EchoholdFindComponentByTypeName(val2.gameObject, "PlasmaEnergySystem"))); } } } } private static Component? EchoholdFindComponentByTypeName(GameObject root, string typeName) { if ((Object)(object)root == (Object)null || string.IsNullOrWhiteSpace(typeName)) { return null; } Component[] componentsInChildren = root.GetComponentsInChildren<Component>(true); foreach (Component val in componentsInChildren) { if ((Object)(object)val != (Object)null && string.Equals(((object)val).GetType().Name, typeName, StringComparison.Ordinal)) { return val; } } return null; } private static void EchoholdSetFieldIfNull(Component target, string fieldName, Object? value) { if ((Object)(object)target == (Object)null || value == (Object)null || string.IsNullOrWhiteSpace(fieldName)) { return; } try { if (!(AccessTools.Field(((object)target).GetType(), fieldName) == null)) { Traverse val = Traverse.Create((object)target).Field(fieldName); if (val.GetValue() == null) { val.SetValue((object)value); } } } catch { } } private static void EchoholdAssignFallbackAudioMixerGroups(GameObject prefab) { AudioMixerGroup val = EchoholdGetFallbackAudioMixerGroup(); if ((Object)(object)prefab == (Object)null || (Object)(object)val == (Object)null) { return; } AudioSource[] componentsInChildren = prefab.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.outputAudioMixerGroup != (Object)null)) { val2.outputAudioMixerGroup = val; } } } private static AudioMixerGroup? EchoholdGetFallbackAudioMixerGroup() { if ((Object)(object)AudioManager.instance == (Object)null) { return null; } return AudioManager.instance.SoundMasterGroup ?? AudioManager.instance.PersistentSoundGroup ?? AudioManager.instance.MusicMasterGroup ?? AudioManager.instance.MicrophoneSoundGroup ?? AudioManager.instance.MicrophoneSpectateGroup ?? AudioManager.instance.TTSSoundGroup ?? AudioManager.instance.TTSSpectateGroup; } private static void EchoholdAssignFallbackPhysAttributes(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { return; } NotValuableObject[] componentsInChildren = prefab.GetComponentsInChildren<NotValuableObject>(true); foreach (NotValuableObject val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.physAttributePreset != (Object)null)) { Rigidbody component = ((Component)val).GetComponent<Rigidbody>(); float mass = (((Object)(object)component != (Object)null && component.mass > 0f) ? component.mass : 1f); val.physAttributePreset = EchoholdCreateFallbackPhysAttribute(mass); } } } private static PhysAttribute EchoholdCreateFallbackPhysAttribute(float mass) { PhysAttribute obj = ScriptableObject.CreateInstance<PhysAttribute>(); obj.mass = Mathf.Max(0.01f, mass); EchoholdApplyHideFlags((Object)(object)obj); return obj; } private bool EchoholdTryRepairItems(AssetBundle bundle) { if (_echoholdItemsRepairApplied || (Object)(object)bundle == (Object)null) { return false; } List<ItemContent> list = (from itemContent in bundle.LoadAllAssets<ItemContent>() where (Object)(object)((itemContent != null) ? itemContent.Prefab : null) != (Object)null select itemContent).OrderBy<ItemContent, string>((ItemContent itemContent) => ((Object)((Component)itemContent.Prefab).gameObject).name, StringComparer.OrdinalIgnoreCase).ToList(); int num = 0; foreach (ItemContent item in list) { ItemAttributes prefab = item.Prefab; Item val = prefab?.item; if (!((Object)(object)prefab == (Object)null) && !((Object)(object)val == (Object)null) && EchoholdIsEchoholdItem(prefab, val)) { EchoholdPreparePrefab(((Component)prefab).gameObject); if (!EchoholdItemAlreadyRegistered(prefab, val) && Items.RegisterItem(item) != null) { num++; } } } _echoholdItemsRepairApplied = true; if (num > 0) { ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Empress Echohold Compat Patch repaired {num} Echohold item registrations."); } return num > 0; } private static bool EchoholdIsEchoholdItem(ItemAttributes itemAttributes, Item item) { string value = (((Object)(object)itemAttributes != (Object)null) ? ((Object)((Component)itemAttributes).gameObject).name : string.Empty); string value2 = (((Object)(object)item != (Object)null) ? item.itemName : string.Empty); string value3 = (((Object)(object)item != (Object)null) ? ((Object)item).name : string.Empty); if (!EchoholdContainsEchoholdItemName(value) && !EchoholdContainsEchoholdItemName(value2)) { return EchoholdContainsEchoholdItemName(value3); } return true; } private static bool EchoholdContainsEchoholdItemName(string? value) { if (string.IsNullOrWhiteSpace(value)) { return false; } if (value.IndexOf("plasma", StringComparison.OrdinalIgnoreCase) < 0 && value.IndexOf("echohold", StringComparison.OrdinalIgnoreCase) < 0) { return value.IndexOf("railgun", StringComparison.OrdinalIgnoreCase) >= 0; } return true; } private static bool EchoholdItemAlreadyRegistered(ItemAttributes itemAttributes, Item item) { if ((Object)(object)itemAttributes == (Object)null || (Object)(object)item == (Object)null) { return false; } if (EchoholdItemListContains(Items.RegisteredItems, item) || EchoholdItemListContains(Items.AllItems, item)) { return true; } string key = "Items/" + ((Object)((Component)itemAttributes).gameObject).name; if (NetworkPrefabs.PrefabRefs.ContainsKey(key)) { return true; } return false; } private static bool EchoholdItemListContains(IEnumerable<Item>? items, Item item) { if (items == null || (Object)(object)item == (Object)null) { return false; } foreach (Item item2 in items) { if (!((Object)(object)item2 == (Object)null)) { if ((Object)(object)item2 == (Object)(object)item) { return true; } if (!string.IsNullOrWhiteSpace(((Object)item2).name) && string.Equals(((Object)item2).name, ((Object)item).name, StringComparison.OrdinalIgnoreCase)) { return true; } if (!string.IsNullOrWhiteSpace(item2.itemName) && string.Equals(item2.itemName, item.itemName, StringComparison.OrdinalIgnoreCase)) { return true; } } } return false; } private static int EchoholdCountModules(Level level) { return (level.ModulesNormal1?.Count ?? 0) + (level.ModulesPassage1?.Count ?? 0) + (level.ModulesDeadEnd1?.Count ?? 0) + (level.ModulesExtraction1?.Count ?? 0) + (level.ModulesNormal2?.Count ?? 0) + (level.ModulesPassage2?.Count ?? 0) + (level.ModulesDeadEnd2?.Count ?? 0) + (level.ModulesExtraction2?.Count ?? 0) + (level.ModulesNormal3?.Count ?? 0) + (level.ModulesPassage3?.Count ?? 0) + (level.ModulesDeadEnd3?.Count ?? 0) + (level.ModulesExtraction3?.Count ?? 0); } internal static bool EchoholdIsCurrentLevel() { if (!EchoholdIsEchoholdLevel(((Object)(object)LevelGenerator.Instance != (Object)null) ? LevelGenerator.Instance.Level : null)) { return EchoholdIsEchoholdLevel(((Object)(object)RunManager.instance != (Object)null) ? RunManager.instance.levelCurrent : null); } return true; } internal static bool EchoholdShouldSuppressUnityLog(LogType logType, string? format, object[]? args) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (!EchoholdIsCurrentLevel()) { return false; } string text = EchoholdFormatUnityLogMessage(format, args); if (string.IsNullOrWhiteSpace(text)) { return false; } if ((int)logType == 2 && EchoholdIsMissingScriptWarning(text)) { return true; } if ((int)logType == 2 && text.StartsWith("BoxCollider does not support negative scale or size.", StringComparison.Ordinal)) { return true; } if ((int)logType == 0 && text.StartsWith("RuntimeNavMeshBuilder: Source mesh ", StringComparison.Ordinal) && text.IndexOf("does not allow read access", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if ((int)logType == 0) { if (!text.StartsWith("Level Point: ", StringComparison.Ordinal)) { return text.StartsWith(" Point Name: ", StringComparison.Ordinal); } return true; } return false; } internal static bool EchoholdShouldSuppressUnityLog(LogEventArgs? eventArgs) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 if (eventArgs == null || !EchoholdIsCurrentLevel()) { return false; } if (!EchoholdIsUnityLogSource(eventArgs.Source)) { return false; } return EchoholdShouldSuppressUnityLog((LogType)(((int)eventArgs.Level != 2) ? (((int)eventArgs.Level == 4) ? 2 : 3) : 0), eventArgs.Data?.ToString(), null); } private static bool EchoholdIsUnityLogSource(ILogSource? source) { if (source != null) { return string.Equals(source.SourceName, "Unity Log", StringComparison.OrdinalIgnoreCase); } return false; } private static bool EchoholdIsMissingScriptWarning(string? message) { if (string.IsNullOrWhiteSpace(message)) { return false; } if (message.IndexOf("The referenced script", StringComparison.Ordinal) >= 0) { return message.IndexOf("missing", StringComparison.OrdinalIgnoreCase) >= 0; } return false; } private static string EchoholdFormatUnityLogMessage(string? format, object[]? args) { if (format == null) { return string.Empty; } if (args == null || args.Length == 0) { return format; } try { return string.Format(format, args); } catch { return format; } } private static bool EchoholdSuppressMissingScriptWarningPrefix(LogType logType, string format, object[] args) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return !EchoholdShouldSuppressUnityLog(logType, format, args); } private static bool EchoholdIsEchoholdLevel(Level? level) { if ((Object)(object)level == (Object)null) { return false; } if (!string.Equals(((Object)level).name, "Level - Echohold", StringComparison.OrdinalIgnoreCase) && !string.Equals(((Object)level).name, "Echohold", StringComparison.OrdinalIgnoreCase) && (string.IsNullOrWhiteSpace(((Object)level).name) || ((Object)level).name.IndexOf("echohold", StringComparison.OrdinalIgnoreCase) < 0)) { if (!string.IsNullOrWhiteSpace(level.NarrativeName)) { return level.NarrativeName.IndexOf("echohold", StringComparison.OrdinalIgnoreCase) >= 0; } return false; } return true; } internal static void EchoholdEnsureLevelFallbackData(Level? level) { if (EchoholdIsEchoholdLevel(level)) { Level val = level; if (val.ValuablePresets == null) { val.ValuablePresets = new List<LevelValuables>(); } val = level; if (val.AmbiencePresets == null) { val.AmbiencePresets = new List<LevelAmbience>(); } if (level.ValuablePresets.Count == 0 && (Object)(object)ValuablePresets.GenericValuablePreset != (Object)null) { level.ValuablePresets.Add(ValuablePresets.GenericValuablePreset); } if (level.AmbiencePresets.Count == 0 && EchoholdTryGetFallbackAmbience(out LevelAmbience ambience)) { level.AmbiencePresets.Add(ambience); } } } private static void EchoholdEnsureLevelLoadingGraphics(Level level, AssetBundle bundle) { List<EchoholdLoadingGraphic> list = EchoholdCollectLoadingGraphics(bundle); EchoholdCacheLoadingSprites(list); string[] echoholdLoadingGraphicFieldNames = EchoholdLoadingGraphicFieldNames; foreach (string text in echoholdLoadingGraphicFieldNames) { if (list.Count != 0 || !EchoholdLevelLoadingGraphicValid(level, text)) { EchoholdLoadingGraphic echoholdLoadingGraphic = ((list.Count > 0) ? list[Math.Min(Array.IndexOf(EchoholdLoadingGraphicFieldNames, text), list.Count - 1)] : null); if (echoholdLoadingGraphic == null || !EchoholdSetLevelLoadingGraphic(level, text, echoholdLoadingGraphic)) { EchoholdCopyFallbackLevelLoadingGraphic(level, text); } } } } private static List<EchoholdLoadingGraphic> EchoholdCollectLoadingGraphics(AssetBundle bundle) { List<EchoholdLoadingGraphic> list = new List<EchoholdLoadingGraphic>(); HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); List<Sprite> source = (from sprite in bundle.LoadAllAssets<Sprite>() where (Object)(object)sprite != (Object)null && !string.IsNullOrWhiteSpace(((Object)sprite).name) select sprite).ToList(); string[] echoholdPreferredLoadingGraphicNames = EchoholdPreferredLoadingGraphicNames; foreach (string preferredName in echoholdPreferredLoadingGraphicNames) { Sprite val = ((IEnumerable<Sprite>)source).FirstOrDefault((Func<Sprite, bool>)((Sprite candidate) => string.Equals(((Object)candidate).name, preferredName, StringComparison.OrdinalIgnoreCase))); if (!((Object)(object)val == (Object)null) && hashSet.Add(((Object)val).name)) { bool canUsePrefabRef = (Object)(object)bundle.LoadAsset<Sprite>(((Object)val).name) != (Object)null; list.Add(new EchoholdLoadingGraphic(bundle, val, ((Object)val).name, canUsePrefabRef)); } } foreach (string item in bundle.GetAllAssetNames().OrderBy(EchoholdLoadingGraphicRank).ThenBy<string, string>((string name) => name, StringComparer.OrdinalIgnoreCase)) { Sprite val2 = bundle.LoadAsset<Sprite>(item); if (!((Object)(object)val2 == (Object)null) && hashSet.Add(item)) { list.Add(new EchoholdLoadingGraphic(bundle, val2, item, canUsePrefabRef: true)); } } foreach (Sprite item2 in source.OrderBy((Sprite sprite) => EchoholdLoadingGraphicRank(((Object)sprite).name)).ThenBy<Sprite, string>((Sprite sprite) => ((Object)sprite).name, StringComparer.OrdinalIgnoreCase)) { if (!((Object)(object)item2 == (Object)null) && !string.IsNullOrWhiteSpace(((Object)item2).name) && hashSet.Add(((Object)item2).name)) { bool canUsePrefabRef2 = (Object)(object)bundle.LoadAsset<Sprite>(((Object)item2).name) != (Object)null; list.Add(new EchoholdLoadingGraphic(bundle, item2, ((Object)item2).name, canUsePrefabRef2)); } } return list; } private static void EchoholdCacheLoadingSprites(IEnumerable<EchoholdLoadingGraphic> graphics) { EchoholdLoadingSprites.Clear(); foreach (EchoholdLoadingGraphic graphic in graphics) { if ((Object)(object)graphic.Sprite != (Object)null && !EchoholdLoadingSprites.Contains(graphic.Sprite)) { EchoholdLoadingSprites.Add(graphic.Sprite); } if (EchoholdLoadingSprites.Count >= EchoholdLoadingGraphicFieldNames.Length) { break; } } } internal static void EchoholdApplyLoadingGraphics(LoadingUI? loadingUI) { if (!((Object)(object)loadingUI == (Object)null) && EchoholdIsCurrentLevel() && EchoholdLoadingSprites.Count != 0) { EchoholdApplyLoadingGraphic(loadingUI.loadingGraphic01, 0); EchoholdApplyLoadingGraphic(loadingUI.loadingGraphic02, 1); EchoholdApplyLoadingGraphic(loadingUI.loadingGraphic03, 2); } } private static void EchoholdApplyLoadingGraphic(Image? image, int index) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)image == (Object)null)) { Sprite sprite = EchoholdLoadingSprites[Math.Min(index, EchoholdLoadingSprites.Count - 1)]; image.sprite = sprite; ((Graphic)image).color = Color.white; } } private static int EchoholdLoadingGraphicRank(string value) { if (string.IsNullOrWhiteSpace(value)) { return 1000; } string text = value.ToLowerInvariant(); int num = 0; if (text.Contains("loading") || text.Contains("load")) { num -= 100; } if (text.Contains("graphic")) { num -= 50; } if (text.Contains("echohold")) { num -= 25; } if (text.Contains("arctic")) { num -= 10; } if (text.Contains("icon") || text.Contains("map")) { num += 100; } return num; } private static bool EchoholdLevelLoadingGraphicValid(Level level, string fieldName) { try { if (AccessTools.Field(((object)level).GetType(), fieldName) == null) { return false; } object value = Traverse.Create((object)level).Field(fieldName).GetValue(); if (value == null) { return false; } Sprite val = (Sprite)((value is Sprite) ? value : null); if (val != null) { return (Object)(object)val != (Object)null; } return AccessTools.Method(value.GetType(), "IsValid", Type.EmptyTypes, (Type[])null) != null && Traverse.Create(value).Method("IsValid", Array.Empty<object>()).GetValue<bool>(); } catch { return false; } } private static bool EchoholdSetLevelLoadingGraphic(Level level, string fieldName, EchoholdLoadingGraphic graphic) { try { FieldInfo fieldInfo = AccessTools.Field(((object)level).GetType(), fieldName); if (fieldInfo == null) { return false; } if (typeof(Sprite).IsAssignableFrom(fieldInfo.FieldType)) { Traverse.Create((object)level).Field(fieldName).SetValue((object)graphic.Sprite); return true; } if (!fieldInfo.FieldType.Name.StartsWith("PrefabRef", StringComparison.Ordinal)) { return false; } if (!graphic.CanUsePrefabRef) { return false; } object obj = Traverse.Create((object)level).Field(fieldName).GetValue() ?? AccessTools.CreateInstance(fieldInfo.FieldType); if (obj == null) { return false; } if (AccessTools.Method(fieldInfo.FieldType, "SetPrefab", new Type[2] { typeof(AssetBundle), typeof(string) }, (Type[])null) != null) { Traverse.Create(obj).Method("SetPrefab", new object[2] { graphic.Bundle, graphic.ResourcePath }).GetValue(); } else { if (AccessTools.Field(fieldInfo.FieldType, "bundle") != null) { Traverse.Create(obj).Field("bundle").SetValue((object)graphic.Bundle); } if (AccessTools.Field(fieldInfo.FieldType, "resourcePath") != null) { Traverse.Create(obj).Field("resourcePath").SetValue((object)graphic.ResourcePath); } if (AccessTools.Field(fieldInfo.FieldType, "prefabName") != null) { Traverse.Create(obj).Field("prefabName").SetValue((object)Path.GetFileNameWithoutExtension(graphic.ResourcePath)); } } Traverse.Create((object)level).Field(fieldName).SetValue(obj); return EchoholdLevelLoadingGraphicValid(level, fieldName); } catch { return false; } } private static bool EchoholdCopyFallbackLevelLoadingGraphic(Level level, string fieldName) { if (RunManager.instance?.levels == null) { return false; } foreach (Level level2 in RunManager.instance.levels) { if ((Object)(object)level2 == (Object)null || (Object)(object)level2 == (Object)(object)level) { continue; } try { FieldInfo fieldInfo = AccessTools.Field(((object)level2).GetType(), fieldName); FieldInfo fieldInfo2 = AccessTools.Field(((object)level).GetType(), fieldName); if (fieldInfo == null || fieldInfo2 == null) { continue; } object value = Traverse.Create((object)level2).Field(fieldName).GetValue(); if (value != null) { Traverse.Create((object)level).Field(fieldName).SetValue(value); if (EchoholdLevelLoadingGraphicValid(level, fieldName)) { return true; } } } catch { } } return false; } private static bool EchoholdTryGetFallbackAmbience(out LevelAmbience ambience) { ambience = null; if ((Object)(object)AudioManager.instance != (Object)null && AudioManager.instance.levelAmbiences != null) { foreach (LevelAmbience levelAmbience in AudioManager.instance.levelAmbiences) { if (!((Object)(object)levelAmbience == (Object)null)) { ambience = levelAmbience; return true; } } } if ((Object)(object)RunManager.instance != (Object)null && RunManager.instance.levels != null) { foreach (Level level in RunManager.instance.levels) { if (level?.AmbiencePresets == null) { continue; } foreach (LevelAmbience ambiencePreset in level.AmbiencePresets) { if (!((Object)(object)ambiencePreset == (Object)null)) { ambience = ambiencePreset; return true; } } } } return false; } internal static void EchoholdEnsureExtractionPointCompatibility(ExtractionPoint extractionPoint) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown if ((Object)(object)extractionPoint == (Object)null || !EchoholdIsCurrentLevel()) { return; } if ((Object)(object)extractionPoint.extractionArea == (Object)null) { GameObject val = GameObject.CreatePrimitive((PrimitiveType)2); ((Object)val).name = "Echohold Patch Extraction Area"; val.transform.SetParent(((Component)extractionPoint).transform, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one * 0.1f; MeshRenderer component = val.GetComponent<MeshRenderer>(); if ((Object)(object)component != (Object)null) { ((Renderer)component).enabled = false; } Collider component2 = val.GetComponent<Collider>(); if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); } val.SetActive(false); EchoholdApplyHideFlags((Object)(object)val); extractionPoint.extractionArea = val; } if ((Object)(object)extractionPoint.grossUp == (Object)null) { GameObject val2 = new GameObject("Echohold Patch GrossUp"); val2.transform.SetParent(((Component)extractionPoint).transform, false); val2.SetActive(false); EchoholdApplyHideFlags((Object)(object)val2); extractionPoint.grossUp = val2; } } internal bool EchoholdTryStartSilentLevelPoint(LevelPoint levelPoint) { if (!EchoholdIsEchoholdLevelPoint(levelPoint)) { return false; } if ((Object)(object)LevelGenerator.Instance != (Object)null) { LevelGenerator instance = LevelGenerator.Instance; if (instance.LevelPathPoints == null) { instance.LevelPathPoints = new List<LevelPoint>(); } if (!LevelGenerator.Instance.LevelPathPoints.Contains(levelPoint)) { LevelGenerator.Instance.LevelPathPoints.Add(levelPoint); } if (levelPoint.Truck) { LevelGenerator.Instance.LevelPathTruck = levelPoint; } } if ((Object)(object)((Component)levelPoint).GetComponentInParent<StartRoom>() != (Object)null) { EchoholdSetLevelPointBool(levelPoint, "inStartRoom", value: true); } ((MonoBehaviour)this).StartCoroutine(EchoholdSilentLevelPointCheck(levelPoint)); return true; } private static void EchoholdSetLevelPointBool(LevelPoint levelPoint, string fieldName, bool value) { try { if (AccessTools.Field(((object)levelPoint).GetType(), fieldName) != null) { Traverse.Create((object)levelPoint).Field(fieldName).SetValue((object)value); } } catch { } } private static bool EchoholdIsEchoholdLevelPoint(LevelPoint? levelPoint) { if ((Object)(object)levelPoint == (Object)null) { return false; } if (EchoholdIsCurrentLevel()) { return true; } Module componentInParent = ((Component)levelPoint).GetComponentInParent<Module>(); if ((Object)(object)componentInParent != (Object)null && !string.IsNullOrWhiteSpace(((Object)componentInParent).name) && ((Object)componentInParent).name.IndexOf("echohold", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } StartRoom componentInParent2 = ((Component)levelPoint).GetComponentInParent<StartRoom>(); if ((Object)(object)componentInParent2 != (Object)null && !string.IsNullOrWhiteSpace(((Object)componentInParent2).name) && ((Object)componentInParent2).name.IndexOf("echohold", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } Transform val = ((Component)levelPoint).transform; while ((Object)(object)val != (Object)null) { if (!string.IsNullOrWhiteSpace(((Object)val).name) && ((Object)val).name.IndexOf("echohold", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } val = val.parent; } return false; } internal void EchoholdRepairLevelPoints(LevelGenerator levelGenerator) { if ((Object)(object)levelGenerator == (Object)null || !EchoholdIsEchoholdLevel(levelGenerator.Level) || levelGenerator.LevelPathPoints == null) { return; } int num = 0; int num2 = 0; foreach (LevelPoint levelPathPoint in levelGenerator.LevelPathPoints) { if (EchoholdRepairLevelPoint(levelPathPoint)) { num++; } if (EchoholdRepairLevelPointRoom(levelPathPoint)) { num2++; } } if (num > 0 || num2 > 0) { ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Empress Echohold Compat Patch repaired {num} Echohold level points onto the navmesh and restored {num2} room links."); } } private static bool EchoholdRepairLevelPoint(LevelPoint? levelPoint) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0043: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)levelPoint == (Object)null) { return false; } Vector3 position = ((Component)levelPoint).transform.position; NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(position, ref val, 0.5f, -1)) { return false; } NavMeshHit val2 = default(NavMeshHit); if (!NavMesh.SamplePosition(position, ref val2, 2f, -1)) { return false; } ((Component)levelPoint).transform.position = ((NavMeshHit)(ref val2)).position; EchoholdRepairLevelPointRoom(levelPoint); return true; } private static bool EchoholdRepairLevelPointRoom(LevelPoint? levelPoint) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)levelPoint == (Object)null || (Object)(object)levelPoint.Room != (Object)null) { return false; } RoomVolume room = default(RoomVolume); Vector3 val = default(Vector3); if (!SemiFunc.GetRoomVolumeAtPosition(((Component)levelPoint).transform.position, ref room, ref val)) { return false; } levelPoint.Room = room; return true; } internal IEnumerator EchoholdSilentLevelPointCheck(LevelPoint levelPoint) { if ((Object)(object)levelPoint == (Object)null) { yield break; } while ((Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated) { yield return (object)new WaitForSeconds(0.1f); } yield return (object)new WaitForSeconds(0.5f); if (EchoholdIsCurrentLevel()) { EchoholdRepairLevelPoint(levelPoint); EchoholdRepairLevelPointRoom(levelPoint); EchoholdRepairLevelPointConnections(levelPoint, LevelGenerator.Instance?.LevelPathPoints); if (levelPoint.ModuleConnect) { EchoholdSetLevelPointBool(levelPoint, "ModuleConnected", value: true); } } } private static void EchoholdRepairLevelPointConnections(LevelPoint? levelPoint, IList<LevelPoint>? allLevelPoints) { if ((Object)(object)levelPoint == (Object)null) { return; } if (levelPoint.ConnectedPoints == null) { levelPoint.ConnectedPoints = new List<LevelPoint>(); } levelPoint.ConnectedPoints.RemoveAll((LevelPoint connectedPoint) => (Object)(object)connectedPoint == (Object)null); LevelPoint[] array = levelPoint.ConnectedPoints.ToArray(); for (int i = 0; i < array.Length; i++) { EchoholdAddLevelPointConnection(array[i], levelPoint); } if (!levelPoint.ModuleConnect || allLevelPoints == null || levelPoint.ConnectedPoints.Count > 0) { return; } LevelPoint val = null; float currentBestDistance = float.MaxValue; foreach (LevelPoint allLevelPoint in allLevelPoints) { if (EchoholdCanConnectLevelPoints(levelPoint, allLevelPoint, currentBestDistance, out var distance)) { val = allLevelPoint; currentBestDistance = distance; } } EchoholdAddLevelPointConnection(levelPoint, val); EchoholdAddLevelPointConnection(val, levelPoint); } private static bool EchoholdCanConnectLevelPoints(LevelPoint source, LevelPoint? candidate, float currentBestDistance, out float distance) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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) distance = 0f; if ((Object)(object)source == (Object)null || (Object)(object)candidate == (Object)null || (Object)(object)source == (Object)(object)candidate || !candidate.ModuleConnect) { return false; } Vector3 val = ((Component)source).transform.position - ((Component)candidate).transform.position; if (((Vector3)(ref val)).sqrMagnitude <= Mathf.Epsilon) { return false; } distance = ((Vector3)(ref val)).magnitude; if (distance >= 15f || distance >= currentBestDistance) { return false; } if (Vector3.Dot(((Component)candidate).transform.forward, ((Component)source).transform.forward) > -0.8f) { return false; } return Vector3.Dot(((Component)candidate).transform.forward, ((Vector3)(ref val)).normalized) > 0.8f; } private static void EchoholdAddLevelPointConnection(LevelPoint? source, LevelPoint? target) { if (!((Object)(object)source == (Object)null) && !((Object)(object)target == (Object)null)) { if (source.ConnectedPoints == null) { source.ConnectedPoints = new List<LevelPoint>(); } if (!source.ConnectedPoints.Contains(target)) { source.ConnectedPoints.Add(target); } } } internal GameObject EchoholdCreateFallbackDoorMapObject(Map map, DirtFinderMapDoor door) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) MapLayer layerParent = map.GetLayerParent(((Component)door).transform.position.y); GameObject val = EchoholdInstantiateFallbackDoorMapObject(map, ((Component)layerParent).transform); ((Object)val).name = ((Object)((Component)door).gameObject).name; door.Target = val.transform; DirtFinderMapDoorTarget val2 = val.GetComponent<DirtFinderMapDoorTarget>() ?? val.AddComponent<DirtFinderMapDoorTarget>(); val2.Target = ((Component)door).transform; val2.Layer = layerParent; DirtFinderMapDoorTarget val3 = val2; if (val3.HingeTransform == null) { val3.HingeTransform = val.transform; } map.DoorUpdate(val2.HingeTransform, ((Component)door).transform, layerParent); if (!_echoholdLoggedDoorMapFallback) { _echoholdLoggedDoorMapFallback = true; ((BaseUnityPlugin)this).Logger.LogWarning((object)"Empress Echohold Compat Patch injected fallback minimap door markers for missing Echohold door prefabs."); } return val; } private static GameObject EchoholdInstantiateFallbackDoorMapObject(Map map, Transform parent) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) GameObject val; if ((Object)(object)map.Door1x1Object != (Object)null) { val = Object.Instantiate<GameObject>(map.Door1x1Object, parent); Collider[] componentsInChildren = val.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } } else { val = GameObject.CreatePrimitive((PrimitiveType)3); val.transform.SetParent(parent, false); val.transform.localScale = new Vector3(0.12f, 0.12f, 0.3f); Collider component = val.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } } val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; DirtFinderMapDoorTarget val2 = val.GetComponent<DirtFinderMapDoorTarget>() ?? val.AddComponent<DirtFinderMapDoorTarget>(); if (val2.HingeTransform == null) { val2.HingeTransform = val.transform; } EchoholdApplyHideFlags((Object)(object)val); return val; } private static void EchoholdApplyHideFlags(Object obj) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) if (obj == (Object)null) { return; } obj.hideFlags = (HideFlags)(obj.hideFlags | 0x23); GameObject val = (GameObject)(object)((obj is GameObject) ? obj : null); if (val == null) { return; } Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>(true); foreach (Transform obj2 in componentsInChildren) { ((Object)obj2).hideFlags = (HideFlags)(((Object)obj2).hideFlags | 0x23); GameObject gameObject = ((Component)obj2).gameObject; ((Object)gameObject).hideFlags = (HideFlags)(((Object)gameObject).hideFlags | 0x23); Component[] components = ((Component)obj2).GetComponents<Component>(); foreach (Component val2 in components) { if ((Object)(object)val2 != (Object)null) { ((Object)val2).hideFlags = (HideFlags)(((Object)val2).hideFlags | 0x23); } } } } } [HarmonyPatch(typeof(LevelPoint), "Start")] internal static class EchoholdCompatPatchLevelPointStartPatch { [HarmonyPrefix] private static bool EchoholdPrefix(LevelPoint __instance) { EchoholdCompatPatchPlugin instance = EchoholdCompatPatchPlugin.Instance; if ((Object)(object)instance == (Object)null || !instance.EchoholdTryStartSilentLevelPoint(__instance)) { return true; } return false; } } [HarmonyPatch(typeof(LoadingUI), "LevelAnimationStart")] internal static class EchoholdCompatPatchLoadingUILevelAnimationStartPatch { [HarmonyPostfix] private static void EchoholdPostfix(LoadingUI __instance) { EchoholdCompatPatchPlugin.EchoholdApplyLoadingGraphics(__instance); } } [HarmonyPatch(typeof(LevelGenerator), "StartRoomGeneration")] internal static class EchoholdCompatPatchStartRoomGenerationPatch { [HarmonyPrefix] private static void EchoholdPrefix() { EchoholdCompatPatchPlugin.Instance?.EchoholdTryRepairCurrentLevel(); } } [HarmonyPatch(typeof(StartRoom), "Start")] internal static class EchoholdCompatPatchStartRoomStartPatch { [HarmonyPostfix] private static void EchoholdPostfix(StartRoom __instance) { EchoholdCompatPatchPlugin.EchoholdActivateVehicleChargingStation(__instance); } } [HarmonyPatch(typeof(ExtractionPoint), "Start")] internal static class EchoholdCompatPatchExtractionPointStartPatch { [HarmonyPostfix] private static void EchoholdPostfix(ExtractionPoint __instance) { EchoholdCompatPatchPlugin.EchoholdEnsureExtractionPointCompatibility(__instance); } } [HarmonyPatch(typeof(Levels), "RegisterLevelWithGame")] internal static class EchoholdCompatPatchRegisterLevelPatch { [HarmonyPrefix] private static void EchoholdPrefix(Level level) { EchoholdCompatPatchPlugin.EchoholdEnsureLevelFallbackData(level); } } [HarmonyPatch(typeof(Map), "AddDoor")] internal static class EchoholdCompatPatchMapAddDoorPatch { [HarmonyPrefix] private static bool EchoholdPrefix(Map __instance, DirtFinderMapDoor door, GameObject doorPrefab, ref GameObject __result) { if (!EchoholdCompatPatchPlugin.EchoholdIsCurrentLevel() || (Object)(object)door == (Object)null || (Object)(object)doorPrefab != (Object)null) { return true; } EchoholdCompatPatchPlugin instance = EchoholdCompatPatchPlugin.Instance; if ((Object)(object)instance == (Object)null) { return true; } __result = instance.EchoholdCreateFallbackDoorMapObject(__instance, door); return false; } } [HarmonyPatch(typeof(LevelGenerator), "NavMeshSetupRPC")] internal static class EchoholdCompatPatchNavMeshSetupPatch { [HarmonyPostfix] private static void EchoholdPostfix(LevelGenerator __instance) { EchoholdCompatPatchPlugin.Instance?.EchoholdRepairLevelPoints(__instance); } } [HarmonyPatch(typeof(LevelPoint), "NavMeshCheck")] internal static class EchoholdCompatPatchLevelPointNavMeshCheckPatch { [HarmonyPrefix] private static bool EchoholdPrefix(LevelPoint __instance, ref IEnumerator __result) { if (!EchoholdCompatPatchPlugin.EchoholdIsCurrentLevel()) { return true; } EchoholdCompatPatchPlugin instance = EchoholdCompatPatchPlugin.Instance; if ((Object)(object)instance == (Object)null) { return true; } __result = instance.EchoholdSilentLevelPointCheck(__instance); return false; } } [HarmonyPatch(typeof(UnityLogListener), "LogEvent")] internal static class EchoholdCompatPatchUnityLogListenerPatch { [HarmonyPrefix] private static bool EchoholdPrefix(LogEventArgs eventArgs) { return !EchoholdCompatPatchPlugin.EchoholdShouldSuppressUnityLog(eventArgs); } } [HarmonyPatch(typeof(UnityLogSource), "UnityLogMessageHandler")] internal static class EchoholdCompatPatchUnityLogSourcePatch { [HarmonyPrefix] private static bool EchoholdPrefix(LogEventArgs eventArgs) { return !EchoholdCompatPatchPlugin.EchoholdShouldSuppressUnityLog(eventArgs); } } [HarmonyPatch(typeof(Logger), "InternalLogEvent")] internal static class EchoholdCompatPatchInternalLogEventPatch { [HarmonyPrefix] private static bool EchoholdPrefix(LogEventArgs eventArgs) { return !EchoholdCompatPatchPlugin.EchoholdShouldSuppressUnityLog(eventArgs); } } }
EmpressPlasmaRifleWeaponCompatPatch.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib.Modules; using REPOLib.Objects.Sdk; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Empress")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.12.0")] [assembly: AssemblyInformationalVersion("1.0.12")] [assembly: AssemblyProduct("EmpressPlasmaRifleWeaponCompatPatch")] [assembly: AssemblyTitle("EmpressPlasmaRifleWeaponCompatPatch")] [assembly: AssemblyVersion("1.0.12.0")] [module: RefSafetyRules(11)] 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 EmpressPlasmaRifleWeaponCompatPatch { [BepInPlugin("Empress.Plasma_Rifle.WeaponCompatPatch", "Empress Plasma Rifle Weapon Compat Patch", "1.0.12")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class EmpressPlasmaRifleWeaponCompatPatchPlugin : BaseUnityPlugin { internal const string PluginGuid = "Empress.Plasma_Rifle.WeaponCompatPatch"; internal const string PluginName = "Empress Plasma Rifle Weapon Compat Patch"; internal const string PluginVersion = "1.0.12"; private const string CompatShootBulletRpcName = "EmpressCompatShootBulletRPC"; private static readonly string[] TargetTokens = new string[19] { "Plasma Rifle", "Energy Crystal", "Plasma Shotgun", "Plasma Pistol", "Plasma Railgun", "Item Gun PlasmaRifle", "Item Power Crystal", "Item Gun PlasmaShotgun", "Item Gun PlasmaPistol", "Item Gun PlasmaRailgun", "Valuable - EH - Sweepo", "REPOLib - Item - Plasma Pistol", "Valuable - EH - Energy Capsule", "REPOLib - Item - Plasma Railgun", "Valuable - EH - Alien Canister", "Valuable - EH - Nuke", "REPOLib - Item - Plasma Rifle", "Valuable - EH - Plant Container", "REPOLib - Item - Plasma Shotgun" }; private static EmpressPlasmaRifleWeaponCompatPatchPlugin? Instance; private static readonly Dictionary<string, MemberInfo?> MemberCache = new Dictionary<string, MemberInfo>(StringComparer.Ordinal); private readonly Harmony _harmony = new Harmony("Empress.Plasma_Rifle.WeaponCompatPatch"); private readonly HashSet<int> _loggedBatterySkips = new HashSet<int>(); private readonly HashSet<int> _preparedRootIds = new HashSet<int>(); private readonly HashSet<int> _preparedGunIds = new HashSet<int>(); private readonly HashSet<int> _preparedBatteryIds = new HashSet<int>(); private readonly Dictionary<int, bool> _targetRootCache = new Dictionary<int, bool>(); private bool _customPlasmaGunCompatibilityPatched; private float _customPlasmaGunCompatibilityRetryTimer; private void Awake() { Instance = this; _harmony.PatchAll(); _customPlasmaGunCompatibilityPatched = PatchCustomPlasmaGunCompatibility(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Empress Plasma Rifle Weapon Compat Patch is ready for Plasma Rifle."); } private void Update() { if (!_customPlasmaGunCompatibilityPatched) { _customPlasmaGunCompatibilityRetryTimer -= Time.unscaledDeltaTime; if (!(_customPlasmaGunCompatibilityRetryTimer > 0f)) { _customPlasmaGunCompatibilityRetryTimer = 1f; _customPlasmaGunCompatibilityPatched = PatchCustomPlasmaGunCompatibility(); } } } private void OnDestroy() { _harmony.UnpatchSelf(); if (Instance == this) { Instance = null; } } internal static void PrepareRegisteredItem(ItemContent? itemContent) { if (!((Object)(object)itemContent == (Object)null)) { Instance?.PrepareItemAttributes(itemContent.Prefab); } } internal static void PrepareRegisteredItem(ItemAttributes? itemAttributes) { Instance?.PrepareItemAttributes(itemAttributes); } internal static void PrepareBattery(ItemBattery? itemBattery) { Instance?.PrepareBatteryInternal(itemBattery); } internal static void FinishBatteryStart(ItemBattery? itemBattery) { Instance?.FinishBatteryStartInternal(itemBattery); } internal static void SyncBattery(ItemBattery? itemBattery) { Instance?.SyncBatteryStateInternal(itemBattery, forceVisualUpdate: true); } internal static bool CanRunBatteryUpdate(ItemBattery? itemBattery) { if (!((Object)(object)Instance == (Object)null)) { return Instance.CanRunBatteryUpdateInternal(itemBattery); } return true; } internal static void PrepareGun(ItemGun? itemGun) { Instance?.PrepareGunInternal(itemGun); } internal static void SyncGunBattery(ItemGun? itemGun) { Instance?.SyncGunBatteryInternal(itemGun); } internal static void HandleCustomPlasmaGunShootBulletRpc(object? plasmaGun, Vector3 endPosition, bool hit, PhotonMessageInfo info) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) Instance?.HandleCustomPlasmaGunShootBulletRpcInternal(plasmaGun, endPosition, hit, info); } internal static void PrepareCustomPlasmaGun(object? plasmaGun) { Component val = (Component)((plasmaGun is Component) ? plasmaGun : null); if (val != null) { Instance?.EnsureCustomPlasmaGunRelay(val); } } internal static bool HandleCustomPlasmaGunShootBullet(object? plasmaGun, Vector3 endPosition, bool hit) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Instance != (Object)null) { return Instance.HandleCustomPlasmaGunShootBulletInternal(plasmaGun, endPosition, hit); } return false; } private bool PatchCustomPlasmaGunCompatibility() { //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => string.Equals(assembly.GetName().Name, "PlasmaGunAPI", StringComparison.OrdinalIgnoreCase))?.GetType("ItemPlasmaGun", throwOnError: false); MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, "Start", (Type[])null, (Type[])null) : null); MethodInfo methodInfo2 = ((type != null) ? AccessTools.Method(type, "ShootBullet", new Type[2] { typeof(Vector3), typeof(bool) }, (Type[])null) : null); if (methodInfo == null || methodInfo2 == null) { return false; } MethodInfo methodInfo3 = AccessTools.Method(typeof(EmpressPlasmaRifleWeaponCompatPatchPlugin), "PlasmaGunStartPostfix", (Type[])null, (Type[])null); MethodInfo methodInfo4 = AccessTools.Method(typeof(EmpressPlasmaRifleWeaponCompatPatchPlugin), "PlasmaGunShootBulletPrefix", (Type[])null, (Type[])null); if (methodInfo3 == null || methodInfo4 == null) { return false; } _harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo3), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _harmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Applied Echohold PlasmaGunAPI compat bridge."); return true; } private static void PlasmaGunStartPostfix(object __instance) { PrepareCustomPlasmaGun(__instance); } private static bool PlasmaGunShootBulletPrefix(object __instance, Vector3 _endPosition, bool _hit) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) HandleCustomPlasmaGunShootBullet(__instance, _endPosition, _hit); return false; } private void PrepareItemAttributes(ItemAttributes? itemAttributes) { if (!((Object)(object)itemAttributes == (Object)null)) { PreparePrefab(GetRoot(((Component)itemAttributes).gameObject)); } } private void PreparePrefab(GameObject? root) { if (!((Object)(object)root == (Object)null) && IsTargetObject(root) && _preparedRootIds.Add(((Object)root).GetInstanceID())) { CleanupInvalidManagedLightTags(root); ItemAttributes[] componentsInChildren = root.GetComponentsInChildren<ItemAttributes>(true); foreach (ItemAttributes itemAttributes in componentsInChildren) { EnsureItemAttributes(itemAttributes); } ItemBattery[] componentsInChildren2 = root.GetComponentsInChildren<ItemBattery>(true); foreach (ItemBattery itemBattery in componentsInChildren2) { PrepareBatteryInternal(itemBattery); } ItemGun[] componentsInChildren3 = root.GetComponentsInChildren<ItemGun>(true); foreach (ItemGun itemGun in componentsInChildren3) { PrepareGunInternal(itemGun); } PhysGrabObject[] componentsInChildren4 = root.GetComponentsInChildren<PhysGrabObject>(true); for (int i = 0; i < componentsInChildren4.Length; i++) { EnsurePhysGrabObjectColliders(componentsInChildren4[i]); } } } private void EnsureItemAttributes(ItemAttributes? itemAttributes) { if (!((Object)(object)itemAttributes == (Object)null)) { SetFieldIfNull(itemAttributes, "photonView", ((Component)itemAttributes).GetComponent<PhotonView>() ?? ((Component)itemAttributes).GetComponentInParent<PhotonView>()); SetFieldIfNull(itemAttributes, "roomVolumeCheck", ((Component)itemAttributes).GetComponent<RoomVolumeCheck>() ?? ((Component)itemAttributes).GetComponentInParent<RoomVolumeCheck>()); SetFieldIfNull(itemAttributes, "itemEquippable", ((Component)itemAttributes).GetComponent<ItemEquippable>() ?? ((Component)itemAttributes).GetComponentInParent<ItemEquippable>()); SetFieldIfNull(itemAttributes, "physGrabObject", ((Component)itemAttributes).GetComponent<PhysGrabObject>() ?? ((Component)itemAttributes).GetComponentInChildren<PhysGrabObject>(true) ?? ((Component)itemAttributes).GetComponentInParent<PhysGrabObject>()); SetFieldIfNull(itemAttributes, "itemToggle", ((Component)itemAttributes).GetComponent<ItemToggle>() ?? ((Component)itemAttributes).GetComponentInParent<ItemToggle>()); } } private void PrepareBatteryInternal(ItemBattery? itemBattery) { if (!((Object)(object)itemBattery == (Object)null) && IsTargetObject(GetRoot(((Component)itemBattery).gameObject)) && (!_preparedBatteryIds.Contains(((Object)itemBattery).GetInstanceID()) || !HasBatteryCompatibility(itemBattery))) { ItemAttributes value = ((Component)itemBattery).GetComponent<ItemAttributes>() ?? ((Component)itemBattery).GetComponentInParent<ItemAttributes>(); ItemEquippable value2 = ((Component)itemBattery).GetComponent<ItemEquippable>() ?? ((Component)itemBattery).GetComponentInParent<ItemEquippable>(); PhysGrabObject value3 = ((Component)itemBattery).GetComponent<PhysGrabObject>() ?? ((Component)itemBattery).GetComponentInChildren<PhysGrabObject>(true) ?? ((Component)itemBattery).GetComponentInParent<PhysGrabObject>(); PhotonView value4 = ((Component)itemBattery).GetComponent<PhotonView>() ?? ((Component)itemBattery).GetComponentInParent<PhotonView>(); Transform value5 = GetFieldValue<Transform>(itemBattery, "batteryTransform") ?? FindChildByExactName(((Component)itemBattery).transform, "Item Battery") ?? FindChildByExactName(((Component)itemBattery).transform, "Battery Graphic") ?? FindChildContaining(((Component)itemBattery).transform, "battery") ?? ((Component)itemBattery).transform; SetFieldIfNull(itemBattery, "itemAttributes", value); SetFieldIfNull(itemBattery, "itemEquippable", value2); SetFieldIfNull(itemBattery, "physGrabObject", value3); SetFieldIfNull(itemBattery, "photonView", value4); SetFieldValue(itemBattery, "batteryTransform", value5); int num = GetFieldValue(itemBattery, "batteryBars", 0); float fieldValue = GetFieldValue(itemBattery, "batteryLife", 100f); ItemGun val = ((Component)itemBattery).GetComponent<ItemGun>() ?? ((Component)itemBattery).GetComponentInParent<ItemGun>(); float batteryDrain = (((Object)(object)val != (Object)null) ? Mathf.Max(GetFieldValue(val, "batteryDrain", 1f), 0.01f) : 1f); int num2 = DeriveBatteryBars(fieldValue, batteryDrain); bool flag = ShouldUseDerivedBatteryBars(itemBattery, val, num, fieldValue, num2); if (num <= 0 || flag) { num = num2; SetFieldValue(itemBattery, "batteryBars", num); } int num3 = CalculateBatteryDisplayBars(fieldValue, num); if (GetFieldValue(itemBattery, "batteryLifeInt", -1) < 0 || flag) { SetFieldValue(itemBattery, "batteryLifeInt", num3); } if (GetFieldValue(itemBattery, "currentBars", -1) < 0 || flag) { SetFieldValue(itemBattery, "currentBars", num3); } if (GetFieldValue(itemBattery, "batteryLifeCountBars", -1) < 0 || flag) { SetFieldValue(itemBattery, "batteryLifeCountBars", num3); } if (GetFieldValue(itemBattery, "batteryLifeCountBarsPrev", -1) < 0 || flag) { SetFieldValue(itemBattery, "batteryLifeCountBarsPrev", num3); } if (GetFieldValue(itemBattery, "batteryLife", -1f) < 0f) { SetFieldValue(itemBattery, "batteryLife", 100f); } if (GetFieldValue(itemBattery, "batteryDrainRate", 0f) <= 0f) { SetFieldValue(itemBattery, "batteryDrainRate", 1f); } if (GetFieldValue(itemBattery, "chargeRate", 0f) <= 0f) { SetFieldValue(itemBattery, "chargeRate", 25f); } if (GetFieldValue<List<GameObject>>(itemBattery, "chargerList") == null) { SetFieldValue(itemBattery, "chargerList", new List<GameObject>()); } BatteryVisualLogic val2 = GetFieldValue<BatteryVisualLogic>(itemBattery, "batteryVisualLogic") ?? ((Component)itemBattery).GetComponentInChildren<BatteryVisualLogic>(true); if ((Object)(object)val2 == (Object)null && IsSceneInstance(((Component)itemBattery).gameObject)) { val2 = CreateBatteryVisualLogic(itemBattery, num); } if ((Object)(object)val2 != (Object)null) { EnsureBatteryVisualLogic(itemBattery, val2, num); SetFieldValue(itemBattery, "batteryVisualLogic", val2); } if (HasBatteryCompatibility(itemBattery)) { _preparedBatteryIds.Add(((Object)itemBattery).GetInstanceID()); } } } private void FinishBatteryStartInternal(ItemBattery? itemBattery) { if ((Object)(object)itemBattery == (Object)null || !IsTargetObject(GetRoot(((Component)itemBattery).gameObject))) { return; } int batteryBars = Mathf.Max(GetFieldValue(itemBattery, "batteryBars", 0), 1); BatteryVisualLogic val = GetFieldValue<BatteryVisualLogic>(itemBattery, "batteryVisualLogic") ?? ((Component)itemBattery).GetComponentInChildren<BatteryVisualLogic>(true); if ((Object)(object)val == (Object)null) { val = CreateBatteryVisualLogic(itemBattery, batteryBars); if ((Object)(object)val != (Object)null) { SetFieldValue(itemBattery, "batteryVisualLogic", val); } } if (!((Object)(object)val == (Object)null)) { EnsureBatteryVisualLogic(itemBattery, val, batteryBars); TryInvoke(val, "BatteryBarsSet"); if (!GetFieldValue(itemBattery, "batteryActive", fallback: false) && !GetFieldValue(itemBattery, "isCharging", fallback: false)) { ((Component)val).gameObject.SetActive(false); } SyncBatteryStateInternal(itemBattery, forceVisualUpdate: true); } } private bool CanRunBatteryUpdateInternal(ItemBattery? itemBattery) { if ((Object)(object)itemBattery == (Object)null || !IsTargetObject(GetRoot(((Component)itemBattery).gameObject))) { return true; } if (HasBatteryCompatibility(itemBattery)) { _preparedBatteryIds.Add(((Object)itemBattery).GetInstanceID()); return true; } PrepareBatteryInternal(itemBattery); if (HasBatteryCompatibility(itemBattery)) { _preparedBatteryIds.Add(((Object)itemBattery).GetInstanceID()); return true; } if (_loggedBatterySkips.Add(((Object)itemBattery).GetInstanceID())) { ManualLogSource logger = ((BaseUnityPlugin)this).Logger; GameObject root = GetRoot(((Component)itemBattery).gameObject); logger.LogWarning((object)("Empress Plasma Rifle Weapon Compat Patch skipped a broken battery update on " + (((root != null) ? ((Object)root).name : null) ?? ((Object)((Component)itemBattery).gameObject).name) + " until its compatibility data was restored.")); } return false; } private void PrepareGunInternal(ItemGun? itemGun) { if (!((Object)(object)itemGun == (Object)null) && IsTargetObject(GetRoot(((Component)itemGun).gameObject)) && !_preparedGunIds.Contains(((Object)itemGun).GetInstanceID())) { PhysGrabObject value = ((Component)itemGun).GetComponent<PhysGrabObject>() ?? ((Component)itemGun).GetComponentInChildren<PhysGrabObject>(true) ?? ((Component)itemGun).GetComponentInParent<PhysGrabObject>(); ItemToggle value2 = ((Component)itemGun).GetComponent<ItemToggle>() ?? ((Component)itemGun).GetComponentInParent<ItemToggle>(); ItemBattery val = ((Component)itemGun).GetComponent<ItemBattery>() ?? ((Component)itemGun).GetComponentInParent<ItemBattery>(); PhotonView value3 = ((Component)itemGun).GetComponent<PhotonView>() ?? ((Component)itemGun).GetComponentInParent<PhotonView>(); PhysGrabObjectImpactDetector value4 = ((Component)itemGun).GetComponent<PhysGrabObjectImpactDetector>() ?? ((Component)itemGun).GetComponentInParent<PhysGrabObjectImpactDetector>(); RoomVolumeCheck value5 = ((Component)itemGun).GetComponent<RoomVolumeCheck>() ?? ((Component)itemGun).GetComponentInParent<RoomVolumeCheck>(); ItemEquippable value6 = ((Component)itemGun).GetComponent<ItemEquippable>() ?? ((Component)itemGun).GetComponentInParent<ItemEquippable>(); Transform val2 = GetFieldValue<Transform>(itemGun, "gunMuzzle") ?? FindChildByExactName(((Component)itemGun).transform, "Gun Muzzle") ?? FindChildByExactName(((Component)itemGun).transform, "Muzzle") ?? FindChildContaining(((Component)itemGun).transform, "muzzle"); GameObject value7 = GetFieldValue<GameObject>(itemGun, "muzzleFlashPrefab") ?? FindGameObjectByExactName(((Component)itemGun).transform, "Muzzle Flash") ?? FindGameObjectByExactName(((Component)itemGun).transform, "MuzzleFlash") ?? FindGameObjectContaining(((Component)itemGun).transform, "muzzle", "flash"); GameObject val3 = GetFieldValue<GameObject>(itemGun, "bulletPrefab") ?? FindGameObjectByExactName(((Component)itemGun).transform, "Bullet") ?? FindGameObjectContaining(((Component)itemGun).transform, "bullet"); Transform value8 = GetFieldValue<Transform>(itemGun, "gunTrigger") ?? FindChildByExactName(((Component)itemGun).transform, "Gun Trigger") ?? FindChildByExactName(((Component)itemGun).transform, "Trigger") ?? val2 ?? ((Component)itemGun).transform; HurtCollider value9 = GetFieldValue<HurtCollider>(itemGun, "hurtCollider") ?? (((Object)(object)val3 != (Object)null) ? val3.GetComponentInChildren<HurtCollider>(true) : null) ?? ((Component)itemGun).GetComponentInChildren<HurtCollider>(true); SetFieldIfNull(itemGun, "physGrabObject", value); SetFieldIfNull(itemGun, "itemToggle", value2); SetFieldIfNull(itemGun, "itemBattery", val); SetFieldIfNull(itemGun, "photonView", value3); SetFieldIfNull(itemGun, "impactDetector", value4); SetFieldIfNull(itemGun, "roomVolumeCheck", value5); SetFieldIfNull(itemGun, "itemEquippable", value6); SetFieldIfNull(itemGun, "gunMuzzle", val2); SetFieldIfNull(itemGun, "muzzleFlashPrefab", value7); SetFieldIfNull(itemGun, "bulletPrefab", val3); SetFieldIfNull(itemGun, "gunTrigger", value8); SetFieldIfNull(itemGun, "hurtCollider", value9); if (GetFieldValue(itemGun, "numberOfBullets", 0) <= 0) { SetFieldValue(itemGun, "numberOfBullets", 1); } if (GetFieldValue(itemGun, "shootCooldown", 0f) <= 0f) { SetFieldValue(itemGun, "shootCooldown", 0.1f); } if (GetFieldValue(itemGun, "batteryDrain", 0f) <= 0f) { SetFieldValue(itemGun, "batteryDrain", 1f); } if (GetFieldValue(itemGun, "batteryDrainFullBar", fallback: false) && GetFieldValue(itemGun, "batteryDrainFullBars", 0) <= 0) { SetFieldValue(itemGun, "batteryDrainFullBars", Mathf.Max(1, Mathf.RoundToInt(GetFieldValue(itemGun, "batteryDrain", 1f)))); } if ((Object)(object)val != (Object)null) { PrepareBatteryInternal(val); } _preparedGunIds.Add(((Object)itemGun).GetInstanceID()); } } private void SyncGunBatteryInternal(ItemGun? itemGun) { if (!((Object)(object)itemGun == (Object)null) && IsTargetObject(GetRoot(((Component)itemGun).gameObject))) { PrepareGunInternal(itemGun); ItemBattery val = ((Component)itemGun).GetComponent<ItemBattery>() ?? ((Component)itemGun).GetComponentInParent<ItemBattery>(); if (!((Object)(object)val == (Object)null)) { SyncBatteryStateInternal(val, forceVisualUpdate: true); } } } private EmpressPlasmaRifleWeaponCompatPatchPluginPlasmaGunRelay EnsureCustomPlasmaGunRelay(Component plasmaGunComponent) { PreparePrefab(GetRoot(plasmaGunComponent.gameObject)); EnsurePhysGrabObjectColliders(GetFieldValue<PhysGrabObject>(plasmaGunComponent, "physGrabObject") ?? plasmaGunComponent.GetComponent<PhysGrabObject>()); EmpressPlasmaRifleWeaponCompatPatchPluginPlasmaGunRelay empressPlasmaRifleWeaponCompatPatchPluginPlasmaGunRelay = plasmaGunComponent.GetComponent<EmpressPlasmaRifleWeaponCompatPatchPluginPlasmaGunRelay>(); if ((Object)(object)empressPlasmaRifleWeaponCompatPatchPluginPlasmaGunRelay == (Object)null) { empressPlasmaRifleWeaponCompatPatchPluginPlasmaGunRelay = plasmaGunComponent.gameObject.AddComponent<EmpressPlasmaRifleWeaponCompatPatchPluginPlasmaGunRelay>(); } empressPlasmaRifleWeaponCompatPatchPluginPlasmaGunRelay.Initialize(plasmaGunComponent); return empressPlasmaRifleWeaponCompatPatchPluginPlasmaGunRelay; } private bool HandleCustomPlasmaGunShootBulletInternal(object? plasmaGun, Vector3 endPosition, bool hit) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) Component val = (Component)((plasmaGun is Component) ? plasmaGun : null); if (val == null) { return true; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { return true; } EmpressPlasmaRifleWeaponCompatPatchPluginPlasmaGunRelay empressPlasmaRifleWeaponCompatPatchPluginPlasmaGunRelay = EnsureCustomPlasmaGunRelay(val); if (SemiFunc.IsMultiplayer()) { PhotonView val2 = GetFieldValue<PhotonView>(plasmaGun, "photonView") ?? val.GetComponent<PhotonView>(); if ((Object)(object)val2 != (Object)null) { val2.RPC("EmpressCompatShootBulletRPC", (RpcTarget)0, new object[2] { endPosition, hit }); return true; } } empressPlasmaRifleWeaponCompatPatchPluginPlasmaGunRelay.EmpressCompatShootBulletRPC(endPosition, hit); return true; } private void HandleCustomPlasmaGunShootBulletRpcInternal(object? plasmaGun, Vector3 endPosition, bool hit, PhotonMessageInfo info) { //IL_0012: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) Component val = (Component)((plasmaGun is Component) ? plasmaGun : null); if (val == null || (SemiFunc.IsMultiplayer() && !SemiFunc.MasterOnlyRPC(info))) { return; } PhysGrabObject val2 = GetFieldValue<PhysGrabObject>(plasmaGun, "physGrabObject") ?? val.GetComponent<PhysGrabObject>(); PhotonView val3 = GetFieldValue<PhotonView>(plasmaGun, "photonView") ?? val.GetComponent<PhotonView>(); if ((Object)(object)val2 != (Object)null && val2.playerGrabbing.Count > 1) { foreach (PhysGrabber item in val2.playerGrabbing.Where((PhysGrabber grabber) => (Object)(object)grabber != (Object)null).ToList()) { item.OverrideGrabRelease((val3 != null) ? val3.ViewID : (-1), 0.5f); } } Transform val4 = GetFieldValue<Transform>(plasmaGun, "gunMuzzle") ?? val.transform; GameObject fieldValue = GetFieldValue<GameObject>(plasmaGun, "bulletPrefab"); if ((Object)(object)fieldValue != (Object)null) { Component val5 = ((IEnumerable<Component>)Object.Instantiate<GameObject>(fieldValue, val4.position, val4.rotation).GetComponentsInChildren<Component>(true)).FirstOrDefault((Func<Component, bool>)((Component component) => (Object)(object)component != (Object)null && string.Equals(((object)component).GetType().Name, "PlasmaProjectile", StringComparison.Ordinal))); if ((Object)(object)val5 != (Object)null) { TryInvoke(val5, "SetProjectileData", val4.position, endPosition, hit); SetFieldValue(plasmaGun, "hurtCollider", val5.GetComponentInChildren<HurtCollider>()); TryInvoke(val5, "ActivateAll"); } } Sound fieldValue2 = GetFieldValue<Sound>(plasmaGun, "soundHit"); if (fieldValue2 != null) { fieldValue2.Play(endPosition, 1f, 1f, 1f, 1f); } Component fieldValue3 = GetFieldValue<Component>(plasmaGun, "energyTrailParticles"); if ((Object)(object)fieldValue3 != (Object)null) { TryInvoke(fieldValue3, "Play"); } } private static void EnsurePhysGrabObjectColliders(PhysGrabObject? physGrabObject) { if ((Object)(object)physGrabObject == (Object)null) { return; } List<Transform> fieldValue = GetFieldValue(physGrabObject, "colliders", new List<Transform>()); fieldValue.Clear(); int num = 0; Collider[] componentsInChildren = ((Component)physGrabObject).GetComponentsInChildren<Collider>(true); foreach (Collider val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !val.isTrigger) { PhysGrabObjectCollider val2 = ((Component)val).GetComponent<PhysGrabObjectCollider>(); if ((Object)(object)val2 == (Object)null) { val2 = ((Component)val).gameObject.AddComponent<PhysGrabObjectCollider>(); } SetFieldValue(val2, "physGrabObject", physGrabObject); SetFieldValue(val2, "colliderID", num++); fieldValue.Add(((Component)val).transform); } } SetFieldValue(physGrabObject, "colliders", fieldValue); } private static void CleanupInvalidManagedLightTags(GameObject root) { Transform[] componentsInChildren = root.GetComponentsInChildren<Transform>(true); for (int i = 0; i < componentsInChildren.Length; i++) { GameObject gameObject = ((Component)componentsInChildren[i]).gameObject; if (gameObject.CompareTag("Prop Lights") && (Object)(object)gameObject.GetComponent<PropLight>() == (Object)null) { gameObject.tag = "Untagged"; } if (gameObject.CompareTag("Prop Emission") && (Object)(object)gameObject.GetComponent<PropLightEmission>() == (Object)null) { gameObject.tag = "Untagged"; } } } private void SyncBatteryStateInternal(ItemBattery? itemBattery, bool forceVisualUpdate) { if ((Object)(object)itemBattery == (Object)null || !IsTargetObject(GetRoot(((Component)itemBattery).gameObject))) { return; } if (!HasBatteryCompatibility(itemBattery)) { PrepareBatteryInternal(itemBattery); if (!HasBatteryCompatibility(itemBattery)) { return; } } int num = Mathf.Max(GetFieldValue(itemBattery, "batteryBars", 0), 1); int num2 = CalculateBatteryDisplayBars(Mathf.Clamp(GetFieldValue(itemBattery, "batteryLife", 100f), 0f, 100f), num); int fieldValue = GetFieldValue(itemBattery, "batteryLifeInt", num2); int fieldValue2 = GetFieldValue(itemBattery, "currentBars", num2); int fieldValue3 = GetFieldValue(itemBattery, "batteryLifeCountBars", num2); int fieldValue4 = GetFieldValue(itemBattery, "batteryLifeCountBarsPrev", num2); bool flag = fieldValue != num2 || fieldValue2 != num2 || fieldValue3 != num2 || fieldValue4 != num2; SetFieldValue(itemBattery, "batteryLifeInt", num2); SetFieldValue(itemBattery, "currentBars", num2); SetFieldValue(itemBattery, "batteryLifeCountBars", num2); SetFieldValue(itemBattery, "batteryLifeCountBarsPrev", num2); BatteryVisualLogic val = GetFieldValue<BatteryVisualLogic>(itemBattery, "batteryVisualLogic") ?? ((Component)itemBattery).GetComponentInChildren<BatteryVisualLogic>(true); if ((Object)(object)val != (Object)null) { EnsureBatteryVisualLogic(itemBattery, val, num); SetFieldValue(val, "currentBars", num2); if (!((Component)val).gameObject.activeSelf && (num2 < num || GetFieldValue(itemBattery, "batteryActive", fallback: false) || GetFieldValue(itemBattery, "isCharging", fallback: false))) { ((Component)val).gameObject.SetActive(true); } if (flag || forceVisualUpdate) { TryInvoke(val, "BatteryBarsSet"); TryInvoke(val, "BatteryBarsUpdate", num2, true); } if (num2 <= 0) { TryInvoke(val, "OverrideBatteryOutWarning", 0.2f); } else if (num2 <= Mathf.Max(1, num / 2)) { TryInvoke(val, "OverrideChargeNeeded", 0.2f); } else { TryInvoke(val, "BatteryColorMainReset"); } } SyncLegacyAmmoIndicator(itemBattery, num2, num); BatteryUI val2 = FindBatteryUiInstance(); BatteryVisualLogic val3 = (((Object)(object)val2 != (Object)null) ? (GetFieldValue<BatteryVisualLogic>(val2, "batteryVisualLogic") ?? ((Component)val2).GetComponentInChildren<BatteryVisualLogic>(true)) : null); if ((Object)(object)val2 != (Object)null && (Object)(object)val3 != (Object)null && (Object)(object)GetFieldValue<ItemBattery>(val3, "itemBattery") == (Object)(object)itemBattery) { SetFieldValue(val2, "batteryCurrentBars", num2); SetFieldValue(val2, "batteryCurrenyBarsMax", num); SetFieldValue(val3, "itemBattery", itemBattery); TryInvoke(val3, "BatteryBarsSet"); TryInvoke(val3, "BatteryBarsUpdate", num2, true); } } private static int DeriveBatteryBars(float legacyBatteryLife, float batteryDrain) { if (legacyBatteryLife > 0f && batteryDrain > 0f) { return Mathf.Clamp(Mathf.RoundToInt(legacyBatteryLife / batteryDrain), 1, 200); } if (legacyBatteryLife > 0f) { return Mathf.Clamp(Mathf.RoundToInt(legacyBatteryLife / 10f), 1, 200); } return 10; } private static bool ShouldUseDerivedBatteryBars(ItemBattery itemBattery, ItemGun? itemGun, int batteryBars, float legacyBatteryLife, int derivedBatteryBars) { if (derivedBatteryBars <= 0) { return false; } if (batteryBars <= 0) { return true; } if ((Object)(object)itemGun == (Object)null) { return false; } if ((Object)(object)(GetFieldValue<BatteryVisualLogic>(itemBattery, "batteryVisualLogic") ?? ((Component)itemBattery).GetComponentInChildren<BatteryVisualLogic>(true)) != (Object)null) { return false; } if (batteryBars != 6) { return false; } if (legacyBatteryLife < 99f) { return false; } int fieldValue = GetFieldValue(itemBattery, "batteryLifeInt", 6); int fieldValue2 = GetFieldValue(itemBattery, "currentBars", 6); if (fieldValue == 6) { return fieldValue2 == 6; } return false; } private static int CalculateBatteryDisplayBars(float batteryLife, int batteryBars) { if (batteryBars <= 0) { return 0; } float num = 100f / (float)batteryBars; if (num <= 0f) { return 0; } return Mathf.Clamp(Mathf.RoundToInt(batteryLife / num), 0, batteryBars); } private static void SyncLegacyAmmoIndicator(ItemBattery itemBattery, int desiredBars, int batteryBars) { if (!IsSceneInstance(((Component)itemBattery).gameObject)) { return; } Transform val = FindLegacyBatteryGraphic(itemBattery); if ((Object)(object)val == (Object)null) { return; } MeshRenderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<MeshRenderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Renderer)componentsInChildren[i]).enabled = false; } EmpressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicator empressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicator = (((Object)(object)val.parent != (Object)null) ? ((Component)val.parent).GetComponentInChildren<EmpressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicator>(true) : null); if ((Object)(object)empressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicator == (Object)null) { empressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicator = BuildLegacyAmmoIndicator(val); } if (!((Object)(object)empressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicator == (Object)null)) { int filledBars = ((batteryBars > 0) ? Mathf.Clamp(Mathf.CeilToInt((float)desiredBars / (float)batteryBars * (float)empressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicator.BarCount), 0, empressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicator.BarCount) : 0); EmpressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicatorState state = EmpressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicatorState.Normal; if (desiredBars <= 0) { state = EmpressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicatorState.Empty; } else if (desiredBars <= Mathf.Max(1, batteryBars / 2)) { state = EmpressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicatorState.Low; } empressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicator.SetDisplay(filledBars, state); } } private static Transform? FindLegacyBatteryGraphic(ItemBattery itemBattery) { return FindChildByExactName(((Component)itemBattery).transform, "Battery Graphic") ?? FindChildContaining(((Component)itemBattery).transform, "battery", "graphic"); } private static bool IsSceneInstance(GameObject gameObject) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) Scene scene = gameObject.scene; if (((Scene)(ref scene)).IsValid()) { scene = gameObject.scene; return ((Scene)(ref scene)).isLoaded; } return false; } private static BatteryUI? FindBatteryUiInstance() { return ((IEnumerable<BatteryUI>)Resources.FindObjectsOfTypeAll<BatteryUI>()).FirstOrDefault((Func<BatteryUI, bool>)delegate(BatteryUI ui) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ui != (Object)null) { Scene scene = ((Component)ui).gameObject.scene; return ((Scene)(ref scene)).IsValid(); } return false; }); } private static EmpressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicator? BuildLegacyAmmoIndicator(Transform legacyGraphic) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_015b: 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) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)legacyGraphic.parent == (Object)null) { return null; } GameObject val = CreateUiObject("Empress Legacy Ammo Indicator", legacyGraphic.parent, new Vector2(88f, 24f)); val.transform.localPosition = legacyGraphic.localPosition; val.transform.localRotation = legacyGraphic.localRotation; val.transform.localScale = new Vector3(Mathf.Max(legacyGraphic.localScale.x * 0.004f, 0.00075f), Mathf.Max(legacyGraphic.localScale.y * 0.004f, 0.00075f), Mathf.Max(legacyGraphic.localScale.z * 0.004f, 0.00075f)); Canvas obj = val.AddComponent<Canvas>(); obj.renderMode = (RenderMode)2; obj.overrideSorting = true; obj.sortingOrder = 2600; val.AddComponent<CanvasScaler>().dynamicPixelsPerUnit = 12f; val.AddComponent<GraphicRaycaster>(); EmpressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicator empressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicator = val.AddComponent<EmpressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicator>(); CreateImageObject("Frame Shadow", val.transform, new Vector2(0f, 0f), new Vector2(88f, 24f), new Color(0f, 0f, 0f, 0.45f)); RawImage frame = CreateImageObject("Frame Main", val.transform, new Vector2(0f, 0f), new Vector2(82f, 18f), new Color(0.25f, 1f, 0.15f, 1f)); RawImage background = CreateImageObject("Background", val.transform, new Vector2(0f, 0f), new Vector2(76f, 12f), new Color(0.03f, 0.07f, 0.03f, 0.92f)); GameObject val2 = CreateUiObject("Bar Container", val.transform, new Vector2(70f, 10f)); val2.GetComponent<RectTransform>().anchoredPosition = Vector2.zero; HorizontalLayoutGroup obj2 = val2.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj2).spacing = 2f; List<RawImage> list = new List<RawImage>(); for (int i = 0; i < 5; i++) { RawImage val3 = CreateUiObject("Bar " + (i + 1), val2.transform, new Vector2(10f, 10f)).AddComponent<RawImage>(); ((Graphic)val3).color = new Color(0.2f, 1f, 0.15f, 1f); list.Add(val3); } empressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicator.Initialize(frame, background, list); ApplyHideFlags((Object)(object)val); return empressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicator; } private static BatteryVisualLogic? CreateBatteryVisualLogic(ItemBattery itemBattery, int batteryBars) { BatteryVisualLogic val = CloneBatteryVisualLogic(itemBattery); if ((Object)(object)val != (Object)null) { return val; } return BuildBatteryVisualLogic(itemBattery, batteryBars); } private static BatteryVisualLogic? CloneBatteryVisualLogic(ItemBattery itemBattery) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) BatteryVisualLogic val = FindTemplateBatteryVisualLogic(itemBattery); if ((Object)(object)val == (Object)null) { return null; } GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)itemBattery).transform); ((Object)val2).name = "Empress Battery Visual Logic"; val2.transform.localPosition = new Vector3(0f, 0.35f, 0f); val2.transform.localRotation = Quaternion.identity; if (val2.transform.localScale == Vector3.zero) { val2.transform.localScale = Vector3.one * 0.0065f; } ApplyHideFlags((Object)(object)val2); return val2.GetComponent<BatteryVisualLogic>(); } private static BatteryVisualLogic? FindTemplateBatteryVisualLogic(ItemBattery itemBattery) { ItemBattery itemBattery2 = itemBattery; return (from visual in Resources.FindObjectsOfTypeAll<BatteryVisualLogic>() where (Object)(object)visual != (Object)null && (Object)(object)((Component)visual).gameObject != (Object)(object)((Component)itemBattery2).gameObject where (Object)(object)GetFieldValue<GameObject>(visual, "batteryBarPrefab") != (Object)null orderby GetFieldValue(visual, "inUI", fallback: false) ? 1 : 0, IsTargetObject(GetRoot(((Component)visual).gameObject)) ? 1 : 0 select visual).FirstOrDefault(); } private static BatteryVisualLogic BuildBatteryVisualLogic(ItemBattery itemBattery, int batteryBars) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0149: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) GameObject val = CreateUiObject("Empress Battery Visual Logic", ((Component)itemBattery).transform, new Vector2(92f, 26f)); val.transform.localPosition = new Vector3(0f, 0.35f, 0f); val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one * 0.0065f; Canvas obj = val.AddComponent<Canvas>(); obj.renderMode = (RenderMode)2; obj.overrideSorting = true; obj.sortingOrder = 2500; val.AddComponent<CanvasScaler>().dynamicPixelsPerUnit = 12f; val.AddComponent<GraphicRaycaster>(); BatteryVisualLogic obj2 = val.AddComponent<BatteryVisualLogic>(); RawImage value = CreateImageObject("Border Shadow", val.transform, new Vector2(0f, 0f), new Vector2(90f, 22f), new Color(0f, 0f, 0f, 0.45f)); RawImage value2 = CreateImageObject("Border Main", val.transform, new Vector2(0f, 0f), new Vector2(86f, 18f), new Color(0.96f, 0.86f, 0.2f, 1f)); RawImage value3 = CreateImageObject("Background", val.transform, new Vector2(0f, 0f), new Vector2(80f, 12f), new Color(0.08f, 0.08f, 0.08f, 0.88f)); RawImage val2 = CreateImageObject("Charge", val.transform, new Vector2(0f, 0f), new Vector2(76f, 10f), new Color(0.1f, 1f, 0.2f, 0.6f)); RawImage val3 = CreateImageObject("Drain", val.transform, new Vector2(0f, 0f), new Vector2(70f, 10f), new Color(1f, 0.35f, 0.1f, 0.6f)); GameObject val4 = CreateUiObject("Bar Container", val.transform, new Vector2(72f, 10f)); val4.GetComponent<RectTransform>().anchoredPosition = Vector2.zero; HorizontalLayoutGroup val5 = val4.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val5).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)val5).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)val5).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)val5).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val5).spacing = 2f; GameObject gameObject = ((Component)CreateImageObject("Battery Out Visual", val.transform, new Vector2(0f, 0f), new Vector2(88f, 24f), new Color(1f, 0f, 0f, 0.25f))).gameObject; gameObject.SetActive(false); GameObject gameObject2 = ((Component)CreateImageObject("Battery Charge Needed Visual", val.transform, new Vector2(0f, 0f), new Vector2(88f, 24f), new Color(1f, 0.55f, 0f, 0.2f))).gameObject; gameObject2.SetActive(false); GameObject gameObject3 = ((Component)CreateImageObject("Bar Prefab", val.transform, new Vector2(-5000f, -5000f), new Vector2(6f, 10f), new Color(1f, 0.92f, 0.3f, 1f))).gameObject; GameObject value4 = CreateBarEffectPrefab(val.transform); SetFieldValue(obj2, "batteryBarContainerGroup", val5); SetFieldValue(obj2, "batteryBarPrefab", gameObject3); SetFieldValue(obj2, "batteryBars", batteryBars); SetFieldValue(obj2, "batteryBarContainer", val4.transform); SetFieldValue(obj2, "inUI", false); SetFieldValue(obj2, "cameraTurn", true); SetFieldValue(obj2, "batteryBarCharge", ((Component)val2).transform); SetFieldValue(obj2, "batteryBarDrain", ((Component)val3).transform); SetFieldValue(obj2, "bars", new List<GameObject>()); SetFieldValue(obj2, "batteryBorderShadow", value); SetFieldValue(obj2, "batteryBorderMain", value2); SetFieldValue(obj2, "batteryBackground", value3); SetFieldValue(obj2, "batteryCharge", val2); SetFieldValue(obj2, "batteryDrain", val3); SetFieldValue(obj2, "batteryOutVisual", gameObject); SetFieldValue(obj2, "batteryChargeNeededVisual", gameObject2); SetFieldValue(obj2, "barLossEffectPrefab", value4); ApplyHideFlags((Object)(object)val); return obj2; } private static RawImage CreateImageObject(string name, Transform parent, Vector2 anchoredPosition, Vector2 size, Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) GameObject obj = CreateUiObject(name, parent, size); obj.GetComponent<RectTransform>().anchoredPosition = anchoredPosition; RawImage obj2 = obj.AddComponent<RawImage>(); ((Graphic)obj2).color = color; return obj2; } private static GameObject CreateUiObject(string name, Transform parent, Vector2 size) { //IL_0021: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(CanvasRenderer) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 0.5f); component.sizeDelta = size; return val; } private static GameObject CreateBarEffectPrefab(Transform parent) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown GameObject val = CreateUiObject("Bar Effect Prefab", parent, new Vector2(6f, 10f)); val.GetComponent<RectTransform>().anchoredPosition = new Vector2(-6000f, -6000f); ((Graphic)val.AddComponent<RawImage>()).color = Color.red; BatteryBarEffect val2 = val.AddComponent<BatteryBarEffect>(); val2.barLossEffect = true; val2.barColor = Color.red; val2.barAnimationCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f); val2.barFadeOutCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, 1f), new Keyframe(1f, 0f) }); val2.whiteFlashCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[3] { new Keyframe(0f, 0f), new Keyframe(0.2f, 1f), new Keyframe(1f, 0f) }); return val; } private static void EnsureBatteryVisualLogic(ItemBattery itemBattery, BatteryVisualLogic batteryVisualLogic, int batteryBars) { SetFieldValue(itemBattery, "batteryVisualLogic", batteryVisualLogic); SetFieldValue(itemBattery, "batteryTransform", GetFieldValue<Transform>(itemBattery, "batteryTransform") ?? ((Component)batteryVisualLogic).transform); SetFieldValue(itemBattery, "batteryBars", batteryBars); SetFieldValue(itemBattery, "batteryLifeInt", Mathf.Clamp(GetFieldValue(itemBattery, "batteryLifeInt", batteryBars), 0, batteryBars)); SetFieldValue(itemBattery, "currentBars", Mathf.Clamp(GetFieldValue(itemBattery, "currentBars", batteryBars), 0, batteryBars)); SetFieldValue(itemBattery, "batteryLifeCountBars", Mathf.Clamp(GetFieldValue(itemBattery, "batteryLifeCountBars", batteryBars), 0, batteryBars)); SetFieldValue(itemBattery, "batteryLifeCountBarsPrev", Mathf.Clamp(GetFieldValue(itemBattery, "batteryLifeCountBarsPrev", batteryBars), 0, batteryBars)); SetFieldValue(batteryVisualLogic, "itemBattery", itemBattery); SetFieldValue(batteryVisualLogic, "batteryBars", batteryBars); SetFieldValue(batteryVisualLogic, "currentBars", GetFieldValue(itemBattery, "currentBars", batteryBars)); if ((Object)(object)GetFieldValue<HorizontalLayoutGroup>(batteryVisualLogic, "batteryBarContainerGroup") == (Object)null) { SetFieldValue(batteryVisualLogic, "batteryBarContainerGroup", ((Component)batteryVisualLogic).GetComponentInChildren<HorizontalLayoutGroup>(true)); } if ((Object)(object)GetFieldValue<Transform>(batteryVisualLogic, "batteryBarContainer") == (Object)null) { SetFieldValue(batteryVisualLogic, "batteryBarContainer", FindChildByExactName(((Component)batteryVisualLogic).transform, "Bar Container")); } if ((Object)(object)GetFieldValue<GameObject>(batteryVisualLogic, "batteryBarPrefab") == (Object)null) { SetFieldValue(batteryVisualLogic, "batteryBarPrefab", FindGameObjectByExactName(((Component)batteryVisualLogic).transform, "Bar Prefab")); } if ((Object)(object)GetFieldValue<Transform>(batteryVisualLogic, "batteryBarCharge") == (Object)null) { SetFieldValue(batteryVisualLogic, "batteryBarCharge", FindChildByExactName(((Component)batteryVisualLogic).transform, "Charge")); } if ((Object)(object)GetFieldValue<Transform>(batteryVisualLogic, "batteryBarDrain") == (Object)null) { SetFieldValue(batteryVisualLogic, "batteryBarDrain", FindChildByExactName(((Component)batteryVisualLogic).transform, "Drain")); } if ((Object)(object)GetFieldValue<RawImage>(batteryVisualLogic, "batteryBorderShadow") == (Object)null) { Transform? obj = FindChildByExactName(((Component)batteryVisualLogic).transform, "Border Shadow"); SetFieldValue(batteryVisualLogic, "batteryBorderShadow", (obj != null) ? ((Component)obj).GetComponent<RawImage>() : null); } if ((Object)(object)GetFieldValue<RawImage>(batteryVisualLogic, "batteryBorderMain") == (Object)null) { Transform? obj2 = FindChildByExactName(((Component)batteryVisualLogic).transform, "Border Main"); SetFieldValue(batteryVisualLogic, "batteryBorderMain", (obj2 != null) ? ((Component)obj2).GetComponent<RawImage>() : null); } if ((Object)(object)GetFieldValue<RawImage>(batteryVisualLogic, "batteryBackground") == (Object)null) { Transform? obj3 = FindChildByExactName(((Component)batteryVisualLogic).transform, "Background"); SetFieldValue(batteryVisualLogic, "batteryBackground", (obj3 != null) ? ((Component)obj3).GetComponent<RawImage>() : null); } if ((Object)(object)GetFieldValue<RawImage>(batteryVisualLogic, "batteryCharge") == (Object)null) { Transform? obj4 = FindChildByExactName(((Component)batteryVisualLogic).transform, "Charge"); SetFieldValue(batteryVisualLogic, "batteryCharge", (obj4 != null) ? ((Component)obj4).GetComponent<RawImage>() : null); } if ((Object)(object)GetFieldValue<RawImage>(batteryVisualLogic, "batteryDrain") == (Object)null) { Transform? obj5 = FindChildByExactName(((Component)batteryVisualLogic).transform, "Drain"); SetFieldValue(batteryVisualLogic, "batteryDrain", (obj5 != null) ? ((Component)obj5).GetComponent<RawImage>() : null); } if ((Object)(object)GetFieldValue<GameObject>(batteryVisualLogic, "batteryOutVisual") == (Object)null) { SetFieldValue(batteryVisualLogic, "batteryOutVisual", FindGameObjectByExactName(((Component)batteryVisualLogic).transform, "Battery Out Visual")); } if ((Object)(object)GetFieldValue<GameObject>(batteryVisualLogic, "batteryChargeNeededVisual") == (Object)null) { SetFieldValue(batteryVisualLogic, "batteryChargeNeededVisual", FindGameObjectByExactName(((Component)batteryVisualLogic).transform, "Battery Charge Needed Visual")); } if ((Object)(object)GetFieldValue<GameObject>(batteryVisualLogic, "barLossEffectPrefab") == (Object)null) { SetFieldValue(batteryVisualLogic, "barLossEffectPrefab", FindGameObjectByExactName(((Component)batteryVisualLogic).transform, "Bar Effect Prefab")); } if (GetFieldValue<List<GameObject>>(batteryVisualLogic, "bars") == null) { SetFieldValue(batteryVisualLogic, "bars", new List<GameObject>()); } } private static bool IsTargetObject(GameObject? gameObject) { if ((Object)(object)gameObject == (Object)null) { return false; } if ((Object)(object)Instance != (Object)null && Instance._targetRootCache.TryGetValue(((Object)(object)gameObject.transform.root != (Object)null) ? ((Object)((Component)gameObject.transform.root).gameObject).GetInstanceID() : ((Object)gameObject).GetInstanceID(), out var value)) { return value; } GameObject root = GetRoot(gameObject); bool flag = false; foreach (string item in EnumerateCandidateNames(root)) { if (MatchesTargetToken(item)) { flag = true; break; } } if ((Object)(object)Instance != (Object)null) { Instance._targetRootCache[((Object)root).GetInstanceID()] = flag; } return flag; } private static IEnumerable<string> EnumerateCandidateNames(GameObject root) { yield return ((Object)root).name; ItemAttributes[] componentsInChildren = root.GetComponentsInChildren<ItemAttributes>(true); foreach (ItemAttributes itemAttributes in componentsInChildren) { yield return ((Object)itemAttributes).name; yield return GetFieldValue(itemAttributes, "itemName", string.Empty); yield return GetFieldValue(itemAttributes, "itemAssetName", string.Empty); Item fieldValue = GetFieldValue<Item>(itemAttributes, "item"); if ((Object)(object)fieldValue != (Object)null) { yield return ((Object)fieldValue).name; } } ItemGun[] componentsInChildren2 = root.GetComponentsInChildren<ItemGun>(true); foreach (ItemGun val in componentsInChildren2) { yield return ((Object)val).name; } ItemBattery[] componentsInChildren3 = root.GetComponentsInChildren<ItemBattery>(true); foreach (ItemBattery val2 in componentsInChildren3) { yield return ((Object)val2).name; } } private static bool MatchesTargetToken(string? value) { string value2 = value; if (string.IsNullOrWhiteSpace(value2)) { return false; } return TargetTokens.Where((string token) => !string.IsNullOrWhiteSpace(token)).Any((string token) => value2.IndexOf(token, StringComparison.OrdinalIgnoreCase) >= 0); } private static GameObject GetRoot(GameObject gameObject) { if (!((Object)(object)gameObject.transform.root != (Object)null)) { return gameObject; } return ((Component)gameObject.transform.root).gameObject; } private static Transform? FindChildByExactName(Transform root, string name) { string name2 = name; return ((IEnumerable<Transform>)((Component)root).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform child) => string.Equals(((Object)child).name, name2, StringComparison.OrdinalIgnoreCase))); } private static Transform? FindChildContaining(Transform root, params string[] fragments) { string[] fragments2 = fragments; return ((IEnumerable<Transform>)((Component)root).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform child) => fragments2.All((string fragment) => ((Object)child).name.IndexOf(fragment, StringComparison.OrdinalIgnoreCase) >= 0))); } private static GameObject? FindGameObjectByExactName(Transform root, string name) { Transform? obj = FindChildByExactName(root, name); if (obj == null) { return null; } return ((Component)obj).gameObject; } private static GameObject? FindGameObjectContaining(Transform root, params string[] fragments) { Transform? obj = FindChildContaining(root, fragments); if (obj == null) { return null; } return ((Component)obj).gameObject; } private static T? GetFieldValue<T>(object instance, string fieldName) { return GetFieldValue(instance, fieldName, default(T)); } private static T GetFieldValue<T>(object instance, string fieldName, T fallback) { if (instance == null) { return fallback; } MemberInfo memberInfo = ResolveMember(instance.GetType(), fieldName); object obj = ((memberInfo is FieldInfo fieldInfo) ? fieldInfo.GetValue(instance) : ((!(memberInfo is PropertyInfo propertyInfo) || !propertyInfo.CanRead) ? null : propertyInfo.GetValue(instance))); object obj2 = obj; if (obj2 is T) { return (T)obj2; } if (obj2 == null) { return fallback; } try { return (T)Convert.ChangeType(obj2, typeof(T)); } catch { return fallback; } } private static void SetFieldValue(object instance, string fieldName, object? value) { if (instance == null) { return; } MemberInfo memberInfo = ResolveMember(instance.GetType(), fieldName); if (!(memberInfo is FieldInfo fieldInfo)) { if (memberInfo is PropertyInfo propertyInfo && propertyInfo.CanWrite) { propertyInfo.SetValue(instance, value); } } else { fieldInfo.SetValue(instance, value); } } private static void SetFieldIfNull(object instance, string fieldName, object? value) { if (value != null) { MemberInfo memberInfo = ResolveMember(instance.GetType(), fieldName); object obj = ((memberInfo is FieldInfo fieldInfo) ? fieldInfo.GetValue(instance) : ((!(memberInfo is PropertyInfo propertyInfo) || !propertyInfo.CanRead) ? new object() : propertyInfo.GetValue(instance))); if (obj == null) { SetFieldValue(instance, fieldName, value); } } } private static void TryInvoke(object instance, string methodName, params object[] args) { AccessTools.Method(instance.GetType(), methodName, (Type[])null, (Type[])null)?.Invoke(instance, args); } private static void ApplyHideFlags(Object obj) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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) obj.hideFlags = (HideFlags)(obj.hideFlags | 0x23); GameObject val = (GameObject)(object)((obj is GameObject) ? obj : null); if (val == null) { return; } Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>(true); foreach (Transform obj2 in componentsInChildren) { ((Object)obj2).hideFlags = (HideFlags)(((Object)obj2).hideFlags | 0x23); GameObject gameObject = ((Component)obj2).gameObject; ((Object)gameObject).hideFlags = (HideFlags)(((Object)gameObject).hideFlags | 0x23); Component[] components = ((Component)obj2).GetComponents<Component>(); foreach (Component val2 in components) { if ((Object)(object)val2 != (Object)null) { ((Object)val2).hideFlags = (HideFlags)(((Object)val2).hideFlags | 0x23); } } } } private static MemberInfo? ResolveMember(Type type, string memberName) { string key = type.AssemblyQualifiedName + "|" + memberName; if (MemberCache.TryGetValue(key, out MemberInfo value)) { return value; } Type type2 = type; while (type2 != null) { FieldInfo field = type2.GetField(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { MemberCache[key] = field; return field; } PropertyInfo property = type2.GetProperty(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null) { MemberCache[key] = property; return property; } type2 = type2.BaseType; } MemberCache[key] = null; return null; } private static bool HasBatteryCompatibility(ItemBattery itemBattery) { if ((Object)(object)GetFieldValue<BatteryVisualLogic>(itemBattery, "batteryVisualLogic") != (Object)null && (Object)(object)GetFieldValue<ItemAttributes>(itemBattery, "itemAttributes") != (Object)null && (Object)(object)GetFieldValue<ItemEquippable>(itemBattery, "itemEquippable") != (Object)null) { return (Object)(object)GetFieldValue<PhysGrabObject>(itemBattery, "physGrabObject") != (Object)null; } return false; } } [HarmonyPatch(typeof(Items), "RegisterItem", new Type[] { typeof(ItemContent) })] internal static class EmpressPlasmaRifleWeaponCompatPatchPluginRegisterItemContentPatch { [HarmonyPrefix] private static void Prefix(ItemContent itemContent) { EmpressPlasmaRifleWeaponCompatPatchPlugin.PrepareRegisteredItem(itemContent); } } [HarmonyPatch(typeof(Items), "RegisterItem", new Type[] { typeof(ItemAttributes) })] internal static class EmpressPlasmaRifleWeaponCompatPatchPluginRegisterItemAttributesPatch { [HarmonyPrefix] private static void Prefix(ItemAttributes itemAttributes) { EmpressPlasmaRifleWeaponCompatPatchPlugin.PrepareRegisteredItem(itemAttributes); } } [HarmonyPatch(typeof(ItemBattery), "Start")] internal static class EmpressPlasmaRifleWeaponCompatPatchPluginItemBatteryStartPatch { [HarmonyPrefix] private static void Prefix(ItemBattery __instance) { EmpressPlasmaRifleWeaponCompatPatchPlugin.PrepareBattery(__instance); } [HarmonyPostfix] private static void Postfix(ItemBattery __instance) { EmpressPlasmaRifleWeaponCompatPatchPlugin.FinishBatteryStart(__instance); } } [HarmonyPatch(typeof(ItemGun), "Start")] internal static class EmpressPlasmaRifleWeaponCompatPatchPluginItemGunStartPatch { [HarmonyPrefix] private static void Prefix(ItemGun __instance) { EmpressPlasmaRifleWeaponCompatPatchPlugin.PrepareGun(__instance); } } [HarmonyPatch(typeof(ItemGun), "ShootRPC")] internal static class EmpressPlasmaRifleWeaponCompatPatchPluginItemGunShootRpcPatch { [HarmonyPostfix] private static void Postfix(ItemGun __instance) { EmpressPlasmaRifleWeaponCompatPatchPlugin.SyncGunBattery(__instance); } } [HarmonyPatch(typeof(ItemBattery), "RemoveFullBar")] internal static class EmpressPlasmaRifleWeaponCompatPatchPluginItemBatteryRemoveFullBarPatch { [HarmonyPostfix] private static void Postfix(ItemBattery __instance) { EmpressPlasmaRifleWeaponCompatPatchPlugin.SyncBattery(__instance); } } [HarmonyPatch(typeof(ItemBattery), "SetBatteryLife")] internal static class EmpressPlasmaRifleWeaponCompatPatchPluginItemBatterySetBatteryLifePatch { [HarmonyPostfix] private static void Postfix(ItemBattery __instance) { EmpressPlasmaRifleWeaponCompatPatchPlugin.SyncBattery(__instance); } } [HarmonyPatch(typeof(ItemBattery), "BatteryFullPercentChangeLogic")] internal static class EmpressPlasmaRifleWeaponCompatPatchPluginItemBatteryFullPercentChangeLogicPatch { [HarmonyPostfix] private static void Postfix(ItemBattery __instance) { EmpressPlasmaRifleWeaponCompatPatchPlugin.SyncBattery(__instance); } } internal sealed class EmpressPlasmaRifleWeaponCompatPatchPluginPlasmaGunRelay : MonoBehaviour { private Component? _plasmaGun; internal void Initialize(Component plasmaGun) { _plasmaGun = plasmaGun; } private Component? ResolvePlasmaGun() { if ((Object)(object)_plasmaGun != (Object)null) { return _plasmaGun; } _plasmaGun = ((IEnumerable<Component>)((Component)this).GetComponents<Component>()).FirstOrDefault((Func<Component, bool>)((Component component) => (Object)(object)component != (Object)null && (Object)(object)component != (Object)(object)this && string.Equals(((object)component).GetType().Name, "ItemPlasmaGun", StringComparison.Ordinal))); return _plasmaGun; } [PunRPC] public void EmpressCompatShootBulletRPC(Vector3 _endPosition, bool _hit, PhotonMessageInfo _info = default(PhotonMessageInfo)) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) EmpressPlasmaRifleWeaponCompatPatchPlugin.HandleCustomPlasmaGunShootBulletRpc(ResolvePlasmaGun(), _endPosition, _hit, _info); } } internal enum EmpressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicatorState { Normal, Low, Empty } internal sealed class EmpressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicator : MonoBehaviour { private RawImage _frame; private RawImage _background; private List<RawImage> _bars; internal int BarCount => _bars?.Count ?? 0; internal void Initialize(RawImage frame, RawImage background, List<RawImage> bars) { _frame = frame; _background = background; _bars = bars; } internal void SetDisplay(int filledBars, EmpressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicatorState state) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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) //IL_00ea: 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_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) if (_bars != null && _bars.Count != 0) { Color color = (Color)(state switch { EmpressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicatorState.Empty => new Color(1f, 0.18f, 0.18f, 1f), EmpressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicatorState.Low => new Color(1f, 0.82f, 0.2f, 1f), _ => new Color(0.25f, 1f, 0.15f, 1f), }); Color val = (Color)(state switch { EmpressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicatorState.Empty => new Color(1f, 0.18f, 0.18f, 1f), EmpressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicatorState.Low => new Color(1f, 0.82f, 0.2f, 1f), _ => new Color(0.25f, 1f, 0.15f, 1f), }); Color val2 = (Color)(state switch { EmpressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicatorState.Empty => new Color(0.22f, 0.02f, 0.02f, 0.95f), EmpressPlasmaRifleWeaponCompatPatchPluginLegacyAmmoIndicatorState.Low => new Color(0.12f, 0.09f, 0.02f, 0.92f), _ => new Color(0.02f, 0.08f, 0.02f, 0.9f), }); ((Graphic)_frame).color = color; ((Graphic)_background).color = val2; for (int i = 0; i < _bars.Count; i++) { ((Graphic)_bars[i]).color = ((i < filledBars) ? val : val2); } } } } }