using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ZeroGravityExtractionDroneToOrbFix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ZeroGravityExtractionDroneToOrbFix")] [assembly: AssemblyTitle("ZeroGravityExtractionDroneToOrbFix")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ZeroGravityExtractionDroneToOrbFix { [BepInPlugin("REPOJP.ZeroGravityExtractionDroneToOrbFix", "ZeroGravityExtraction DroneToOrbItem Fix", "1.0.6")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { private sealed class Candidate { public readonly string ItemName; public readonly string ResourcePath; public readonly GameObject AffectPrefab; public readonly int Score; public Candidate(string itemName, string resourcePath, GameObject affectPrefab, int score) { ItemName = itemName; ResourcePath = resourcePath; AffectPrefab = affectPrefab; Score = score; } } public const string PluginGuid = "REPOJP.ZeroGravityExtractionDroneToOrbFix"; public const string PluginName = "ZeroGravityExtraction DroneToOrbItem Fix"; public const string PluginVersion = "1.0.6"; private static readonly Dictionary TypeCache = new Dictionary(); private static readonly HashSet MissingTypeCache = new HashSet(); private static readonly Dictionary MemberCache = new Dictionary(); private static readonly Dictionary FieldCache = new Dictionary(); private static readonly object MissingMember = new object(); private static readonly object MissingField = new object(); private static ManualLogSource Log; private static float _nextDebugLog; private static MethodInfo _isMultiplayerMethod; private static readonly HashSet ProtectedExternalConnectionDrones = new HashSet(); private static readonly Dictionary ProtectedExternalConnectionLastSeen = new Dictionary(); private static readonly Dictionary ProtectedExternalConnectionKeys = new Dictionary(); private static readonly HashSet AnchorAssistedDrones = new HashSet(); private Harmony _harmony; private bool _patched; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; } private IEnumerator Start() { yield return null; yield return null; ApplyPatches(); } private void OnDestroy() { if (_harmony != null) { _harmony.UnpatchSelf(); } } private void ApplyPatches() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (!_patched) { _patched = true; _harmony = new Harmony("REPOJP.ZeroGravityExtractionDroneToOrbFix"); PatchZeroGravityExtraction(_harmony); Log.LogInfo((object)"ZeroGravityExtraction DroneToOrbItem Fix v1.0.6 loaded."); } } private static void PatchZeroGravityExtraction(Harmony harmony) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Expected O, but got Unknown Type type = FindType("ZeroGravityExtraction.Services.ZeroGravityPadService"); if (type == null) { Log.LogError((object)"ZeroGravityPadService type was not found."); return; } MethodInfo methodInfo = AccessTools.Method(type, "TryResolveEffect", (Type[])null, (Type[])null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Plugin), "TryResolveEffectPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Patched TryResolveEffect for robust v1.1.1 resolver retry/fallback."); } MethodInfo methodInfo2 = AccessTools.Method(type, "Tick", (Type[])null, (Type[])null); if (methodInfo2 != null) { harmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(Plugin), "TickPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } MethodInfo methodInfo3 = AccessTools.Method(type, "ResetLevelState", (Type[])null, (Type[])null); MethodInfo methodInfo4 = AccessTools.Method(type, "EnsureAnchor", (Type[])null, (Type[])null); MethodInfo methodInfo5 = AccessTools.Method(type, "CollectDroneZoneTargets", (Type[])null, (Type[])null); if (methodInfo3 != null) { harmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "ResetLevelStatePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } if (methodInfo4 != null) { harmony.Patch((MethodBase)methodInfo4, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "EnsureAnchorPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } if (methodInfo5 != null) { harmony.Patch((MethodBase)methodInfo5, new HarmonyMethod(typeof(Plugin), "CollectDroneZoneTargetsPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } MethodInfo methodInfo6 = AccessTools.Method(type, "IsPadPowered", (Type[])null, (Type[])null); if (methodInfo6 != null) { harmony.Patch((MethodBase)methodInfo6, new HarmonyMethod(typeof(Plugin), "IsPadPoweredPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Patched IsPadPowered for in-zone native connection gate."); } PatchItemDrone(harmony); } private static void PatchItemDrone(Harmony harmony) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_006f: Expected O, but got Unknown Type type = FindType("ItemDrone"); if (type == null) { Log.LogWarning((object)"ItemDrone type was not found. Multiplayer anchor assist disabled."); return; } MethodInfo methodInfo = AccessTools.Method(type, "Update", (Type[])null, (Type[])null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Plugin), "ItemDroneUpdatePrefix", (Type[])null), new HarmonyMethod(typeof(Plugin), "ItemDroneUpdatePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Patched ItemDrone.Update for external-connection origin tracking."); } } private static void ResetLevelStatePostfix(object __instance) { ResetResolveFailure(__instance); } private static void TickPrefix(object __instance) { if (GetMember(__instance, "_affectPrefab") == null) { ResetResolveFailure(__instance); } } private static bool TryResolveEffectPrefix(object __instance, ref bool __result) { __result = TryResolveEffect(__instance); return false; } private static void EnsureAnchorPostfix(object __instance) { ConfigureVanillaPlusAnchors(__instance); } private static void CollectDroneZoneTargetsPrefix(object __instance) { ConfigureVanillaPlusAnchors(__instance); } private static void ItemDroneUpdatePrefix(object __instance) { object zeroGravityPadServiceInstance = GetZeroGravityPadServiceInstance(); if (zeroGravityPadServiceInstance != null) { ConfigureVanillaPlusAnchors(zeroGravityPadServiceInstance); AssistDroneToNearestAnchor(__instance, GetDroneAnchors(zeroGravityPadServiceInstance)); } } private static void ItemDroneUpdatePostfix(object __instance) { object zeroGravityPadServiceInstance = GetZeroGravityPadServiceInstance(); if (zeroGravityPadServiceInstance != null) { AssistDroneToNearestAnchor(__instance, GetDroneAnchors(zeroGravityPadServiceInstance)); } } private static object GetZeroGravityPadServiceInstance() { object staticMember = GetStaticMember("ZeroGravityExtraction.Services.ZeroGravityPadService", "Instance"); if (staticMember != null) { return staticMember; } return GetStaticMember("ZeroGravityPadService", "Instance"); } private static bool IsPadPoweredPrefix(object __instance, object point, ref bool __result) { __result = IsPadPoweredStrict(__instance, point); return false; } private static bool IsPadPoweredStrict(object service, object point) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) if (service == null || point == null) { return false; } GameObject anchorForPoint = GetAnchorForPoint(service, point); if ((Object)(object)anchorForPoint == (Object)null || IsButtonModeAnchor(anchorForPoint)) { return false; } List droneAnchors = GetDroneAnchors(service); if (!(GetStaticMember("ItemDrone", "activeDrones") is IEnumerable enumerable)) { return false; } foreach (object item in enumerable) { if (!IsPoweredZeroGravityDrone(item)) { UnprotectExternalConnectionDrone(item); continue; } Component val = (Component)((item is Component) ? item : null); if (!((Object)(object)val == (Object)null)) { bool num = IsInsideExtractionZone(point, val.transform.position, anchorForPoint); bool insideExtractionZone = IsInsideAnyExtractionZone(val.transform.position, droneAnchors); bool flag = HasActiveNonAnchorConnection(item, droneAnchors); UpdateExternalConnectionProtection(item, droneAnchors, insideExtractionZone, flag); if (num && flag && !IsProtectedExternalConnectionDrone(item)) { return true; } } } return false; } private static bool HasVisibleBeamToAnchor(GameObject droneObject, GameObject anchor) { //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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00b4: 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_00c2: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)droneObject == (Object)null || (Object)(object)anchor == (Object)null) { return false; } LineRenderer[] componentsInChildren = droneObject.GetComponentsInChildren(true); foreach (LineRenderer val in componentsInChildren) { if ((Object)(object)val == (Object)null || !((Renderer)val).enabled || val.positionCount < 2) { continue; } GameObject gameObject = ((Component)val).gameObject; if (!((Object)(object)gameObject == (Object)null) && gameObject.activeInHierarchy) { Vector3 val2 = val.GetPosition(0); Vector3 val3 = val.GetPosition(val.positionCount - 1); if (!val.useWorldSpace) { val2 = ((Component)val).transform.TransformPoint(val2); val3 = ((Component)val).transform.TransformPoint(val3); } Vector3 val4 = val2 - anchor.transform.position; float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude; val4 = val3 - anchor.transform.position; float sqrMagnitude2 = ((Vector3)(ref val4)).sqrMagnitude; if (sqrMagnitude <= 2.25f || sqrMagnitude2 <= 2.25f) { return true; } } } return false; } private static void ConfigureVanillaPlusAnchors(object service) { IEnumerable dictionaryValues = GetDictionaryValues(GetMember(service, "_anchors")); if (dictionaryValues == null) { return; } foreach (object item in dictionaryValues) { GameObject val = (GameObject)((item is GameObject) ? item : null); if (!((Object)(object)val == (Object)null) && !IsButtonModeAnchor(val)) { ConfigureDroneAnchor(val); } } } private static void ConfigureDroneAnchor(GameObject anchor) { if ((Object)(object)anchor == (Object)null) { return; } try { anchor.tag = "Phys Grab Object"; } catch { } try { int num = LayerMask.NameToLayer("PhysGrabObject"); if (num >= 0) { anchor.layer = num; } } catch { } Collider val = anchor.GetComponent(); if ((Object)(object)val == (Object)null) { val = (Collider)(object)anchor.AddComponent(); } val.enabled = true; val.isTrigger = false; Rigidbody val2 = anchor.GetComponent(); if ((Object)(object)val2 == (Object)null) { val2 = anchor.AddComponent(); } val2.useGravity = false; val2.isKinematic = true; val2.constraints = (RigidbodyConstraints)126; object orAddComponentByName = GetOrAddComponentByName(anchor, "PhysGrabObject"); if (orAddComponentByName != null) { SetMember(orAddComponentByName, "isNonValuable", true); SetMember(orAddComponentByName, "isValuable", false); SetMember(orAddComponentByName, "isEnemy", false); SetMember(orAddComponentByName, "grabDisable", false); SetMember(orAddComponentByName, "disabled", false); SetMember(orAddComponentByName, "dead", false); } GetOrAddComponentByName(anchor, "PhysGrabObjectCollider"); EnsurePhotonView(anchor); Renderer component = anchor.GetComponent(); if ((Object)(object)component != (Object)null) { component.enabled = false; } } private static void EnsurePhotonView(GameObject anchor) { object obj = GetComponentByName(anchor, "PhotonView"); if (obj == null) { obj = GetOrAddComponentByName(anchor, "PhotonView"); } if (obj == null || !IsMultiplayer()) { return; } object member = GetMember(obj, "ViewID"); if (member is int && (int)member != 0) { return; } Type type = FindType("Photon.Pun.PhotonNetwork"); if (type == null) { return; } try { MethodInfo methodInfo = AccessTools.Method(type, "AllocateViewID", new Type[1] { obj.GetType() }, (Type[])null); if (methodInfo != null) { methodInfo.Invoke(null, new object[1] { obj }); } } catch { } } private static void AssistMultiplayerDrones(object service) { List droneAnchors = GetDroneAnchors(service); if (droneAnchors.Count == 0 || !(GetStaticMember("ItemDrone", "activeDrones") is IEnumerable enumerable)) { return; } foreach (object item in enumerable) { AssistDroneToNearestAnchor(item, droneAnchors); } } private static GameObject GetAnchorForPoint(object service, object point) { IDictionary dictionary = GetMember(service, "_anchors") as IDictionary; int unityInstanceId = GetUnityInstanceId(point); if (dictionary != null && unityInstanceId != 0) { if (dictionary.Contains(unityInstanceId)) { object? obj = dictionary[unityInstanceId]; return (GameObject)((obj is GameObject) ? obj : null); } foreach (DictionaryEntry item in dictionary) { if (item.Key is int && (int)item.Key == unityInstanceId) { object? value = item.Value; return (GameObject)((value is GameObject) ? value : null); } } } return null; } private static int GetUnityInstanceId(object obj) { Object val = (Object)((obj is Object) ? obj : null); if (val == (Object)null) { return 0; } try { return val.GetInstanceID(); } catch { return 0; } } private static bool IsInsideExtractionZone(object point, Vector3 position, GameObject anchor) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_004c: Unknown result type (might be due to invalid IL or missing references) object member = GetMember(point, "roomVolume"); GameObject val = (GameObject)((member is GameObject) ? member : null); if ((Object)(object)val != (Object)null) { Collider[] componentsInChildren = val.GetComponentsInChildren(true); foreach (Collider val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null)) { Bounds bounds = val2.bounds; ((Bounds)(ref bounds)).Expand(0.35f); if (((Bounds)(ref bounds)).Contains(position)) { return true; } } } } if ((Object)(object)anchor == (Object)null) { return false; } Vector3 val3 = position - anchor.transform.position; if (val3.x * val3.x + val3.z * val3.z > 9f) { return false; } if (val3.y >= -2f) { return val3.y <= 6.75f; } return false; } private static void ForceDroneAnchorTarget(object drone, GameObject anchor, object anchorPhysObject) { if (drone != null && !((Object)(object)anchor == (Object)null) && anchorPhysObject != null) { MarkAnchorAssistedDrone(drone); SetMember(drone, "targetNonValuables", true); SetMember(drone, "targetPhysGrabObject", anchorPhysObject); SetMember(drone, "currentTargetPhysGrabObject", anchorPhysObject); SetMember(drone, "targetTransform", anchor.transform); SetMember(drone, "targetGameObject", anchor); SetMember(drone, "magnetTargetPhysGrabObject", anchorPhysObject); SetMember(drone, "magnetTargetTransform", anchor.transform); SetMember(drone, "magnetTargetGameObject", anchor); SetMember(drone, "magnetActive", true); ClearKnownNonAnchorFollowTargets(drone); SetDroneFollowAnchorTarget(drone, anchor, anchorPhysObject); } } private static void SetDroneFollowAnchorTarget(object drone, GameObject anchor, object anchorPhysObject) { if (drone != null && !((Object)(object)anchor == (Object)null)) { string[] array = new string[31] { "followTarget", "followTargetTransform", "followTransform", "followTargetObject", "followTargetGameObject", "followGameObject", "followPhysGrabObject", "currentFollowTarget", "currentFollowTransform", "currentFollowGameObject", "moveTarget", "moveTargetTransform", "moveTargetGameObject", "moveTargetPhysGrabObject", "navigationTarget", "navigationTargetTransform", "navigationTargetGameObject", "hoverTarget", "hoverTargetTransform", "hoverTargetGameObject", "desiredTarget", "desiredTargetTransform", "desiredTargetGameObject", "targetFollow", "targetFollowTransform", "targetFollowGameObject", "followPosition", "movePosition", "targetPosition", "destination", "destinationPosition" }; for (int i = 0; i < array.Length; i++) { SetAnchorValueIfCompatible(drone, array[i], anchor, anchorPhysObject); } } } private static void ClearKnownNonAnchorFollowTargets(object drone) { if (drone != null) { string[] array = new string[12] { "targetPlayerAvatar", "currentTargetPlayerAvatar", "magnetTargetPlayerAvatar", "targetPlayer", "currentTargetPlayer", "magnetTargetPlayer", "targetEnemy", "currentTargetEnemy", "magnetTargetEnemy", "targetEnemyParent", "currentTargetEnemyParent", "magnetTargetEnemyParent" }; for (int i = 0; i < array.Length; i++) { ClearMemberIfExists(drone, array[i]); } } } private static void ClearAnchorFollowTarget(object drone, List anchors) { if (drone != null && anchors != null) { string[] array = new string[26] { "followTarget", "followTargetTransform", "followTransform", "followTargetObject", "followTargetGameObject", "followGameObject", "followPhysGrabObject", "currentFollowTarget", "currentFollowTransform", "currentFollowGameObject", "moveTarget", "moveTargetTransform", "moveTargetGameObject", "moveTargetPhysGrabObject", "navigationTarget", "navigationTargetTransform", "navigationTargetGameObject", "hoverTarget", "hoverTargetTransform", "hoverTargetGameObject", "desiredTarget", "desiredTargetTransform", "desiredTargetGameObject", "targetFollow", "targetFollowTransform", "targetFollowGameObject" }; for (int i = 0; i < array.Length; i++) { ClearMemberIfAnchorObject(drone, array[i], anchors); } } } private static void SetAnchorValueIfCompatible(object target, string memberName, GameObject anchor, object anchorPhysObject) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) if (target == null || (Object)(object)anchor == (Object)null) { return; } FieldInfo cachedField = GetCachedField(target.GetType(), memberName); if (cachedField == null) { return; } object obj = null; Type fieldType = cachedField.FieldType; if (typeof(Transform).IsAssignableFrom(fieldType)) { obj = anchor.transform; } else if (typeof(GameObject).IsAssignableFrom(fieldType)) { obj = anchor; } else if (fieldType == typeof(Vector3)) { obj = anchor.transform.position; } else if (anchorPhysObject != null && fieldType.IsInstanceOfType(anchorPhysObject)) { obj = anchorPhysObject; } else if (typeof(Component).IsAssignableFrom(fieldType)) { obj = anchor.transform; } else { if (!(fieldType == typeof(object))) { return; } obj = anchorPhysObject ?? anchor; } try { cachedField.SetValue(target, obj); } catch { } } private static void ClearMemberIfExists(object target, string memberName) { if (target == null) { return; } FieldInfo cachedField = GetCachedField(target.GetType(), memberName); if (cachedField == null || cachedField.FieldType.IsValueType) { return; } try { cachedField.SetValue(target, null); } catch { } } private static void ClearMemberIfAnchorObject(object target, string memberName, List anchors) { if (target == null || anchors == null) { return; } FieldInfo cachedField = GetCachedField(target.GetType(), memberName); if (cachedField == null || cachedField.FieldType.IsValueType) { return; } object obj = null; try { obj = cachedField.GetValue(target); } catch { obj = null; } GameObject val = ToGameObject(obj); if ((Object)(object)val == (Object)null || !IsAnchorObject(val, anchors)) { return; } try { cachedField.SetValue(target, null); } catch { } } private static void ClearSingleAnchorTarget(object drone, object anchorPhysObject) { if (drone != null && anchorPhysObject != null && GetMember(drone, "magnetTargetPhysGrabObject") == anchorPhysObject) { SetMember(drone, "magnetTargetPhysGrabObject", null); SetMember(drone, "targetPhysGrabObject", null); SetMember(drone, "currentTargetPhysGrabObject", null); SetMember(drone, "magnetTargetTransform", null); SetMember(drone, "targetTransform", null); SetMember(drone, "magnetTargetGameObject", null); SetMember(drone, "targetGameObject", null); SetMember(drone, "magnetActive", false); List list = new List(); Component val = (Component)((anchorPhysObject is Component) ? anchorPhysObject : null); if ((Object)(object)val != (Object)null) { list.Add(val.gameObject); } ClearAnchorFollowTarget(drone, list); RestoreDroneTargetSelectionIfAnchorAssisted(drone); } } private static void AssistDroneToNearestAnchor(object drone, List anchors) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (drone == null || anchors == null || anchors.Count == 0) { return; } Component val = (Component)((drone is Component) ? drone : null); if (!((Object)(object)val == (Object)null)) { if (!IsPoweredZeroGravityDrone(drone)) { UnprotectExternalConnectionDrone(drone); return; } bool insideExtractionZone = IsInsideAnyExtractionZone(val.transform.position, anchors); bool hasExternalConnection = HasActiveNonAnchorConnection(drone, anchors); UpdateExternalConnectionProtection(drone, anchors, insideExtractionZone, hasExternalConnection); } } private static void UpdateExternalConnectionProtection(object drone, List anchors, bool insideExtractionZone, bool hasExternalConnection) { if (drone == null) { return; } if (!hasExternalConnection) { UnprotectExternalConnectionDrone(drone); return; } string text = GetActiveConnectionKey(drone, anchors); if (string.IsNullOrEmpty(text)) { text = "unknown"; } if (!insideExtractionZone) { ProtectExternalConnectionDrone(drone, text); } else if (IsProtectedExternalConnectionDrone(drone)) { string protectedExternalConnectionKey = GetProtectedExternalConnectionKey(drone); if (string.IsNullOrEmpty(protectedExternalConnectionKey) || protectedExternalConnectionKey == text || text == "unknown") { RefreshExternalConnectionProtection(drone); } else { UnprotectExternalConnectionDrone(drone); } } } private static string GetActiveConnectionKey(object drone, List anchors) { GameObject activeNonAnchorTargetObject = GetActiveNonAnchorTargetObject(drone, anchors); if ((Object)(object)activeNonAnchorTargetObject != (Object)null) { return ((Object)activeNonAnchorTargetObject).GetInstanceID().ToString(); } Component val = (Component)((drone is Component) ? drone : null); if ((Object)(object)val != (Object)null && HasVisibleNonAnchorBeam(val.gameObject, anchors)) { return "beam"; } return null; } private static GameObject GetActiveNonAnchorTargetObject(object drone, List anchors) { if (drone == null) { return null; } string[] array = new string[21] { "magnetTargetPhysGrabObject", "targetPhysGrabObject", "currentTargetPhysGrabObject", "magnetTargetPlayerAvatar", "magnetTargetPlayer", "magnetTargetEnemy", "magnetTargetEnemyParent", "targetPlayerAvatar", "targetPlayer", "currentTargetPlayer", "currentTargetPlayerAvatar", "targetEnemy", "currentTargetEnemy", "targetEnemyParent", "currentTargetEnemyParent", "magnetTargetTransform", "targetTransform", "currentTargetTransform", "magnetTargetGameObject", "targetGameObject", "currentTargetGameObject" }; for (int i = 0; i < array.Length; i++) { object member = GetMember(drone, array[i]); GameObject val = ToGameObject(member); if ((Object)(object)val != (Object)null && IsExternalTargetObject(member, anchors, drone)) { return val; } } return GetGenericExternalTargetObject(drone, anchors); } private static GameObject GetGenericExternalTargetObject(object drone, List anchors) { if (drone == null) { return null; } Type type = drone.GetType(); FieldInfo[] fields; try { fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } catch { return null; } foreach (FieldInfo fieldInfo in fields) { if (fieldInfo == null || fieldInfo.FieldType.IsPrimitive || fieldInfo.FieldType == typeof(string)) { continue; } string text = ((fieldInfo.Name == null) ? string.Empty : fieldInfo.Name.ToLowerInvariant()); if (text.Contains("target") || text.Contains("magnet")) { object obj2 = null; try { obj2 = fieldInfo.GetValue(drone); } catch { obj2 = null; } GameObject val = ToGameObject(obj2); if ((Object)(object)val != (Object)null && IsExternalTargetObject(obj2, anchors, drone)) { return val; } } } return null; } private static bool HasActiveNonAnchorConnection(object drone, List anchors) { if (drone == null) { return false; } bool boolMember = GetBoolMember(drone, "magnetActive"); Component val = (Component)((drone is Component) ? drone : null); bool num = (Object)(object)val != (Object)null && HasVisibleNonAnchorBeam(val.gameObject, anchors); bool flag = HasNonAnchorTargetMember(drone, anchors); if (!num) { return boolMember && flag; } return true; } private static bool HasNonAnchorTargetMember(object drone, List anchors) { if (drone == null) { return false; } string[] array = new string[21] { "magnetTargetPhysGrabObject", "targetPhysGrabObject", "currentTargetPhysGrabObject", "magnetTargetPlayerAvatar", "magnetTargetPlayer", "magnetTargetEnemy", "magnetTargetEnemyParent", "targetPlayerAvatar", "targetPlayer", "currentTargetPlayer", "currentTargetPlayerAvatar", "targetEnemy", "currentTargetEnemy", "targetEnemyParent", "currentTargetEnemyParent", "magnetTargetTransform", "targetTransform", "currentTargetTransform", "magnetTargetGameObject", "targetGameObject", "currentTargetGameObject" }; for (int i = 0; i < array.Length; i++) { if (IsExternalTargetObject(GetMember(drone, array[i]), anchors, drone)) { return true; } } return HasGenericExternalTargetMember(drone, anchors); } private static bool HasGenericExternalTargetMember(object drone, List anchors) { if (drone == null) { return false; } Type type = drone.GetType(); FieldInfo[] fields; try { fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } catch { return false; } foreach (FieldInfo fieldInfo in fields) { if (fieldInfo == null || fieldInfo.FieldType.IsPrimitive || fieldInfo.FieldType == typeof(string)) { continue; } string text = ((fieldInfo.Name == null) ? string.Empty : fieldInfo.Name.ToLowerInvariant()); if (text.Contains("target") || text.Contains("magnet")) { object obj2 = null; try { obj2 = fieldInfo.GetValue(drone); } catch { obj2 = null; } if (IsExternalTargetObject(obj2, anchors, drone)) { return true; } } } return false; } private static bool IsExternalTargetObject(object value, List anchors, object drone) { if (value == null) { return false; } if (value is bool || value is int || value is float || value is double || value is string) { return false; } GameObject val = ToGameObject(value); if ((Object)(object)val == (Object)null) { return false; } Component val2 = (Component)((drone is Component) ? drone : null); if ((Object)(object)val2 != (Object)null && (Object)(object)val2.gameObject != (Object)null && (val == val2.gameObject || val.transform.IsChildOf(val2.transform))) { return false; } return !IsAnchorObject(val, anchors); } private static GameObject ToGameObject(object value) { GameObject val = (GameObject)((value is GameObject) ? value : null); if ((Object)(object)val != (Object)null) { return val; } Component val2 = (Component)((value is Component) ? value : null); if ((Object)(object)val2 != (Object)null) { return val2.gameObject; } Transform val3 = (Transform)((value is Transform) ? value : null); if ((Object)(object)val3 != (Object)null) { return ((Component)val3).gameObject; } return null; } private static bool IsAnchorObject(GameObject gameObject, List anchors) { if ((Object)(object)gameObject == (Object)null || anchors == null) { return false; } for (int i = 0; i < anchors.Count; i++) { GameObject val = anchors[i]; if (!((Object)(object)val == (Object)null)) { if (gameObject == val) { return true; } Transform transform = gameObject.transform; if ((Object)(object)transform != (Object)null && (transform.IsChildOf(val.transform) || val.transform.IsChildOf(transform))) { return true; } GameObject val2 = ToGameObject(GetComponentByName(val, "PhysGrabObject")); if ((Object)(object)val2 != (Object)null && gameObject == val2) { return true; } } } return false; } private static bool HasVisibleNonAnchorBeam(GameObject droneObject, List anchors) { //IL_0044: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_0101: 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_0110: 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_011d: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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) //IL_00bb: 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) if ((Object)(object)droneObject == (Object)null) { return false; } LineRenderer[] componentsInChildren = droneObject.GetComponentsInChildren(true); foreach (LineRenderer val in componentsInChildren) { if ((Object)(object)val == (Object)null || !((Renderer)val).enabled || val.positionCount < 2) { continue; } Vector3 position; Vector3 position2; try { position = val.GetPosition(0); position2 = val.GetPosition(val.positionCount - 1); } catch { continue; } Vector3 val2; if (val.useWorldSpace) { if (IsPointNearAnyAnchor(position, anchors, 1.35f) || IsPointNearAnyAnchor(position2, anchors, 1.35f)) { continue; } val2 = position - droneObject.transform.position; if (!(((Vector3)(ref val2)).sqrMagnitude > 0.04f)) { val2 = position2 - droneObject.transform.position; if (!(((Vector3)(ref val2)).sqrMagnitude > 0.04f)) { continue; } } return true; } Vector3 val3 = ((Component)val).transform.TransformPoint(position); Vector3 val4 = ((Component)val).transform.TransformPoint(position2); if (IsPointNearAnyAnchor(val3, anchors, 1.35f) || IsPointNearAnyAnchor(val4, anchors, 1.35f)) { continue; } val2 = val3 - droneObject.transform.position; if (!(((Vector3)(ref val2)).sqrMagnitude > 0.04f)) { val2 = val4 - droneObject.transform.position; if (!(((Vector3)(ref val2)).sqrMagnitude > 0.04f)) { continue; } } return true; } return false; } private static bool IsPointNearAnyAnchor(Vector3 point, List anchors, float maxDistance) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_002f: Unknown result type (might be due to invalid IL or missing references) if (anchors == null) { return false; } float num = maxDistance * maxDistance; for (int i = 0; i < anchors.Count; i++) { GameObject val = anchors[i]; if (!((Object)(object)val == (Object)null)) { Vector3 val2 = point - val.transform.position; if (((Vector3)(ref val2)).sqrMagnitude <= num) { return true; } } } return false; } private static bool IsInsideAnyExtractionZone(Vector3 position, List anchors) { //IL_0056: 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) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0070: 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: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) if (anchors == null) { return false; } for (int i = 0; i < anchors.Count; i++) { GameObject val = anchors[i]; if (!((Object)(object)val == (Object)null)) { object componentByName = GetComponentByName(val, "PadAnchor"); object member = GetMember(componentByName, "Point"); if (member == null) { member = GetMember(componentByName, "point"); } if (member != null && IsInsideExtractionZone(member, position, val)) { return true; } Vector3 val2 = position - val.transform.position; if (val2.x * val2.x + val2.z * val2.z <= 9f && val2.y >= -2f && val2.y <= 6.75f) { return true; } } } return false; } private static bool GetBoolMember(object target, string memberName) { object member = GetMember(target, memberName); if (member is bool) { return (bool)member; } return false; } private static int GetDroneKey(object drone) { Component val = (Component)((drone is Component) ? drone : null); if ((Object)(object)val != (Object)null && (Object)(object)val.gameObject != (Object)null) { return ((Object)val.gameObject).GetInstanceID(); } return drone?.GetHashCode() ?? 0; } private static void MarkAnchorAssistedDrone(object drone) { int droneKey = GetDroneKey(drone); if (droneKey != 0) { AnchorAssistedDrones.Add(droneKey); } } private static void RestoreDroneTargetSelectionIfAnchorAssisted(object drone) { int droneKey = GetDroneKey(drone); if (droneKey != 0 && AnchorAssistedDrones.Contains(droneKey)) { AnchorAssistedDrones.Remove(droneKey); SetMember(drone, "targetValuables", true); SetMember(drone, "targetPlayers", true); SetMember(drone, "targetPlayer", true); SetMember(drone, "targetEnemies", true); } } private static void ProtectExternalConnectionDrone(object drone, string connectionKey) { int droneKey = GetDroneKey(drone); if (droneKey != 0) { ProtectedExternalConnectionDrones.Add(droneKey); ProtectedExternalConnectionLastSeen[droneKey] = Time.time; ProtectedExternalConnectionKeys[droneKey] = (string.IsNullOrEmpty(connectionKey) ? "unknown" : connectionKey); } } private static void RefreshExternalConnectionProtection(object drone) { int droneKey = GetDroneKey(drone); if (droneKey != 0 && ProtectedExternalConnectionDrones.Contains(droneKey)) { ProtectedExternalConnectionLastSeen[droneKey] = Time.time; } } private static string GetProtectedExternalConnectionKey(object drone) { int droneKey = GetDroneKey(drone); if (droneKey == 0) { return null; } if (!ProtectedExternalConnectionKeys.TryGetValue(droneKey, out var value)) { return null; } return value; } private static void UnprotectExternalConnectionDrone(object drone) { int droneKey = GetDroneKey(drone); if (droneKey != 0) { ProtectedExternalConnectionDrones.Remove(droneKey); ProtectedExternalConnectionLastSeen.Remove(droneKey); ProtectedExternalConnectionKeys.Remove(droneKey); } } private static bool IsProtectedExternalConnectionDrone(object drone) { int droneKey = GetDroneKey(drone); if (droneKey != 0) { return ProtectedExternalConnectionDrones.Contains(droneKey); } return false; } private static bool IsProtectedExternalConnectionGraceActive(object drone, float seconds) { int droneKey = GetDroneKey(drone); if (droneKey == 0 || !ProtectedExternalConnectionDrones.Contains(droneKey)) { return false; } if (!ProtectedExternalConnectionLastSeen.TryGetValue(droneKey, out var value)) { return false; } return Time.time - value <= seconds; } private static List GetDroneAnchors(object service) { List list = new List(); IEnumerable dictionaryValues = GetDictionaryValues(GetMember(service, "_anchors")); if (dictionaryValues == null) { return list; } foreach (object item in dictionaryValues) { GameObject val = (GameObject)((item is GameObject) ? item : null); if (!((Object)(object)val == (Object)null) && !IsButtonModeAnchor(val)) { list.Add(val); } } return list; } private static bool IsButtonModeAnchor(GameObject anchor) { object componentByName = GetComponentByName(anchor, "PadAnchor"); if (componentByName == null) { return false; } object member = GetMember(componentByName, "ButtonMode"); if (member is bool) { return (bool)member; } return false; } private static GameObject FindNearestAnchor(Vector3 position, List anchors, float maxDistance) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_002e: 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_003d: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) GameObject result = null; float num = maxDistance * maxDistance; for (int i = 0; i < anchors.Count; i++) { GameObject val = anchors[i]; if (!((Object)(object)val == (Object)null)) { Vector3 val2 = position - val.transform.position; float num2 = val2.x * val2.x + val2.z * val2.z; if (!(num2 > num) && !(val2.y < -2.5f) && !(val2.y > 6.5f)) { num = num2; result = val; } } } return result; } private static void ClearAnchorTargetIfNeeded(object drone, List anchors) { if (drone != null && anchors != null) { object member = GetMember(drone, "magnetTargetPhysGrabObject"); if (member != null && IsAnchorPhysObject(member, anchors)) { SetMember(drone, "magnetTargetPhysGrabObject", null); SetMember(drone, "targetPhysGrabObject", null); SetMember(drone, "currentTargetPhysGrabObject", null); SetMember(drone, "magnetTargetTransform", null); SetMember(drone, "targetTransform", null); SetMember(drone, "magnetTargetGameObject", null); SetMember(drone, "targetGameObject", null); SetMember(drone, "magnetActive", false); ClearAnchorFollowTarget(drone, anchors); RestoreDroneTargetSelectionIfAnchorAssisted(drone); } } } private static bool IsAnchorPhysObject(object physObject, List anchors) { for (int i = 0; i < anchors.Count; i++) { object componentByName = GetComponentByName(anchors[i], "PhysGrabObject"); if (physObject == componentByName) { return true; } } return false; } private static bool IsPoweredZeroGravityDrone(object drone) { if (drone == null) { return false; } object member = GetMember(drone, "itemActivated"); if (member is bool && !(bool)member) { return false; } Component val = (Component)((drone is Component) ? drone : null); if ((Object)(object)val == (Object)null || GetComponentByName(val.gameObject, "ItemDroneZeroGravity") == null) { return false; } object componentByName = GetComponentByName(val.gameObject, "ItemBattery"); if (componentByName != null) { object member2 = GetMember(componentByName, "batteryLife"); if (member2 is float && (float)member2 <= 0f) { return false; } } return true; } private static bool HasNativeResolverFix() { Type type = FindType("ZeroGravityExtraction.ZeroGravityExtraction"); if (type == null) { return false; } string input = null; object[] customAttributes = type.GetCustomAttributes(inherit: false); foreach (object obj in customAttributes) { if (obj != null && !(obj.GetType().FullName != "BepInEx.BepInPlugin")) { input = GetMember(obj, "Version") as string; break; } } if (Version.TryParse(input, out Version result)) { return result.CompareTo(new Version(1, 1, 1)) >= 0; } Assembly assembly = type.Assembly; if (Version.TryParse((assembly.GetCustomAttribute() != null) ? assembly.GetCustomAttribute().InformationalVersion : null, out result)) { return result.CompareTo(new Version(1, 1, 1)) >= 0; } return false; } private static bool TryResolveEffect(object service) { ResetResolveFailure(service); bool flag = IsMultiplayer(); Candidate candidate = null; int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; object staticMember = GetStaticMember("StatsManager", "instance"); IEnumerable enumerable = ((staticMember == null) ? null : GetDictionaryValues(GetMember(staticMember, "itemDictionary"))); if (enumerable != null) { foreach (object item in enumerable) { num++; if (item == null) { continue; } GameObject prefabFromRef = GetPrefabFromRef(GetMember(item, "prefab")); if ((Object)(object)prefabFromRef == (Object)null) { continue; } object obj = FindComponentInChildren(prefabFromRef, "ItemStaffZeroGravity"); if (obj == null) { continue; } num2++; Candidate candidate2 = TryBuildCandidateFromStaff(obj, GetUnityName(item), flag); if (candidate2 == null) { if (flag) { num4++; } continue; } if (!string.IsNullOrEmpty(candidate2.ResourcePath)) { num3++; } if (candidate == null || candidate2.Score > candidate.Score) { candidate = candidate2; } } } if (candidate == null) { foreach (object item2 in FindLoadedComponentsByName("ItemStaffZeroGravity")) { num2++; string objectPath = GetObjectPath(item2); Candidate candidate3 = TryBuildCandidateFromStaff(item2, objectPath, flag); if (candidate3 == null) { if (flag) { num4++; } continue; } if (!string.IsNullOrEmpty(candidate3.ResourcePath)) { num3++; } if (candidate == null || candidate3.Score > candidate.Score) { candidate = candidate3; } } } if (candidate != null) { SetMember(service, "_affectPrefab", candidate.AffectPrefab); SetMember(service, "_orbResourcePath", string.IsNullOrEmpty(candidate.ResourcePath) ? null : candidate.ResourcePath); ResetResolveFailure(service); Log.LogInfo((object)("Resolved zero-gravity effect from '" + candidate.ItemName + "' resourcePath='" + NullText(candidate.ResourcePath) + "'.")); return true; } if (Time.realtimeSinceStartup >= _nextDebugLog) { _nextDebugLog = Time.realtimeSinceStartup + 15f; Log.LogWarning((object)("Zero-gravity effect not ready; retrying. scannedItems=" + num + " scannedStaffs=" + num2 + " resourceCandidates=" + num3 + " rejectedForMultiplayerPath=" + num4 + ".")); } ResetResolveFailure(service); return false; } private static Candidate TryBuildCandidateFromStaff(object staff, string sourceName, bool multiplayer) { if (staff == null) { return null; } object member = GetMember(staff, "projectilePrefab"); if (member == null) { return null; } string stringMember = GetStringMember(member, "ResourcePath"); bool hasBundle = GetMember(member, "Bundle") != null; bool isValid = IsPrefabRefValid(member); GameObject prefabFromRef = GetPrefabFromRef(member); if ((Object)(object)prefabFromRef == (Object)null) { return null; } object obj = FindComponentInChildren(prefabFromRef, "SemiAreaOfEffect"); if (obj == null) { return null; } GameObject prefabFromRef2 = GetPrefabFromRef(GetMember(obj, "semiAffectPrefab")); if ((Object)(object)prefabFromRef2 == (Object)null) { return null; } if (FindComponentInChildren(prefabFromRef2, "SemiAffectZeroGravity") == null) { return null; } if (multiplayer && string.IsNullOrEmpty(stringMember)) { return null; } int score = ScoreCandidate(sourceName, stringMember, hasBundle, isValid); return new Candidate(sourceName, stringMember, prefabFromRef2, score); } private static int ScoreCandidate(string itemName, string resourcePath, bool hasBundle, bool isValid) { int num = 0; string text = ((itemName ?? string.Empty) + " " + (resourcePath ?? string.Empty)).ToLowerInvariant(); if (!string.IsNullOrEmpty(resourcePath)) { num += 1000; } if (isValid) { num += 200; } num = (hasBundle ? (num - 150) : (num + 100)); if (text.Contains("staff")) { num += 200; } if (text.Contains("orb")) { num -= 50; } if (text.Contains("zero") && text.Contains("gravity")) { num += 10; } return num; } private static void ResetResolveFailure(object service) { if (service != null) { SetMember(service, "_resolveFailed", false); SetMember(service, "_resolveAttempts", 0); } } private static object GetOrAddComponentByName(GameObject gameObject, string typeName) { if ((Object)(object)gameObject == (Object)null) { return null; } object componentByName = GetComponentByName(gameObject, typeName); if (componentByName != null) { return componentByName; } Type type = FindType(typeName); if (type == null) { return null; } try { return gameObject.AddComponent(type); } catch { return null; } } private static object GetComponentByName(GameObject gameObject, string typeName) { if ((Object)(object)gameObject == (Object)null) { return null; } Type type = FindType(typeName); if (type == null) { return null; } try { return gameObject.GetComponent(type); } catch { return null; } } private static object FindComponentInChildren(GameObject root, string typeName) { if ((Object)(object)root == (Object)null) { return null; } Type type = FindType(typeName); if (type == null) { return null; } try { return root.GetComponentInChildren(type, true); } catch { return null; } } private static object GetStaticMember(string typeName, string memberName) { Type type = FindType(typeName); if (type == null) { return null; } return GetMember(type, memberName); } private static object GetMember(object target, string memberName) { if (target == null) { return null; } bool num = target is Type; Type type = (num ? ((Type)target) : target.GetType()); object obj = (num ? null : target); object cachedMember = GetCachedMember(type, memberName); if (cachedMember == MissingMember) { return null; } PropertyInfo propertyInfo = cachedMember as PropertyInfo; if (propertyInfo != null) { try { return propertyInfo.GetValue(obj, null); } catch { return null; } } FieldInfo fieldInfo = cachedMember as FieldInfo; if (fieldInfo != null) { try { return fieldInfo.GetValue(obj); } catch { return null; } } return null; } private static object GetCachedMember(Type type, string memberName) { string key = type.AssemblyQualifiedName + "|" + memberName; if (MemberCache.TryGetValue(key, out var value)) { return value; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo property = type.GetProperty(memberName, bindingAttr); if (property != null) { MemberCache[key] = property; return property; } FieldInfo field = type.GetField(memberName, bindingAttr); if (field != null) { MemberCache[key] = field; return field; } MemberCache[key] = MissingMember; return MissingMember; } private static void SetMember(object target, string memberName, object value) { if (target == null) { return; } FieldInfo cachedField = GetCachedField(target.GetType(), memberName); if (cachedField == null) { return; } try { cachedField.SetValue(target, value); } catch { } } private static FieldInfo GetCachedField(Type type, string memberName) { string key = type.AssemblyQualifiedName + "|" + memberName; if (FieldCache.TryGetValue(key, out var value)) { if (value != MissingField) { return value as FieldInfo; } return null; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo field = type.GetField(memberName, bindingAttr); if (field == null) { FieldCache[key] = MissingField; return null; } FieldCache[key] = field; return field; } private static IEnumerable GetDictionaryValues(object dictionary) { if (dictionary == null) { return null; } if (dictionary is IDictionary dictionary2) { return dictionary2.Values; } return GetMember(dictionary, "Values") as IEnumerable; } private static GameObject GetPrefabFromRef(object prefabRef) { if (prefabRef == null) { return null; } object member = GetMember(prefabRef, "Prefab"); return (GameObject)((member is GameObject) ? member : null); } private static string GetStringMember(object target, string memberName) { return GetMember(target, memberName) as string; } private static bool IsPrefabRefValid(object prefabRef) { if (prefabRef == null) { return false; } MethodInfo methodInfo = AccessTools.Method(prefabRef.GetType(), "IsValid", (Type[])null, (Type[])null); if (methodInfo == null) { return (Object)(object)GetPrefabFromRef(prefabRef) != (Object)null; } try { object obj = methodInfo.Invoke(prefabRef, null); return obj is bool && (bool)obj; } catch { return (Object)(object)GetPrefabFromRef(prefabRef) != (Object)null; } } private static IEnumerable FindLoadedComponentsByName(string typeName) { Type type = FindType(typeName); if (type == null) { yield break; } Object[] objects; try { objects = Resources.FindObjectsOfTypeAll(type); } catch { objects = null; } if (objects == null) { yield break; } for (int i = 0; i < objects.Length; i++) { if (objects[i] != (Object)null) { yield return objects[i]; } } } private static string GetObjectPath(object obj) { Component val = (Component)((obj is Component) ? obj : null); if ((Object)(object)val == (Object)null) { return GetUnityName(obj); } Transform val2 = val.transform; string text = (((Object)(object)val2 != (Object)null) ? ((Object)val2).name : GetUnityName(obj)); while ((Object)(object)val2 != (Object)null && (Object)(object)val2.parent != (Object)null) { val2 = val2.parent; text = ((Object)val2).name + "/" + text; } return text; } private static Type FindType(string typeName) { if (TypeCache.TryGetValue(typeName, out var value)) { return value; } if (MissingTypeCache.Contains(typeName)) { return null; } Type type = AccessTools.TypeByName(typeName); if (type != null) { TypeCache[typeName] = type; return type; } Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { try { type = assemblies[i].GetType(typeName, throwOnError: false); if (type != null) { TypeCache[typeName] = type; return type; } Type[] types = assemblies[i].GetTypes(); for (int j = 0; j < types.Length; j++) { if (types[j].Name == typeName || types[j].FullName == typeName) { TypeCache[typeName] = types[j]; return types[j]; } } } catch (ReflectionTypeLoadException ex) { Type[] types2 = ex.Types; foreach (Type type2 in types2) { if (type2 != null && (type2.Name == typeName || type2.FullName == typeName)) { TypeCache[typeName] = type2; return type2; } } } catch { } } MissingTypeCache.Add(typeName); return null; } private static bool IsMultiplayer() { if (_isMultiplayerMethod == null) { Type type = FindType("SemiFunc"); if (type == null) { return false; } _isMultiplayerMethod = AccessTools.Method(type, "IsMultiplayer", (Type[])null, (Type[])null); if (_isMultiplayerMethod == null) { return false; } } try { object obj = _isMultiplayerMethod.Invoke(null, null); if (obj is bool) { return (bool)obj; } } catch { } return false; } private static string GetUnityName(object obj) { Object val = (Object)((obj is Object) ? obj : null); if (val != (Object)null) { return val.name; } return obj.GetType().Name; } private static string NullText(string text) { if (!string.IsNullOrEmpty(text)) { return text; } return ""; } } }