Example #1
0
        private void ESP_RenderObject()
        {
            if (m_enabled || m_vrEnabled)
            {
                if (!m_styleSetup)
                {
                    SetupStyle();
                    m_styleSetup = !m_styleSetup;
                }

                foreach (Player p in m_players)
                {
                    VRCPlayer vrcPlayer = p.vrcPlayer;
                    Animator  animator;

                    if (vrcPlayer == null)
                    {
                        animator = null;
                    }
                    else
                    {
                        VRCAvatarManager vrcAvatarManager = vrcPlayer.AvatarManager();
                        if (vrcAvatarManager == null)
                        {
                            animator = null;
                        }
                        else
                        {
                            GameObject currentAvatar = vrcAvatarManager.currentAvatarObject;
                            animator = ((currentAvatar != null) ? currentAvatar.GetComponent <Animator>() : null);
                        }
                    }

                    if (animator != null)
                    {
                        void DrawBoneEsp(HumanBodyBones bone1, HumanBodyBones bone2)
                        {
                            try
                            {
                                GL.Begin(GL.LINES);
                                m_mat.SetPass(0);
                                GL.Color(GetGroupColour(p));
                                GL.Vertex(animator.GetBoneTransform(bone1).position);
                                GL.Vertex(animator.GetBoneTransform(bone2).position /* + new Vector3(0, .5f, 0)*/);
                            }
                            catch { }
                            finally
                            {
                                GL.End();
                            }
                        }

                        /*EspType espType = ConfigFile.Config.Common.EspType;
                         *
                         * if (espType == EspType.Cute)
                         * {
                         *  for (int j = 0; j < 56; j++)
                         *  {
                         *      if (j == 0)
                         *      {
                         *          continue;
                         *      }
                         *
                         *      DrawBoneEsp((HumanBodyBones)j - 1, (HumanBodyBones)j);
                         *  }
                         * }
                         * else if (espType == EspType.Bone)*/
                        {
                            // hips to left toes
                            DrawBoneEsp(HumanBodyBones.Hips, HumanBodyBones.LeftUpperLeg);
                            DrawBoneEsp(HumanBodyBones.LeftUpperLeg, HumanBodyBones.LeftLowerLeg);
                            DrawBoneEsp(HumanBodyBones.LeftLowerLeg, HumanBodyBones.LeftFoot);
                            DrawBoneEsp(HumanBodyBones.LeftFoot, HumanBodyBones.LeftToes);

                            // hips to right toes
                            DrawBoneEsp(HumanBodyBones.Hips, HumanBodyBones.RightUpperLeg);
                            DrawBoneEsp(HumanBodyBones.RightUpperLeg, HumanBodyBones.RightLowerLeg);
                            DrawBoneEsp(HumanBodyBones.RightLowerLeg, HumanBodyBones.RightFoot);
                            DrawBoneEsp(HumanBodyBones.RightFoot, HumanBodyBones.RightToes);

                            // hips to head
                            DrawBoneEsp(HumanBodyBones.Hips, HumanBodyBones.Spine);
                            DrawBoneEsp(HumanBodyBones.Spine, HumanBodyBones.Chest);
                            DrawBoneEsp(HumanBodyBones.Chest, HumanBodyBones.Neck);
                            DrawBoneEsp(HumanBodyBones.Neck, HumanBodyBones.Head);

                            // chest to left hand
                            DrawBoneEsp(HumanBodyBones.Chest, HumanBodyBones.LeftShoulder);
                            DrawBoneEsp(HumanBodyBones.LeftShoulder, HumanBodyBones.LeftUpperArm);
                            DrawBoneEsp(HumanBodyBones.LeftUpperArm, HumanBodyBones.LeftLowerArm);
                            DrawBoneEsp(HumanBodyBones.LeftLowerArm, HumanBodyBones.LeftHand);

                            // chest to right hand
                            DrawBoneEsp(HumanBodyBones.Chest, HumanBodyBones.RightShoulder);
                            DrawBoneEsp(HumanBodyBones.RightShoulder, HumanBodyBones.RightUpperArm);
                            DrawBoneEsp(HumanBodyBones.RightUpperArm, HumanBodyBones.RightLowerArm);
                            DrawBoneEsp(HumanBodyBones.RightLowerArm, HumanBodyBones.RightHand);

                            // right fingers
                            // thumb
                            DrawBoneEsp(HumanBodyBones.RightHand, HumanBodyBones.RightThumbProximal);
                            DrawBoneEsp(HumanBodyBones.RightThumbProximal, HumanBodyBones.RightThumbIntermediate);
                            DrawBoneEsp(HumanBodyBones.RightThumbIntermediate, HumanBodyBones.RightThumbDistal);

                            // index
                            DrawBoneEsp(HumanBodyBones.RightHand, HumanBodyBones.RightIndexProximal);
                            DrawBoneEsp(HumanBodyBones.RightIndexProximal, HumanBodyBones.RightIndexIntermediate);
                            DrawBoneEsp(HumanBodyBones.RightIndexIntermediate, HumanBodyBones.RightIndexDistal);

                            // middle
                            DrawBoneEsp(HumanBodyBones.RightHand, HumanBodyBones.RightMiddleProximal);
                            DrawBoneEsp(HumanBodyBones.RightMiddleProximal, HumanBodyBones.RightMiddleIntermediate);
                            DrawBoneEsp(HumanBodyBones.RightMiddleIntermediate, HumanBodyBones.RightMiddleDistal);

                            // ring
                            DrawBoneEsp(HumanBodyBones.RightHand, HumanBodyBones.RightRingProximal);
                            DrawBoneEsp(HumanBodyBones.RightRingProximal, HumanBodyBones.RightRingIntermediate);
                            DrawBoneEsp(HumanBodyBones.RightRingIntermediate, HumanBodyBones.RightRingDistal);

                            // little
                            DrawBoneEsp(HumanBodyBones.RightHand, HumanBodyBones.RightLittleProximal);
                            DrawBoneEsp(HumanBodyBones.RightLittleProximal, HumanBodyBones.RightLittleIntermediate);
                            DrawBoneEsp(HumanBodyBones.RightLittleIntermediate, HumanBodyBones.RightLittleDistal);

                            // left fingers
                            // thumb
                            DrawBoneEsp(HumanBodyBones.LeftHand, HumanBodyBones.LeftThumbProximal);
                            DrawBoneEsp(HumanBodyBones.LeftThumbProximal, HumanBodyBones.LeftThumbIntermediate);
                            DrawBoneEsp(HumanBodyBones.LeftThumbIntermediate, HumanBodyBones.LeftThumbDistal);

                            // index
                            DrawBoneEsp(HumanBodyBones.LeftHand, HumanBodyBones.LeftIndexProximal);
                            DrawBoneEsp(HumanBodyBones.LeftIndexProximal, HumanBodyBones.LeftIndexIntermediate);
                            DrawBoneEsp(HumanBodyBones.LeftIndexIntermediate, HumanBodyBones.LeftIndexDistal);

                            // middle
                            DrawBoneEsp(HumanBodyBones.LeftHand, HumanBodyBones.LeftMiddleProximal);
                            DrawBoneEsp(HumanBodyBones.LeftMiddleProximal, HumanBodyBones.LeftMiddleIntermediate);
                            DrawBoneEsp(HumanBodyBones.LeftMiddleIntermediate, HumanBodyBones.LeftMiddleDistal);

                            // ring
                            DrawBoneEsp(HumanBodyBones.LeftHand, HumanBodyBones.LeftRingProximal);
                            DrawBoneEsp(HumanBodyBones.LeftRingProximal, HumanBodyBones.LeftRingIntermediate);
                            DrawBoneEsp(HumanBodyBones.LeftRingIntermediate, HumanBodyBones.LeftRingDistal);

                            // little
                            DrawBoneEsp(HumanBodyBones.LeftHand, HumanBodyBones.LeftLittleProximal);
                            DrawBoneEsp(HumanBodyBones.LeftLittleProximal, HumanBodyBones.LeftLittleIntermediate);
                            DrawBoneEsp(HumanBodyBones.LeftLittleIntermediate, HumanBodyBones.LeftLittleDistal);
                        }
                    }
                }
            }

            if (m_vrEnabled)
            {
                foreach (Player p in m_players)
                {
                    if (p == null || p.ApiUser() == null)
                    {
                        continue;
                    }

                    string displayName = p.ApiUser().displayName;

                    // draw player tag
                    if (!m_names.ContainsKey(displayName))
                    {
                        GameObject obj = new GameObject();
                        UnityEngine.Object.DontDestroyOnLoad(obj);
                        Text t = obj.AddComponent <Text>();

                        t.text  = displayName;
                        t.color = GetGroupColour(p);

                        m_names[displayName] = obj;
                    }
                    m_names[displayName].transform.LookAt(VRCVrCamera.GetInstance().screenCamera.transform.position);
                    m_names[displayName].transform.position = p.transform.position;

                    GameObject myAvatar   = PlayerWrappers.GetLocalPlayer().vrcPlayer.AvatarManager().currentAvatarObject;
                    Animator   myAnimator = ((myAvatar != null) ? myAvatar.GetComponent <Animator>() : null);
                    Vector3    myPos      = PlayerWrappers.GetLocalPlayer().transform.position;

                    if (myAnimator != null)
                    {
                        myPos = myAnimator.GetBoneTransform(HumanBodyBones.LeftIndexDistal).position;

                        if (myPos == null)
                        {
                            myPos = myAnimator.GetBoneTransform(HumanBodyBones.LeftIndexIntermediate).position;
                        }

                        if (myPos == null)
                        {
                            myPos = myAnimator.GetBoneTransform(HumanBodyBones.LeftIndexProximal).position;
                        }

                        if (myPos == null)
                        {
                            myPos = myAnimator.GetBoneTransform(HumanBodyBones.LeftHand).position;
                        }
                    }

                    GameObject targetAvatar   = p.vrcPlayer.AvatarManager().currentAvatarObject;
                    Animator   targetAnimator = ((targetAvatar != null) ? targetAvatar.GetComponent <Animator>() : null);
                    Vector3    targetPos      = p.transform.position;

                    if (targetAnimator != null)
                    {
                        targetPos = targetAnimator.GetBoneTransform(HumanBodyBones.Head).position;
                    }

                    GL.Begin(GL.LINES);
                    m_mat.SetPass(0);
                    GL.Color(GetGroupColour(p));
                    GL.Vertex(myPos);
                    GL.Vertex(targetPos);
                    GL.End();
                }
            }
        }
Example #2
0
        private void Update()
        {
            if (!RoomManagerBaseWrappers.InRoom)
            {
                return;
            }

            if (m_localPlayer == null)
            {
                VRC.Player player = PlayerWrappers.GetLocalPlayer();

                if (player != null) // early init I guess
                {
                    m_localPlayer = player;
                }
            }

            if (m_localPlayer == null)
            {
                return; // wait until player is ready
            }

            bool controller = VRCInputManagerWrappers.LastInputMethod == InputMethod.Controller;
            bool oculus     = VRCInputManagerWrappers.LastInputMethod == InputMethod.Oculus;
            bool desktop    = (VRCInputManagerWrappers.LastInputMethod == InputMethod.Keyboard || VRCInputManagerWrappers.LastInputMethod == InputMethod.Mouse);

            bool isActiveController = controller && Input.GetKey(KeyCode.JoystickButton5);
            bool isActiveOculus     = oculus && Input.GetKey((KeyCode)Oculus.LeftThumbstickPress);
            bool isActiveDesktop    = desktop && (Input.GetKey(KeyCode.Mouse4) || Input.GetKey(KeyCode.RightControl));

            bool swapSpeedsController = controller && Input.GetKey(KeyCode.JoystickButton9);
            bool swapSpeedsOculus     = oculus && Input.GetKey((KeyCode)Oculus.AButton);
            bool swapSpeedsKeyboard   = desktop && Input.GetKey(KeyCode.LeftShift);

            bool isActive   = isActiveController || isActiveOculus || isActiveDesktop;
            bool swapSpeeds = swapSpeedsKeyboard || swapSpeedsController || swapSpeedsOculus;

            if (isActive && Time.time - m_lastTime > 1f)
            {
                if (m_airbreakActive)
                {
                    DisableAirbreak();
                }
                else
                {
                    SetupAirbreak();
                }

                m_airbreakActive = !m_airbreakActive;

                m_lastTime = Time.time;
            }

            if (swapSpeeds && m_airbreakActive && Time.time - m_lastTime > 0.2f)
            {
                m_speedIndex += 1;

                if (m_speedIndex > m_speeds.Count() - 1)
                {
                    m_speedIndex = 0;
                }

                m_currentSpeed = m_speeds[m_speedIndex];
                m_lastTime     = Time.time;
            }

            // get default fallback
            VRCVrCameraOculus[] ctrls = ((VRCVrCameraOculus[])UnityEngine.Object.FindObjectsOfType(typeof(VRCVrCameraOculus)));

            Transform trans = null;

            if (ctrls.Length > 0)
            {
                trans = ctrls[0].transform;
            }

            // alright so
            // let's start by getting our current vrcPlayer
            VRCPlayer vrcPlayer = PlayerWrappers.GetLocalPlayer().vrcPlayer;

            Animator animator = null;

            if (vrcPlayer == null)
            {
                animator = null;
            }
            else
            {
                // let's get our avatar manager
                VRCAvatarManager vrcAvatarManager = vrcPlayer.AvatarManager();

                if (vrcAvatarManager == null)
                {
                    animator = null;
                }
                else
                {
                    // current avatar
                    GameObject currentAvatar = vrcAvatarManager.currentAvatarObject;
                    animator = ((currentAvatar != null) ? currentAvatar.GetComponent <Animator>() : null);
                }
            }

            // if the animator is not null at this stage and airbreak is enabled
            if (animator != null)
            {
                // get the head bone
                Transform tempTrans = animator.GetBoneTransform(HumanBodyBones.Head);

                // if we're humanoid
                if (tempTrans != null)
                {
                    // use the head bone's transform instead of oculus camera
                    trans = tempTrans;
                }
            }

            if (trans == null)
            {
                return;
            }

            if (Input.GetKey(KeyCode.W))
            {
                m_position += trans.forward * m_currentSpeed * Time.deltaTime;
            }

            if (Input.GetKey(KeyCode.A))
            {
                m_position += (trans.right * -1) * m_currentSpeed * Time.deltaTime;
            }

            if (Input.GetKey(KeyCode.S))
            {
                m_position += (trans.forward * -1) * m_currentSpeed * Time.deltaTime;
            }

            if (Input.GetKey(KeyCode.D))
            {
                m_position += trans.right * m_currentSpeed * Time.deltaTime;
            }

            if (Input.GetKey(KeyCode.E))
            {
                m_position += m_localPlayer.transform.up * m_currentSpeed * Time.deltaTime;
            }

            if (Input.GetKey(KeyCode.Q))
            {
                m_position += (m_localPlayer.transform.up * -1) * m_currentSpeed * Time.deltaTime;
            }

            if ((Input.GetAxis("Joy1 Axis 2") != 0))
            {
                m_position += trans.forward * m_currentSpeed * Time.deltaTime * (Input.GetAxis("Joy1 Axis 2") * -1);
            }

            if (Input.GetAxis("Joy1 Axis 1") != 0)
            {
                m_position += trans.right * m_currentSpeed * Time.deltaTime * Input.GetAxis("Joy1 Axis 1");
            }

            if (m_airbreakActive)
            {
                m_localPlayer.transform.position = m_position;
            }
        }