Ejemplo n.º 1
0
    // Token: 0x06005583 RID: 21891 RVA: 0x001D81E8 File Offset: 0x001D65E8
    private void Update()
    {
        if (this.Source == null || this.Target == null || this._renderer == null)
        {
            return;
        }
        Vector3  vector    = this.Target.position;
        Collider component = this.Target.GetComponent <Collider>();

        if (component != null)
        {
            vector = PhysicsUtil.ClosestPointOnCollider(component, this.Source.position);
        }
        base.transform.LookAt(vector);
        float magnitude = (vector - this.Source.position).magnitude;

        this.Source.localScale = new Vector3(magnitude, 1f, 1f);
        this._renderer.material.mainTextureScale   = new Vector2(magnitude * this.TextureScale, 1f);
        this._renderer.material.mainTextureOffset += new Vector2(Time.deltaTime * this.ScrollSpeed, 0f);
    }
Ejemplo n.º 2
0
    // Token: 0x06005390 RID: 21392 RVA: 0x001CD23C File Offset: 0x001CB63C
    public static Vector3 ClosestPointOnCollider(Collider col, Vector3 pt, ref bool isPointInside)
    {
        if (col == null)
        {
            return(Vector3.zero);
        }
        SphereCollider sphereCollider = col as SphereCollider;

        if (sphereCollider != null)
        {
            return(PhysicsUtil.ClosestPointOnCollider(sphereCollider, pt, ref isPointInside));
        }
        BoxCollider boxCollider = col as BoxCollider;

        if (boxCollider != null)
        {
            return(PhysicsUtil.ClosestPointOnCollider(boxCollider, pt, ref isPointInside));
        }
        CapsuleCollider capsuleCollider = col as CapsuleCollider;

        if (capsuleCollider != null)
        {
            return(PhysicsUtil.ClosestPointOnCollider(capsuleCollider, pt, ref isPointInside));
        }
        Bounds     bounds    = col.bounds;
        bool       flag      = pt.x >= bounds.min.x && pt.x <= bounds.max.x && pt.y >= bounds.min.y && pt.y <= bounds.max.y && pt.z >= bounds.min.z && pt.z <= bounds.max.z;
        Vector3    vector    = (!flag) ? col.ClosestPointOnBounds(pt) : pt;
        Vector3    direction = bounds.center - vector;
        Ray        ray       = new Ray(vector, direction);
        RaycastHit raycastHit;

        if (col.Raycast(ray, out raycastHit, direction.magnitude))
        {
            isPointInside = false;
            return(raycastHit.point);
        }
        isPointInside = flag;
        return(col.ClosestPointOnBounds(pt));
    }
Ejemplo n.º 3
0
    // Token: 0x060062A4 RID: 25252 RVA: 0x0022F1A8 File Offset: 0x0022D5A8
    protected VRCUiCursor.CursorOver[] CheckCursorTouch(VRCUiCursor.CursorRaycast target)
    {
        if (VRCPlayer.Instance == null)
        {
            return(new VRCUiCursor.CursorOver[0]);
        }
        VRCHandGrasper handGrasper = VRCPlayer.Instance.GetHandGrasper((this.handedness != VRCUiCursor.CursorHandedness.Left) ? ControllerHand.Right : ControllerHand.Left);

        if (handGrasper != null && handGrasper.IsHoldingObject())
        {
            return(new VRCUiCursor.CursorOver[0]);
        }
        int     num    = -1;
        Vector3 point  = Vector3.zero;
        Vector3 normal = Vector3.zero;
        float   num2   = float.PositiveInfinity;

        VRC_Interactable[] array      = null;
        VRC_Pickup         vrc_Pickup = null;
        VRC_PlayerApi      apiPlayer  = VRCPlayer.Instance.apiPlayer;

        Collider[] array2 = Physics.OverlapSphere(target.touch.position, target.touch.radius, VRCUiCursorManager.GetCurrentInteractiveLayers());
        for (int i = 0; i < array2.Length; i++)
        {
            bool    flag    = false;
            Vector3 vector  = PhysicsUtil.ClosestPointOnCollider(array2[i], target.touch.position, ref flag);
            Vector3 vector2 = vector - target.touch.position;
            float   dist    = (!flag) ? vector2.magnitude : 0f;
            if (dist <= target.touch.radius)
            {
                VRC_Interactable[] array3 = (from inter in array2[i].GetComponents <VRC_Interactable>()
                                             where inter.IsInteractiveForPlayer(apiPlayer)
                                             select inter).ToArray <VRC_Interactable>();
                VRC_Pickup vrc_Pickup2 = array2[i].GetComponent <VRC_Pickup>();
                if (array3.Length != 0 || !(vrc_Pickup2 == null))
                {
                    if (array3 != null && (array3.Length == 0 || array3.All((VRC_Interactable x) => dist > x.proximity)))
                    {
                        array3 = null;
                    }
                    VRC_StationInternal component = array2[i].GetComponent <VRC_StationInternal>();
                    if (array3 != null && component != null && component.Occupant == VRCPlayer.Instance.gameObject)
                    {
                        array3 = null;
                    }
                    if (vrc_Pickup2 != null && (!vrc_Pickup2.pickupable || !VRCPlayer.Instance.canPickupObjects || (vrc_Pickup2.IsHeld && vrc_Pickup2.DisallowTheft && vrc_Pickup2.currentPlayer != apiPlayer)))
                    {
                        vrc_Pickup2 = null;
                    }
                    if (vrc_Pickup2 != null && vrc_Pickup2.currentlyHeldBy != null && dist > VRCHandGrasper.LerpToHandMinDistance)
                    {
                        vrc_Pickup2 = null;
                    }
                    if ((vrc_Pickup2 != null && vrc_Pickup == null) || dist <= num2)
                    {
                        if (!(vrc_Pickup2 == null) || (array3 != null && array3.Length != 0))
                        {
                            num        = i;
                            num2       = dist;
                            point      = vector;
                            normal     = vector2.normalized;
                            array      = array3;
                            vrc_Pickup = vrc_Pickup2;
                        }
                    }
                }
            }
        }
        if (num < 0)
        {
            return(new VRCUiCursor.CursorOver[0]);
        }
        target.hitInfo.distance = num2;
        target.hitInfo.normal   = normal;
        target.hitInfo.point    = point;
        target.pickup           = vrc_Pickup;
        target.interactable     = array;
        if (vrc_Pickup != null && array != null)
        {
            target.over = new VRCUiCursor.CursorOver[]
            {
                VRCUiCursor.CursorOver.Pickup,
                VRCUiCursor.CursorOver.Interactable
            };
        }
        else if (array != null)
        {
            target.over = new VRCUiCursor.CursorOver[]
            {
                VRCUiCursor.CursorOver.Interactable
            };
        }
        else if (vrc_Pickup != null)
        {
            target.over = new VRCUiCursor.CursorOver[]
            {
                VRCUiCursor.CursorOver.Pickup
            };
        }
        else
        {
            target.over = new VRCUiCursor.CursorOver[0];
        }
        return(target.over);
    }
Ejemplo n.º 4
0
    // Token: 0x0600538F RID: 21391 RVA: 0x001CD224 File Offset: 0x001CB624
    public static Vector3 ClosestPointOnCollider(Collider col, Vector3 pt)
    {
        bool flag = false;

        return(PhysicsUtil.ClosestPointOnCollider(col, pt, ref flag));
    }