Ejemplo n.º 1
0
        public OBFUnityActionInternal(Type type, object instance)
        {
            MethodInfo[] addRemoveMethods = type.GetMethods().Where(a => a.GetParameters().Length > 0 && a.GetParameters()[0].ParameterType == typeof(UnityAction <T>)).ToArray();
            if (addRemoveMethods.Length < 2)
            {
                ExtendedLogger.LogError("Failed to find required UnityActionInternal functions for type: " + type.Name + "!");
                return;
            }

            if (addRemoveMethods[0].GetMethodBody().GetILAsByteArray().Length > addRemoveMethods[1].GetMethodBody().GetILAsByteArray().Length)
            {
                MethodAdd    = addRemoveMethods[0];
                MethodRemove = addRemoveMethods[1];
            }
            else
            {
                MethodAdd    = addRemoveMethods[1];
                MethodRemove = addRemoveMethods[0];
            }
            MethodExecute = type.GetMethods().First(a => a.GetParameters()[0].ParameterType == typeof(T));

            ExtendedLogger.Log("Found Execute method in " + type.Name + " with name: " + MethodExecute.Name + "!");
            ExtendedLogger.Log("Found Add method in " + type.Name + " with name: " + MethodAdd.Name + "!");
            ExtendedLogger.Log("Found Remove method in " + type.Name + " with name: " + MethodRemove.Name + "!");

            Instance = instance;
        }
Ejemplo n.º 2
0
        void OnApplicationFocus(bool hasFocus)
        {
            if (!ModPrefs.GetBool("vrcextended", "fpsManagement"))
            {
                return;
            }

            if (!hasFocus)
            {
                Application.targetFrameRate = 5;
                ExtendedLogger.Log("Game out of focus, setting FPS to " + Application.targetFrameRate);
            }
            else
            {
                if (ModPrefs.GetBool("vrcextended", "unlimitedFPS"))
                {
                    Application.targetFrameRate = 0;
                }
                else
                {
                    Application.targetFrameRate = VRCExtended.FrameRate;
                }
                ExtendedLogger.Log("Game in focus, setting FPS to " + Application.targetFrameRate);
            }
        }
Ejemplo n.º 3
0
        void OnTriggerExit(Collider collider)
        {
            if (collider.tag != "handCollider")
            {
                return;
            }

            /*if (VRCEPlayer.Instance.Avatar == collider.gameObject)
             *  return;*/

            ExtendedLogger.Log("Exited collider!");
        }
Ejemplo n.º 4
0
        internal static void Setup()
        {
            _player_get_user     = typeof(Player).GetMethod("get_user", BindingFlags.Public | BindingFlags.Instance);
            _player_get_Instance = typeof(Player).GetMethod("get_Instance", BindingFlags.Public | BindingFlags.Static);

            _vrcplayer_get_AvatarManager = typeof(VRCPlayer).GetMethod("get_AvatarManager", BindingFlags.Public | BindingFlags.Instance);
#if DEBUG
            _vrcplayer_get_uSpeaker = typeof(VRCPlayer).GetMethod("get_uSpeaker", BindingFlags.Public | BindingFlags.Instance);

            _uspeaker_AudioSource = typeof(USpeaker).GetFields(BindingFlags.NonPublic | BindingFlags.Instance).First(a => a.FieldType == typeof(AudioSource));
            ExtendedLogger.Log("Found user voice AudioSource: " + _uspeaker_AudioSource.Name);
#endif
        }
Ejemplo n.º 5
0
        public static void Setup()
        {
            // Setup harmony instances
            HarmonyInstance iSetupUserInfo = HarmonyInstance.Create("vrcextended.pageuserinfo.setupuserinfo");

            // Patch
            try
            {
                iSetupUserInfo.Patch(typeof(PageUserInfo).GetMethods(BindingFlags.Public | BindingFlags.Instance).First(a => a.Name == "SetupUserInfo" && a.GetParameters().Length > 1), null,
                                     new HarmonyMethod(typeof(Patch_PageUserInfo).GetMethod("SetupUserInfo", BindingFlags.NonPublic | BindingFlags.Static)));
                ExtendedLogger.Log("Patched PageUserInfo.SetupUserInfo");
            }
            catch (Exception ex)
            {
                ExtendedLogger.LogError("Failed to patch PageUserInfo!", ex);
                return;
            }
        }
Ejemplo n.º 6
0
        public static void Setup()
        {
            // Setup harmony instances
            HarmonyInstance iEnter = HarmonyInstance.Create("vrcextended.portalinternal.enter");

            // Patch
            try
            {
                iEnter.Patch(typeof(PortalInternal).GetMethod("Enter", BindingFlags.Public | BindingFlags.Instance),
                             new HarmonyMethod(typeof(Patch_PortalInternal).GetMethod("Enter", BindingFlags.Static | BindingFlags.NonPublic)));
                ExtendedLogger.Log("Patched PortalInternal.Enter");
            }
            catch (Exception ex)
            {
                ExtendedLogger.LogError("Failed to patch PortalInternal: " + ex);
                return;
            }
        }
Ejemplo n.º 7
0
        internal static void Setup()
        {
            // Network manager setup
            _networkManagerType = typeof(PlayerManager).Assembly.GetType("NetworkManager");
            if (_networkManagerType == null)
            {
                ExtendedLogger.LogError("Failed to get NetworkManager!");
                return;
            }
            ExtendedLogger.Log("Found NetworkManager!");

            _networkManagerInstance = _networkManagerType.GetField("Instance", BindingFlags.Public | BindingFlags.Static);
            if (_networkManagerInstance == null)
            {
                ExtendedLogger.LogError("Failed to get NetworkManager Instance!");
                return;
            }
            ExtendedLogger.Log("Found NetworkManager Instance!");

            FieldInfo onPlayerJoinedEvent = _networkManagerType.GetField("OnPlayerJoinedEvent", BindingFlags.Public | BindingFlags.Instance);

            if (onPlayerJoinedEvent == null)
            {
                ExtendedLogger.LogError("Failed to get NetworkManager OnPlayerJoinedEvent!");
                return;
            }
            ExtendedLogger.Log("Found NetworkManager OnPlayerJoinedEvent!");

            FieldInfo onPlayerLeftEvent = _networkManagerType.GetField("OnPlayerLeftEvent", BindingFlags.Public | BindingFlags.Instance);

            if (onPlayerLeftEvent == null)
            {
                ExtendedLogger.LogError("Failed to get NetworkManager OnPlayerLeftEvent!");
                return;
            }
            ExtendedLogger.Log("Found NetworkManager OnPlayerLeftEvent!");

            Type unityActionInternalType = onPlayerJoinedEvent.FieldType;

            if (unityActionInternalType == null)
            {
                ExtendedLogger.LogError("Failed to get UnityActionInternal!");
                return;
            }
            ExtendedLogger.Log("Found UnityActionInternal named " + unityActionInternalType.Name + "!");

            _networkManager_OnPlayerJoinedEvent = new OBFUnityActionInternal <Player>(unityActionInternalType, onPlayerJoinedEvent.GetValue(_networkManagerInstance.GetValue(null)));
            _networkManager_OnPlayerLeftEvent   = new OBFUnityActionInternal <Player>(unityActionInternalType, onPlayerLeftEvent.GetValue(_networkManagerInstance.GetValue(null)));

            _networkManager_OnPlayerJoinedEvent.Add(new UnityAction <Player>(delegate(Player player)
            {
                if (OnPlayerJoined != null)
                {
                    OnPlayerJoined(new VRCEPlayer(player));
                }
            }));
            _networkManager_OnPlayerLeftEvent.Add(new UnityAction <Player>(delegate(Player player)
            {
                if (OnPlayerLeft != null)
                {
                    OnPlayerLeft(new VRCEPlayer(player));
                }
            }));
        }