public override void OnApplicationStart() { Instance = this; _configHandler = new MelonLoaderConfigHandler(); ExplorerCore.Init(this); }
internal void Init() { Instance = this; configHandler = new StandaloneConfigHandler(); ExplorerCore.Init(this); }
public static void Prefix(TextRenderer __instance) { if (__instance.gameObject.name == "ExplorerBehaviour") { ExplorerCore.Update(); } }
public void SetupPatches() { try { this.HarmonyInstance.PatchAll(); } catch (Exception ex) { ExplorerCore.Log($"Exception setting up Harmony patches:\r\n{ex.ReflectionExToString()}"); } }
private void PrefixProperty(Type type, string property, HarmonyMethod prefix) { try { var prop = type.GetProperty(property); this.Harmony.Patch(prop.GetSetMethod(), prefix: prefix); } catch (Exception e) { ExplorerCore.Log($"Unable to patch {type.Name}.set_{property}: {e.Message}"); } }
internal override Type Internal_GetActualType(object obj) { if (obj == null) { return(null); } var type = obj.GetType(); try { if (IsString(obj)) { return(typeof(string)); } if (IsIl2CppPrimitive(type)) { return(il2cppPrimitivesToMono[type.FullName]); } if (obj is Il2CppSystem.Object cppObject) { var cppType = cppObject.GetIl2CppType(); // check if type is injected IntPtr classPtr = il2cpp_object_get_class(cppObject.Pointer); if (RuntimeSpecificsStore.IsInjected(classPtr)) { // Note: This will fail on injected subclasses. // - {Namespace}.{Class}.{Subclass} would be {Namespace}.{Subclass} when injected. // Not sure on solution yet. return(GetTypeByName(cppType.FullName) ?? type); } if (AllTypes.TryGetValue(cppType.FullName, out Type primitive) && primitive.IsPrimitive) { return(primitive); } return(GetUnhollowedType(cppType) ?? type); } } catch (Exception ex) { ExplorerCore.LogWarning("Exception in IL2CPP GetActualType: " + ex); } return(type); }
private void Init() { Instance = this; _configHandler = new StandaloneConfigHandler(); #if CPP ClassInjector.RegisterTypeInIl2Cpp <ExplorerBehaviour>(); #endif var obj = new GameObject("ExplorerBehaviour"); obj.AddComponent <ExplorerBehaviour>(); GameObject.DontDestroyOnLoad(obj); obj.hideFlags = HideFlags.HideAndDontSave; ExplorerCore.Init(this); }
private static void BuildDeobfuscationCache() { float start = UnityEngine.Time.realtimeSinceStartup; foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) { foreach (var type in asm.TryGetTypes()) { TryCacheDeobfuscatedType(type); } } if (DeobfuscatedTypes.Count > 0) { ExplorerCore.Log($"Built deobfuscation cache in {UnityEngine.Time.realtimeSinceStartup - start} seconds, " + $"initial count: {DeobfuscatedTypes.Count} "); } }
public static string ToStringForInput(object obj, Type type) { if (type == null || obj == null) { return(null); } if (type == typeof(string)) { return(obj as string); } if (type.IsEnum) { return(Enum.IsDefined(type, obj) ? Enum.GetName(type, obj) : obj.ToString()); } try { if (customTypes.ContainsKey(type.FullName)) { return(customTypesToString[type.FullName].Invoke(obj)); } else if (formattedTypes.Contains(type)) { return(ReflectionUtility.GetMethodInfo(type, "ToString", new Type[] { typeof(string), typeof(IFormatProvider) }) .Invoke(obj, new object[] { NUMBER_FORMAT, en_US }) as string); } else { return(obj.ToString()); } } catch (Exception ex) { ExplorerCore.LogWarning($"Exception formatting object for input: {ex}"); return(null); } }
public void SetupCursorPatches() { try { PrefixProperty(typeof(Cursor), "lockState", new HarmonyMethod(typeof(CursorUnlocker).GetMethod(nameof(CursorUnlocker.Prefix_set_lockState)))); PrefixProperty(typeof(Cursor), "visible", new HarmonyMethod(typeof(CursorUnlocker).GetMethod(nameof(CursorUnlocker.Prefix_set_visible)))); PrefixProperty(typeof(EventSystem), "current", new HarmonyMethod(typeof(CursorUnlocker).GetMethod(nameof(CursorUnlocker.Prefix_EventSystem_set_current)))); } catch (Exception ex) { ExplorerCore.Log($"Exception setting up Harmony patches:\r\n{ex.ReflectionExToString()}"); } }
private void Init() { Instance = this; _configHandler = new StandaloneConfigHandler(); #if CPP ClassInjector.RegisterTypeInIl2Cpp <ExplorerBehaviour>(); var obj = new GameObject( "ExplorerBehaviour", new Il2CppSystem.Type[] { Il2CppType.Of <ExplorerBehaviour>() } ); #else var obj = new GameObject( "ExplorerBehaviour", new Type[] { typeof(ExplorerBehaviour) } ); #endif GameObject.DontDestroyOnLoad(obj); obj.hideFlags = HideFlags.HideAndDontSave; ExplorerCore.Init(this); }
public override void OnUpdate() { ExplorerCore.Update(); }
internal void Update() { ExplorerCore.Update(); }
internal static void OnPostRender(Camera _) { ExplorerCore.OnPostRender(); }
internal void FixedUpdate() { ExplorerCore.FixedUpdate(); }