示例#1
0
        public static bool GetRaycast(GameObject Target, Vector3 StartPos, out Vector3 Point)
        {
            Point = Vector3.zero;

            if (Target == null)
            {
                return(false);
            }

            int BackupLayer = Target.layer;

            Target.layer = LayerMasks.AGENT;

            RaycastComponent Component = Target.GetComponent <RaycastComponent>();

            if (VectorUtilities.GetDistance(Target.transform.position, StartPos) <= 15.5f)
            {
                Point = OptimizationVariables.MainPlayer.transform.position;
                return(true);
            }

            Vector3[] verts = Component.Sphere.GetComponent <MeshCollider>().sharedMesh.vertices;

            Vector3[] nVerts =
                verts
                .Select(v => Component.Sphere.transform.TransformPoint(v))
                .ToArray();

            for (int i = 0; i < nVerts.Length; i++)
            {
                Vector3 Vertex = nVerts[i];
                Vector3 Normal = VectorUtilities.Normalize(Vertex - StartPos);

                double Distance = VectorUtilities.GetDistance(StartPos, Vertex);

                if (Physics.Raycast(StartPos, Normal, (float)Distance + 0.5f, RayMasks.DAMAGE_CLIENT))
                {
                    continue;
                }

                Target.layer = BackupLayer;
                Point        = Vertex;

                return(true);
            }

            Target.layer = BackupLayer;
            return(false);
        }
示例#2
0
        // Token: 0x060000A5 RID: 165 RVA: 0x00007A20 File Offset: 0x00005C20
        public static bool GetRaycast(GameObject Target, Vector3 StartPos, out Vector3 Point)
        {
            Point = Vector3.zero;
            bool flag  = Target == null;
            bool flag2 = flag;
            bool result;

            if (flag2)
            {
                result = false;
            }
            else
            {
                int layer = Target.layer;
                Target.layer = LayerMasks.AGENT;
                RaycastComponent Component = Target.GetComponent <RaycastComponent>();
                bool             flag3     = VectorUtilities.GetDistance(Target.transform.position, StartPos) <= 15.5;
                bool             flag4     = flag3;
                if (flag4)
                {
                    Point  = OptimizationVariables.MainPlayer.transform.position;
                    result = true;
                }
                else
                {
                    Vector3[] vertices = Component.Sphere.GetComponent <MeshCollider>().sharedMesh.vertices;
                    foreach (Vector3 vector in (from v in vertices
                                                select Component.Sphere.transform.TransformPoint(v)).ToArray <Vector3>())
                    {
                        Vector3 direction = VectorUtilities.Normalize(vector - StartPos);
                        double  distance  = VectorUtilities.GetDistance(StartPos, vector);
                        bool    flag1337  = Physics.Raycast(StartPos, direction, (float)distance + 0.5f, RayMasks.DAMAGE_CLIENT);
                        if (!flag1337)
                        {
                            Target.layer = layer;
                            Point        = vector;
                            return(true);
                        }
                    }
                    Target.layer = layer;
                    result       = false;
                }
            }
            return(result);
        }
示例#3
0
        public static bool GetTargetObject(HashSet <GameObject> Objects, out GameObject Object, out Vector3 Point, float Range)
        {
            double Distance = Range + 1;
            double FOV      = 180;

            Object = null;
            Point  = Vector3.zero;

            Vector3 AimPos     = OptimizationVariables.MainPlayer.look.aim.position;
            Vector3 AimForward = OptimizationVariables.MainPlayer.look.aim.forward;

            foreach (GameObject go in Objects)
            {
                if (go == null)
                {
                    continue;
                }

                Vector3 TargetPos = go.transform.position;

                Player p = go.GetComponent <Player>();
                if (p && (p.life.isDead || FriendUtilities.IsFriendly(p)))
                {
                    continue;
                }

                Zombie z = go.GetComponent <Zombie>();
                if (z && z.isDead)
                {
                    continue;
                }

                RaycastComponent Component = go.GetComponent <RaycastComponent>();

                if (Component == null)
                {
                    go.AddComponent <RaycastComponent>();
                    continue;
                }

                double NewDistance = VectorUtilities.GetDistance(AimPos, TargetPos);

                if (NewDistance > Range)
                {
                    continue;
                }

                if (RaycastOptions.SilentAimUseFOV)
                {
                    double _FOV = VectorUtilities.GetAngleDelta(AimPos, AimForward, TargetPos);
                    if (_FOV > RaycastOptions.SilentAimFOV)
                    {
                        continue;
                    }

                    if (_FOV > FOV)
                    {
                        continue;
                    }

                    FOV = _FOV;
                }

                else if (NewDistance > Distance)
                {
                    continue;
                }

                if (!SphereUtilities.GetRaycast(go, AimPos, out Vector3 _Point))
                {
                    continue;
                }

                Object   = go;
                Distance = NewDistance;
                Point    = _Point;
            }

            return(Object != null);
        }