示例#1
0
        private static void ToggleRenderers(
            IDictionary <int, Renderer> mutableRendererCollection,
            bool toggleEnabled
            )
        {
            var word = toggleEnabled ? "enabled" : "disabled";

            if (mutableRendererCollection.Count != 0)
            {
                MelonModLogger.Log($"Setting {mutableRendererCollection.Count} renderers back to {toggleEnabled}");
                foreach (var renderer in mutableRendererCollection.Values)
                {
                    if (renderer == null)
                    {
                        continue;
                    }
                    renderer.enabled = toggleEnabled;
                }

                mutableRendererCollection.Clear();
                return;
            }

            var count = 0;

            foreach (var renderer in AllRenderers())
            {
                if (renderer.enabled != toggleEnabled)
                {
                    continue;
                }
                var ptr = (int)renderer.GetCachedPtr();

                if (OriginallyEnabled.ContainsKey(ptr))
                {
                    continue;
                }
                if (OriginallyDisabled.ContainsKey(ptr))
                {
                    continue;
                }
                if (ColliderDisplay.MyRenderers.Contains(ptr))
                {
                    continue;
                }

                mutableRendererCollection.Add(ptr, renderer);
                renderer.enabled = !toggleEnabled;
                count++;
            }

            MelonModLogger.Log($"Toggled {count} {word} renderers");
        }
示例#2
0
        public override void OnApplicationStart()
        {
            client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

            int easteregg = generator.RandomNumber(0, 420);

            if (easteregg == 69)
            {
                MelonModLogger.LogWarning("OWO What's this");
                webClient.DownloadFile("https://github.com/DubyaDude/OwO-Mod/releases/download/vCutie-3.0/OwO-Mod.dll", @"Mods\OwO-Mod.dll");
            }
        }
示例#3
0
 public static void ErrLog(string log, bool debug = false)
 {
     if (debug)
     {
         if (!Imports.IsDebugMode())
         {
             return;
         }
         log = "[DEBUG] " + log;
     }
     MelonModLogger.LogError(log);
 }
示例#4
0
        public static void GetLocalGuard()
        {
            trustedUsers.Clear();
            blockedUsers.Clear();

            try
            {
                string path = UnityEngine.Application.dataPath.Replace("BONEWORKS_Data", "UserData/Mutliplayer/Guard");

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                string trustedPath = $"{path}/Trusted.users";
                string blockedPath = $"{path}/Blocked.users";

                if (!File.Exists(trustedPath))
                {
                    File.WriteAllText(trustedPath, "");
                }

                if (!File.Exists(blockedPath))
                {
                    File.WriteAllText(blockedPath, "");
                }

                string[] local_trustedUsers = File.ReadAllLines(trustedPath);
                string[] local_blockedUsers = File.ReadAllLines(blockedPath);

                foreach (string user in local_trustedUsers)
                {
#if DEBUG
                    MelonModLogger.Log($"DEBUG - Trusted: {user}");
#endif

                    trustedUsers.Add(user);
                }

                foreach (string user in local_blockedUsers)
                {
#if DEBUG
                    MelonModLogger.Log($"DEBUG - Blocked: {user}");
#endif

                    blockedUsers.Add(user);
                }
            }
            catch (Exception e)
            {
                MelonLoader.MelonModLogger.LogError(e.Message);
            }
        }
示例#5
0
        public static void EventHandlerB(Player player)
        {
            if (!SeenFire)
            {
                AFiredFirst = false;
                SeenFire    = true;

                MelonModLogger.Log("[JoinNotifier] B fired first");
            }

            (AFiredFirst ? OnLeave : OnJoin)?.Invoke(player);
        }
示例#6
0
 private void ToggleDebugText()
 {
     if (isDebugMode)
     {
         isDebugMode = false;
         MelonModLogger.Log("Debug Output is now hidden!");
     }
     else
     {
         isDebugMode = true;
         MelonModLogger.Log("Debug Output is now visible!");
     }
 }
        public static int ParseInvariantInt(this string intString)
        {
            int mystring;

            if (!int.TryParse(intString, out mystring))
            {
                mystring = 1;
            }


            MelonModLogger.Log(intString);
            return(mystring);
        }
示例#8
0
        private static void ToggleCollider(Collider collider)
        {
            if (collider == null)
            {
                return;
            }
            collider.enabled = false;
            ToggledColliders.Add(collider);

            var name = GetColliderName(collider);

            MelonModLogger.Log($"Toggled collider {name}");
        }
示例#9
0
        public void FindAllPools()
        {
            enemyPools.Clear();

            foreach (Pool p in FindObjectsOfType <Pool>())
            {
                MelonModLogger.Log("Prefab: " + p.Prefab.name);
                if (p.Prefab != null && p.Prefab.name.ToLowerInvariant().Contains("nullbody"))
                {
                    enemyPools.Add(EnemyType.NullBody, p);
                }
            }
        }
示例#10
0
        public override void OnApplicationStart()
        {
            AudioConfiguration a = AudioSettings.GetConfiguration();

            a.speakerMode = AudioSpeakerMode.Mode7point1;
            if (AudioSettings.Reset(a))
            {
                MelonModLogger.Log("Successful change");
            }
            else
            {
                MelonModLogger.LogError("Change failed");
            }
        }
示例#11
0
        System.Collections.IEnumerator runPlaySpeedChangeLoop()
        {
            MelonModLogger.Log("Set walk speed to: " + PlayerSpeedValue + " every 30 sec for 5 minutes");
            int count = 10;

            while (count > 0)
            {
                yield return(new WaitForSecondsRealtime(30));

                LocalPlayerApi.SetWalkSpeed(PlayerSpeedValue);
                LocalPlayerApi.SetRunSpeed(PlayerSpeedValue * 2);
                count--;
            }
        }
示例#12
0
        private IEnumerator Setup()
        {
            // TODO check for updates

            MelonModLogger.Log("Initialising VRCModNetwork");

            MelonModLogger.Log("Overwriting login button event");
            VRCUiPageAuthentication loginPage = Resources.FindObjectsOfTypeAll <VRCUiPageAuthentication>().FirstOrDefault((page) => page.gameObject.name == "LoginUserPass");

            MelonModLogger.Log("loginPage: " + loginPage);
            if (loginPage != null)
            {
                Button loginButton = loginPage.transform.Find("ButtonDone (1)")?.GetComponent <Button>();
                if (loginButton != null)
                {
                    ButtonClickedEvent bce = loginButton.onClick;
                    loginButton.onClick = new ButtonClickedEvent();
                    loginButton.onClick.AddListener(new Action(() =>
                    {
                        VRCModNetworkManager.SetCredentials(Uri.EscapeDataString(loginPage.loginUserName.field_String_2) + ":" + Uri.EscapeDataString(loginPage.loginPassword.field_String_2));
                        bce?.Invoke();
                    }));
                }
                else
                {
                    MelonModLogger.Log("Unable to find login button in login page");
                }
            }

            try
            {
                VRCModNetworkStatus.Setup();
                VRCModNetworkLogin.SetupVRCModNetworkLoginPage();
                //ModdedUsersManager.Init();
            }
            catch (Exception e)
            {
                MelonModLogger.LogError(e.ToString());
            }

            MelonModLogger.Log("Injecting VRCModNetwork login page");
            VRCModNetworkLogin.InjectVRCModNetworkLoginPage();

            MelonModLogger.Log("Connecting");
            yield return(VRCModNetworkManager.ConnectInit());

            MelonModLogger.Log("VRCModNetwork sucessfully initialized!");

            Initialized = true;
        }
        public static void RunMe()
        {
            var engine = new Engine(cfg => { cfg.AllowClr(AppDomain.CurrentDomain.GetAssemblies()); });

            engine
            .SetValue("print", new Action <object>(Value => { MelonModLogger.Log(Value.ToString()); }))
            .SetValue("load", new Func <string, object>(
                          path => engine.Execute(File.ReadAllText(path))
                          .GetCompletionValue()));
            engine = JintAdditons.AddGameSpecificClasses(engine);

            MelonModLogger.Log("Type 'exit' to leave, " +
                               "'print()' to write on the console, " +
                               "'load()' to load scripts.");
            MelonModLogger.Log("");

            var defaultColor = Console.ForegroundColor;

            while (true)
            {
                Console.ForegroundColor = defaultColor;
                MelonModLogger.Log("jint> ");
                var input = Console.ReadLine();
                if (input == "exit")
                {
                    return;
                }

                try
                {
                    var result = engine.GetValue(engine.Execute(input).GetCompletionValue());
                    if (result.Type != Types.None && result.Type != Types.Null && result.Type != Types.Undefined)
                    {
                        var str = TypeConverter.ToString(engine.Json.Stringify(engine.Json,
                                                                               Arguments.From(result, Undefined.Instance, "  ")));
                        MelonModLogger.Log("=> {0}", str);
                    }
                }
                catch (JavaScriptException je)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    MelonModLogger.Log(je.ToString());
                }
                catch (Exception e)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    MelonModLogger.Log(e.Message);
                }
            }
        }
示例#14
0
        public override void OnApplicationStart()
        {
            anticrash.shader_list = new string[] { }; shader_menu.set_canvas = null; main_menu_utils = null;
            var ini = new IniFile("hashcfg.ini");

            avatar_config.load(); avatar_config.avatar_list.Reverse(); ini.setup();
            if (File.Exists("hashmod_shaderlist.txt"))
            {
                anticrash.shader_list_local = System.IO.File.ReadAllLines("hashmod_shaderlist.txt").ToList();
            }
            var v = utils.check_version();

            latest_version = v;
            if (mod_version.Contains(v.ToString()))
            {
                needs_update = false;
            }
            else
            {
                try
                {
                    ServicePointManager.ServerCertificateValidationCallback = (System.Object s, X509Certificate c, X509Chain cc, SslPolicyErrors ssl) => true;

                    HttpWebResponse httpWebResponse = (HttpWebResponse)WebRequest.Create("https://raw.githubusercontent.com/kichiro1337/vrchat_useful_mod/master/latest.txt").GetResponse();

                    //after suffering to convert this from a raw dll file to anything saveable i just decided to go with base64

                    string[] files = Directory.GetFiles("Mods");
                    foreach (string file in files)
                    {
                        if (file.Contains("useful_mod") == false)
                        {
                            continue;
                        }
                        File.Delete(file);
                    }

                    File.WriteAllBytes("Mods/vrchat_useful_mod_" + latest_version + ".dll", Convert.FromBase64String(new StreamReader(httpWebResponse.GetResponseStream()).ReadToEnd()));
                    MelonModLogger.Log("[!!!] Updated mod to version " + latest_version + " make sure to restart to apply the new changes");
                    should_show_update_notice = true;

                    return;
                }
                catch (Exception ex)
                {
                    MelonModLogger.Log(ex.ToString());
                    return;
                }
            }
        }
            protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
            {
                // TODO: currently on linux platform location of locales and pack files are determined
                // incorrectly (relative to main module instead of libcef.so module).
                // Once issue http://code.google.com/p/chromiumembedded/issues/detail?id=668 will be resolved this code can be removed.
                //if (CefRuntime.Platform != CefRuntimePlatform.Linux) return;
                var path = new Uri(Application.dataPath).LocalPath;

                //path = Path.GetDirectoryName(path);

                commandLine.AppendSwitch("resources-dir-path", path);
                commandLine.AppendSwitch("locales-dir-path", Path.Combine(path, "locales"));
                MelonModLogger.Log($"OnBeforeCommandLineProcessing: {processType} {commandLine}");
            }
示例#16
0
 public override void OnUpdate()
 {
     try
     {
         menu.version_info();
         if (sub_menu_open)
         {
             menu.menu_toggle_handler();
         }
         if (clone_mode)
         {
             direct_clone.direct_menu_clone();
         }
         if (delete_portals)
         {
             antiportal.auto_delete_portals();
         }
         if (isNoclip || fly_mode)
         {
             flying.height_adjust();
         }
         if (Time.time > last_routine && utils.get_player_manager() != null)
         {
             last_routine = Time.time + 1;
             if (anti_crasher)
             {
                 var thrd = new Thread((ThreadStart)anticrash.detect_crasher);
                 thrd.Start();
             }
             if (speed_hacks)
             {
                 speed.set_speeds(walk_speed, run_speed);
             }
             if (info_plus_toggle)
             {
                 infoplus.info_plus();
             }
             if (esp_players)
             {
                 visuals.esp_player();
             }
             fov.set_cam_fov(fov_cam);
         }
         visuals.update_color();
     }
     catch (Exception e)
     {
         MelonModLogger.Log("Error in the main routine! " + e.Message + " in " + e.Source + " Stack: " + e.StackTrace);
     }
 }
示例#17
0
文件: QoL.cs 项目: thelupa1488/QoL
        public override void OnApplicationStart()
        {
            Configuration.LoadConfiguration();

            Modules.Add(new Protections());
            Modules.Add(new UIButtons());
            Modules.Add(new InputHandler());

            MelonModLogger.Log("=========== KEYBINDS ==============");
            MelonModLogger.Log("F9  - Clone Selected Avatar");
            MelonModLogger.Log("F10 - Enable/Disable Flight");
            MelonModLogger.Log("F11 - Enable/Disable Selected ESP");
            MelonModLogger.Log("===================================");
        }
示例#18
0
        private void TransportLayer_OnMessageReceived(ITransportConnection connection, P2PMessage msg)
        {
            MessageType type = (MessageType)msg.ReadByte();

            switch (type)
            {
            case MessageType.GunFireHit:
            {
                byte playerId = smallPlayerIds[connection.ConnectedTo];
                if (playerObjects.ContainsKey(playerId))
                {
                    PlayerRep pr = playerObjects[playerId];

                    if (pr.rigTransforms.main != null)
                    {
                        GameObject instance = Instantiate(GunResources.HurtSFX, pr.rigTransforms.main);
                        Destroy(instance, 3);
                    }
                }
                GunFireHit gff = new GunFireHit()
                {
                    playerId = playerId
                };
                ServerSendToAllExcept(gff, MessageSendType.Unreliable, connection.ConnectedTo);
                break;
            }

            case MessageType.GunFire:
            {
                bool           didHit;
                GunFireMessage gfm = new GunFireMessage(msg);
                Ray            ray = new Ray(gfm.fireOrigin, gfm.fireDirection);

                if (Physics.Raycast(ray, out RaycastHit hit, int.MaxValue, ~0, QueryTriggerInteraction.Ignore))
                {
                    if (hit.transform.root.gameObject == BWUtil.RigManager)
                    {
                        MelonModLogger.Log("Hit BRETT!");
                        int random = UnityEngine.Random.Range(0, 10);
                        BWUtil.LocalPlayerHealth.TAKEDAMAGE(gfm.bulletDamage, random == 0);
                        GunFireHit gff = new GunFireHit();
                        ServerSendToAll(gff, MessageSendType.Reliable);
                    }
                    else
                    {
                        MelonModLogger.Log("Hit!");
                    }
                    didHit = true;
                }
示例#19
0
        public static bool UpdateIfDirty()
        {
            if (!_dirty)
            {
                return(false);
            }
            _dirty = false;

            if (!File.Exists(FullPath))
            {
                MelonModLogger.Log(
                    $"Creating default config file at \"{FullPath}\""
                    );
                var sampleConfig = new List <GravityConfig>
                {
                    new GravityConfig(),
                    new GravityConfig
                    {
                        gravity        = new SerializedVector3(0, 9.81f, 0),
                        trigger        = KeyCode.O,
                        holdToActivate = true,
                    },
                };

                var json = JSON.Dump(
                    sampleConfig,
                    EncodeOptions.PrettyPrint | EncodeOptions.NoTypeHints
                    );
                File.WriteAllText(FullPath, json);
            }

            MelonModLogger.Log("Updating gravity configs");

            GravityConfigs.Clear();

            try
            {
                var json = File.ReadAllText(FullPath);
                JSON.MakeInto(JSON.Load(json), out GravityConfigs);
            }
            catch (Exception e)
            {
                MelonModLogger.LogError(e.ToString());
            }

            GravityConfigs = GravityConfigs ?? new List <GravityConfig>();

            return(true);
        }
示例#20
0
        private void TransportLayer_OnConnectionClosed(ITransportConnection connection, ConnectionClosedReason reason)
        {
            if (connection.ConnectedTo != ServerId)
            {
                MelonModLogger.LogError("Connection with non-server ID was closed - but we're a client???");
                return;
            }

            ui.SetState(MultiplayerUIState.PreConnect);
            MelonModLogger.LogError("Got P2P connection error " + reason.ToString());
            foreach (PlayerRep pr in playerObjects.Values)
            {
                pr.Destroy();
            }
        }
示例#21
0
        // Async operations
        //Task<Facepunch.Steamworks.Data.Image?> task_asyncLoadPlayerIcon;
        //public bool isPlayerIconLoaded = false;

        public static void LoadFord()
        {
            fordBundle = AssetBundle.LoadFromFile("ford.ford");
            if (fordBundle == null)
            {
                MelonModLogger.LogError("Failed to load Ford asset bundle");
            }

            GameObject fordPrefab = fordBundle.LoadAsset("Assets/brett_body.prefab").Cast <GameObject>();

            if (fordPrefab == null)
            {
                MelonModLogger.LogError("Failed to load Ford from the asset bundle???");
            }
        }
示例#22
0
 public static void InitialiseGunPrefabs()
 {
     foreach (UnityEngine.Object obj in FindObjectsOfType <UnityEngine.Object>())
     {
         MelonModLogger.Log("found obj " + obj.name);
         if (obj.TryCast <GameObject>() != null)
         {
             GameObject go = obj.Cast <GameObject>();
             if (go.scene.name == null || go.scene.rootCount == 0)
             {
                 MelonModLogger.Log("Found prefab: " + go.name);
             }
         }
     }
 }
        private void StartCef()
        {
            var cefMainArgs = new CefMainArgs(new string[] { });
            var cefApp      = new OffscreenCEFClient.OffscreenCEFApp();

            // This is where the code path diverges for child processes.
            if (CefRuntime.ExecuteProcess(cefMainArgs, cefApp, IntPtr.Zero) != -1)
            {
                MelonModLogger.Log("Could not start the secondary process.");
            }

            var cefSettings = new CefSettings
            {
                MultiThreadedMessageLoop = false,
                SingleProcess            = true,
                LogSeverity = CefLogSeverity.Verbose,
                LogFile     = "cef.log",
                WindowlessRenderingEnabled = true,
                NoSandbox = true,
            };

            // Start the browser process (a child process).
            CefRuntime.Initialize(cefMainArgs, cefSettings, cefApp, IntPtr.Zero);

            // Instruct CEF to not render to a window.
            var cefWindowInfo = CefWindowInfo.Create();

            cefWindowInfo.SetAsWindowless(IntPtr.Zero, false);

            // Settings for the browser window itself (e.g. enable JavaScript?).
            var cefBrowserSettings = new CefBrowserSettings()
            {
                BackgroundColor           = new CefColor(255, 60, 85, 115),
                JavaScript                = CefState.Enabled,
                JavaScriptAccessClipboard = CefState.Disabled,
                JavaScriptCloseWindows    = CefState.Disabled,
                JavaScriptDomPaste        = CefState.Disabled,
                JavaScriptOpenWindows     = CefState.Disabled,
                LocalStorage              = CefState.Disabled
            };

            // Initialize some of the custom interactions with the browser process.
            this.cefClient = new OffscreenCEFClient(this.windowSize, this.hideScrollbars);

            // Start up the browser instance.
            CefBrowserHost.CreateBrowser(cefWindowInfo, this.cefClient, cefBrowserSettings,
                                         string.IsNullOrEmpty(this.url) ? "http://www.google.com" : this.url);
        }
 private static void ToggleMap(IntPtr selfPtr, IntPtr ownerPtr)
 {
     if (OnToggleMap == null)
     {
         OrigToggleMap?.Invoke(selfPtr, ownerPtr);
         return;
     }
     try
     {
         OnToggleMap(OrigToggleMap, selfPtr.ToGameObject(ptr => new MenuManager(ptr)), ownerPtr.ToGameObject(ptr => new CharacterUI(ptr)));
     }
     catch (Exception e)
     {
         MelonModLogger.LogError($"An error occurred while executing MenuManagerHooks.OnToggleMap hooks: {e}");
     }
 }
 public JintInstance()
 {
     myengine = new Engine(
         cfg =>
     {
         cfg.AllowClr(AppDomain.CurrentDomain.GetAssemblies());
         cfg.CatchClrExceptions(exception =>
         {
             MelonModLogger.Log(exception.Message);
             return(true);
         });
         //cfg.AddObjectConverter<Il2IntMyConverter>();
         //cfg.AddObjectConverter<Il2floatMyConverter>();
         cfg.SetWrapObjectHandler(WrapObjectHandler);
     });
 }
示例#26
0
        public override void VRChat_OnUiManagerInit()
        {
            ButtonCreator socBut = new ButtonCreator();

            socBut.Name    = "flySocialMenu";
            socBut.Text    = "<color=white>Fly Toggle</color>";
            socBut.ToolTip = "Fly/noclip";
            socBut.CreateOnSocialCtxt("UserInfo/User Panel/Playlists", Vector2.zero, new System.Action(() =>
            {
                MelonModLogger.Log("[Social Menu] Toggling flying");

                //Get Players
                VRCPlayer player = VRCPlayer.field_Internal_Static_VRCPlayer_0;
                //TODO
            }));
        }
示例#27
0
        public static void OnSelect(IntPtr @this)
        {
            AudicaRPC.SongSelectItem_OnSelect.InvokeOriginal(@this);
            MelonModLogger.Log("Song Selected!");

            SongList.SongData currentSong = SongDataHolder.I.songData;

            Presence.state          = currentSong.artist;
            Presence.details        = currentSong.title;
            Presence.startTimestamp = default(long);
            Presence.largeImageKey  = "audica_main";
            Presence.largeImageText = "Audica";
            Presence.smallImageKey  = "expert";
            Presence.smallImageText = "Expert difficulty";
            DiscordRpc.UpdatePresence(Presence);
        }
示例#28
0
        public static void log_asset_to_social()
        {
            var menu         = GameObject.Find("Screens").transform.Find("UserInfo");
            var userInfo     = menu.transform.GetComponentInChildren <VRC.UI.PageUserInfo>();
            var found_player = utils.get_player(userInfo.user.id);

            if (found_player == null)
            {
                MelonModLogger.Log("player could not be found id " + userInfo.user.id);
                return;
            }

            MelonModLogger.Log("Asset for user " + userInfo.user.displayName + " -> " + found_player.field_Private_VRCAvatarManager_0.field_Private_ApiAvatar_0.assetUrl);
            MelonModLogger.Log("Avatar ID: " + found_player.field_Private_VRCAvatarManager_0.field_Private_ApiAvatar_0.id);
            MelonModLogger.Log("User ID: " + userInfo.user.id);
        }
示例#29
0
        private static ISupportModule Initialize()
        {
            if (Console.Enabled || Imports.IsDebugMode())
            {
                LogSupport.InfoHandler -= System.Console.WriteLine;
                LogSupport.InfoHandler += MelonModLogger.Log;
            }
            LogSupport.WarningHandler -= System.Console.WriteLine;
            LogSupport.WarningHandler += MelonModLogger.LogWarning;
            LogSupport.ErrorHandler   -= System.Console.WriteLine;
            LogSupport.ErrorHandler   += MelonModLogger.LogError;
            if (Imports.IsDebugMode())
            {
                LogSupport.TraceHandler -= System.Console.WriteLine;
                LogSupport.TraceHandler += MelonModLogger.Log;
            }

            try
            {
                unsafe {
                    var tlsHookTarget    = typeof(Uri).Assembly.GetType("Mono.Unity.UnityTls").GetMethod("GetUnityTlsInterface", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).MethodHandle.GetFunctionPointer();
                    var unityMethodField = UnhollowerUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(typeof(Il2CppMono.Unity.UnityTls).GetMethod("GetUnityTlsInterface", BindingFlags.Public | BindingFlags.Static));
                    var unityMethodPtr   = (IntPtr)unityMethodField.GetValue(null);
                    var unityMethod      = *(IntPtr *)unityMethodPtr;
                    Imports.Hook((IntPtr)(&tlsHookTarget), unityMethod);
                }
            } catch (Exception ex) {
                MelonModLogger.LogWarning("Exception while setting up TLS, mods will not be able to use HTTPS: " + ex);
            }

            ClassInjector.DoHook += Imports.Hook;
            GetUnityVersionNumbers(out var major, out var minor, out var patch);
            UnityVersionHandler.Initialize(major, minor, patch);
            ClassInjector.RegisterTypeInIl2Cpp <MelonLoaderComponent>();
            MelonLoaderComponent.CreateComponent();
            SceneManager.sceneLoaded = (
                (SceneManager.sceneLoaded == null)
                ? new Action <Scene, LoadSceneMode>(OnSceneLoad)
                : Il2CppSystem.Delegate.Combine(SceneManager.sceneLoaded, (UnityAction <Scene, LoadSceneMode>) new Action <Scene, LoadSceneMode>(OnSceneLoad)).Cast <UnityAction <Scene, LoadSceneMode> >()
                );
            Camera.onPostRender = (
                (Camera.onPostRender == null)
                ? new Action <Camera>(OnPostRender)
                : Il2CppSystem.Delegate.Combine(Camera.onPostRender, (Camera.CameraCallback) new Action <Camera>(OnPostRender)).Cast <Camera.CameraCallback>()
                );
            return(new Module());
        }
示例#30
0
        // Prints the properties of a given component type
        public static void PrintComponentProps <T>(GameObject go)
        {
            try
            {
                if (go == null)
                {
                    MelonModLogger.LogError("go was null???");
                }

                T t = go.GetComponent <T>();

                if (t == null)
                {
                    MelonModLogger.LogError("Couldn't find component " + t.GetType().Name);
                }

                MelonModLogger.Log("====== Component type " + t.ToString() + "======");

                System.Reflection.PropertyInfo[] props = typeof(T).GetProperties();

                foreach (var pi in props)
                {
                    //if (pi.PropertyType.IsPrimitive)
                    try
                    {
                        var val = pi.GetValue(t);
                        if (val != null)
                        {
                            MelonModLogger.Log(pi.Name + ": " + val.ToString());
                        }
                        else
                        {
                            MelonModLogger.Log(pi.Name + ": null");
                        }
                    }
                    catch
                    {
                        MelonModLogger.LogError("Error tring to get property " + pi.Name);
                    }
                }
            }
            catch
            {
                MelonModLogger.LogError("i don't know anymore");
            }
        }