示例#1
0
        // Token: 0x06000312 RID: 786 RVA: 0x0000C688 File Offset: 0x0000A888
        private void UpdateTrajectoryInfo()
        {
            this.aimRay = base.GetAimRay();
            RaycastHit raycastHit;

            if (Util.CharacterRaycast(base.gameObject, this.aimRay, out raycastHit, this.maxDistance, LayerIndex.world.mask | LayerIndex.entityPrecise.mask, QueryTriggerInteraction.UseGlobal))
            {
                this.hitPoint  = raycastHit.point;
                this.hitNormal = raycastHit.normal;
            }
            else
            {
                this.hitPoint  = this.aimRay.GetPoint(this.maxDistance);
                this.hitNormal = -this.aimRay.direction;
            }
            float   num       = this.projectileBaseSpeed;
            Vector3 vector    = this.hitPoint - this.aimRay.origin;
            Vector2 vector2   = new Vector2(vector.x, vector.z);
            float   magnitude = vector2.magnitude;
            float   y         = Trajectory.CalculateInitialYSpeed(magnitude / num, vector.y);
            Vector3 a         = new Vector3(vector2.x / magnitude * num, y, vector2.y / magnitude * num);

            this.speedOverride = a.magnitude;
            this.finalRay      = new Ray(this.aimRay.origin, a / this.speedOverride);
            this.travelTime    = Trajectory.CalculateGroundTravelTime(num, magnitude);
        }
        // Token: 0x06002964 RID: 10596 RVA: 0x000AE168 File Offset: 0x000AC368
        protected virtual void UpdateTrajectoryInfo(out AimThrowableBase.TrajectoryInfo dest)
        {
            dest = default(AimThrowableBase.TrajectoryInfo);
            Ray        aimRay     = base.GetAimRay();
            RaycastHit raycastHit = default(RaycastHit);
            bool       flag       = false;

            if (this.rayRadius > 0f && Util.CharacterSpherecast(base.gameObject, aimRay, this.rayRadius, out raycastHit, this.maxDistance, LayerIndex.CommonMasks.bullet, QueryTriggerInteraction.UseGlobal) && raycastHit.collider.GetComponent <HurtBox>())
            {
                flag = true;
            }
            if (!flag)
            {
                flag = Util.CharacterRaycast(base.gameObject, aimRay, out raycastHit, this.maxDistance, LayerIndex.CommonMasks.bullet, QueryTriggerInteraction.UseGlobal);
            }
            if (flag)
            {
                dest.hitPoint  = raycastHit.point;
                dest.hitNormal = raycastHit.normal;
            }
            else
            {
                dest.hitPoint  = aimRay.GetPoint(this.maxDistance);
                dest.hitNormal = -aimRay.direction;
            }
            Vector3 vector = dest.hitPoint - aimRay.origin;

            if (this.useGravity)
            {
                float   num       = this.projectileBaseSpeed;
                Vector2 vector2   = new Vector2(vector.x, vector.z);
                float   magnitude = vector2.magnitude;
                float   y         = Trajectory.CalculateInitialYSpeed(magnitude / num, vector.y);
                Vector3 a         = new Vector3(vector2.x / magnitude * num, y, vector2.y / magnitude * num);
                dest.speedOverride = a.magnitude;
                dest.finalRay      = new Ray(aimRay.origin, a / dest.speedOverride);
                dest.travelTime    = Trajectory.CalculateGroundTravelTime(num, magnitude);
                return;
            }
            dest.speedOverride = this.projectileBaseSpeed;
            dest.finalRay      = aimRay;
            dest.travelTime    = this.projectileBaseSpeed / vector.magnitude;
        }
示例#3
0
            // Token: 0x06001D93 RID: 7571 RVA: 0x0008A328 File Offset: 0x00088528
            public float JumpTest(Vector3 startCenterOfCapsulePos, Vector3 endCenterOfCapsulePos, float hSpeed)
            {
                float y = Trajectory.CalculateInitialYSpeed(Trajectory.CalculateGroundTravelTime(hSpeed, MapNode.MoveProbe.DistanceXZ(startCenterOfCapsulePos, endCenterOfCapsulePos)), endCenterOfCapsulePos.y - startCenterOfCapsulePos.y);

                this.testCharacterController.Move(Vector3.zero);
                Vector3 a = endCenterOfCapsulePos - startCenterOfCapsulePos;

                a.y = 0f;
                a.Normalize();
                a  *= hSpeed;
                a.y = y;
                float num = MapNode.MoveProbe.DistanceXZ(startCenterOfCapsulePos, endCenterOfCapsulePos);

                this.testCharacterController.transform.position = startCenterOfCapsulePos;
                int     num2 = Mathf.CeilToInt(num * 1.5f / hSpeed / this.testTimeStep);
                float   num3 = float.NegativeInfinity;
                Vector3 rhs  = this.testCharacterController.transform.position;

                for (int i = 0; i < num2; i++)
                {
                    Vector3 vector = endCenterOfCapsulePos - this.testCharacterController.transform.position;
                    if (vector.sqrMagnitude <= 4f)
                    {
                        return(num3 - startCenterOfCapsulePos.y);
                    }
                    num3 = Mathf.Max(this.testCharacterController.transform.position.y, num3);
                    Vector3 vector2 = vector;
                    vector2.y = 0f;
                    vector2.Normalize();
                    a.x = vector2.x * hSpeed;
                    a.z = vector2.z * hSpeed;
                    a  += Physics.gravity * this.testTimeStep;
                    this.testCharacterController.Move(a * this.testTimeStep);
                    Vector3 position = this.testCharacterController.transform.position;
                    if (position == rhs)
                    {
                        return(0f);
                    }
                    rhs = position;
                }
                return(0f);
            }
示例#4
0
        private void UpdateTrajInfo(out TrajectoryInfo traj)
        {
            traj = default(TrajectoryInfo);
            Ray        aimRay = base.GetAimRay();
            RaycastHit rHit   = default(RaycastHit);

            Vector3 direction = aimRay.direction;

            direction.y = Mathf.Max(direction.y, EntityStates.Croco.BaseLeap.minimumY);
            Vector3 a  = direction.normalized * EntityStates.Croco.BaseLeap.aimVelocity * this.moveSpeedStat;
            Vector3 b  = Vector3.up * EntityStates.Croco.BaseLeap.upwardVelocity;
            Vector3 b2 = new Vector3(direction.x, 0f, direction.z).normalized *EntityStates.Croco.BaseLeap.forwardVelocity;

            Vector3 velocity     = a + b + b2;
            Vector3 tempVelocity = velocity;
            Ray     r            = new Ray(aimRay.origin, velocity);

            Single time     = Trajectory.CalculateFlightDuration(velocity.y);
            Single timeStep = time / 25f;

            Vector3 oldPos = aimRay.origin;

            Boolean hit = false;

            List <Vector3> vecs = new List <Vector3>(100);

            for (Int32 i = 0; i < 100; i++)
            {
                Vector3 pos = Trajectory.CalculatePositionAtTime(r.origin, tempVelocity, timeStep * i, Physics.gravity.y);

                tempVelocity *= Mathf.Exp(timeStep * -0.4f);

                hit = Physics.SphereCast(oldPos, 0.2f, (pos - oldPos), out rHit, (pos - oldPos).magnitude, LayerIndex.world.mask | LayerIndex.entityPrecise.mask, QueryTriggerInteraction.UseGlobal);
                if (hit)
                {
                    break;
                }

                oldPos = pos;
                vecs.Add(pos);
            }

            arcLineRender.positionCount = vecs.Count;
            arcLineRender.SetPositions(vecs.ToArray());

            if (hit)
            {
                traj.hitPoint  = rHit.point;
                traj.hitNormal = rHit.normal;
            }
            else
            {
                traj.hitPoint  = oldPos;
                traj.hitNormal = Vector3.up;
            }

            Vector3 diff = traj.hitPoint - aimRay.origin;

            if (useGravity)
            {
                Single  speed    = velocity.magnitude;
                Vector2 flatDiff = new Vector2(diff.x, diff.z);
                Single  flatDist = flatDiff.magnitude;
                Single  yStart   = Trajectory.CalculateInitialYSpeed(flatDist / speed, diff.y);

                Vector3 speedVec = new Vector3(flatDiff.x / flatDist * speed, yStart, flatDiff.y / flatDist * speed);

                traj.speedOverride = speedVec.magnitude;
                traj.finalRay      = new Ray(aimRay.origin, speedVec / traj.speedOverride);
                traj.travelTime    = Trajectory.CalculateGroundTravelTime(speed, flatDist);
                return;
            }

            traj.speedOverride = baseSpeed;
            traj.finalRay      = aimRay;
            traj.travelTime    = baseSpeed / diff.magnitude;
        }
示例#5
0
        // Token: 0x06001DF4 RID: 7668 RVA: 0x00080FE0 File Offset: 0x0007F1E0
        private void ReconstructPath(Path path, NodeGraph.LinkIndex[] cameFrom, NodeGraph.LinkIndex current, NodeGraph.PathRequest pathRequest)
        {
            int num = 1 << (int)pathRequest.hullClassification;

            path.Clear();
            if (current != NodeGraph.LinkIndex.invalid)
            {
                path.PushWaypointToFront(this.links[current.linkIndex].nodeIndexB, 0f);
            }
            while (current != NodeGraph.LinkIndex.invalid)
            {
                NodeGraph.NodeIndex nodeIndexB = this.links[current.linkIndex].nodeIndexB;
                float minJumpHeight            = 0f;
                if ((num & this.links[current.linkIndex].jumpHullMask) != 0 && this.links[current.linkIndex].minJumpHeight > 0f)
                {
                    Vector3 position  = this.nodes[this.links[current.linkIndex].nodeIndexA.nodeIndex].position;
                    Vector3 position2 = this.nodes[this.links[current.linkIndex].nodeIndexB.nodeIndex].position;
                    minJumpHeight = Trajectory.CalculateApex(Trajectory.CalculateInitialYSpeed(Trajectory.CalculateGroundTravelTime(pathRequest.maxSpeed, NodeGraph.DistanceXZ(position, position2)), position2.y - position.y));
                }
                path.PushWaypointToFront(nodeIndexB, minJumpHeight);
                if (cameFrom[this.links[current.linkIndex].nodeIndexA.nodeIndex] == NodeGraph.LinkIndex.invalid)
                {
                    path.PushWaypointToFront(this.links[current.linkIndex].nodeIndexA, 0f);
                }
                current = cameFrom[this.links[current.linkIndex].nodeIndexA.nodeIndex];
            }
            path.status = PathStatus.Valid;
        }
示例#6
0
        // Token: 0x06001DF2 RID: 7666 RVA: 0x00080B04 File Offset: 0x0007ED04
        public PathTask ComputePath(NodeGraph.PathRequest pathRequest)
        {
            PathTask pathTask = new PathTask(pathRequest.path);

            pathTask.status = PathTask.TaskStatus.Running;
            NodeGraph.NodeIndex nodeIndex  = this.FindClosestNode(pathRequest.startPos, pathRequest.hullClassification);
            NodeGraph.NodeIndex nodeIndex2 = this.FindClosestNode(pathRequest.endPos, pathRequest.hullClassification);
            if (nodeIndex.nodeIndex == NodeGraph.NodeIndex.invalid.nodeIndex || nodeIndex2.nodeIndex == NodeGraph.NodeIndex.invalid.nodeIndex)
            {
                pathRequest.path.Clear();
                pathTask.status = PathTask.TaskStatus.Complete;
                return(pathTask);
            }
            int num = 1 << (int)pathRequest.hullClassification;

            bool[] array  = new bool[this.nodes.Length];
            bool[] array2 = new bool[this.nodes.Length];
            array2[nodeIndex.nodeIndex] = true;
            int i = 1;

            NodeGraph.NodeIndex[] array3 = new NodeGraph.NodeIndex[this.nodes.Length];
            array3[0] = nodeIndex;
            NodeGraph.LinkIndex[] array4 = new NodeGraph.LinkIndex[this.nodes.Length];
            for (int j = 0; j < array4.Length; j++)
            {
                array4[j] = NodeGraph.LinkIndex.invalid;
            }
            float[] array5 = new float[this.nodes.Length];
            for (int k = 0; k < array5.Length; k++)
            {
                array5[k] = float.PositiveInfinity;
            }
            array5[nodeIndex.nodeIndex] = 0f;
            float[] array6 = new float[this.nodes.Length];
            for (int l = 0; l < array6.Length; l++)
            {
                array6[l] = float.PositiveInfinity;
            }
            array6[nodeIndex.nodeIndex] = this.HeuristicCostEstimate(pathRequest.startPos, pathRequest.endPos);
            while (i > 0)
            {
                NodeGraph.NodeIndex invalid = NodeGraph.NodeIndex.invalid;
                float num2 = float.PositiveInfinity;
                for (int m = 0; m < i; m++)
                {
                    int nodeIndex3 = array3[m].nodeIndex;
                    if (array6[nodeIndex3] <= num2)
                    {
                        num2    = array6[nodeIndex3];
                        invalid = new NodeGraph.NodeIndex(nodeIndex3);
                    }
                }
                if (invalid.nodeIndex == nodeIndex2.nodeIndex)
                {
                    this.ReconstructPath(pathRequest.path, array4, array4[invalid.nodeIndex], pathRequest);
                    pathTask.status = PathTask.TaskStatus.Complete;
                    return(pathTask);
                }
                array2[invalid.nodeIndex] = false;
                NodeGraph.ArrayRemoveNodeIndex(array3, invalid, i);
                i--;
                array[invalid.nodeIndex] = true;
                NodeGraph.LinkListIndex linkListIndex = this.nodes[invalid.nodeIndex].linkListIndex;
                NodeGraph.LinkIndex     linkIndex     = new NodeGraph.LinkIndex
                {
                    linkIndex = linkListIndex.index
                };
                NodeGraph.LinkIndex linkIndex2 = new NodeGraph.LinkIndex
                {
                    linkIndex = linkListIndex.index + (int)linkListIndex.size
                };
                while (linkIndex.linkIndex < linkIndex2.linkIndex)
                {
                    NodeGraph.Link      link       = this.links[linkIndex.linkIndex];
                    NodeGraph.NodeIndex nodeIndexB = link.nodeIndexB;
                    if (!array[nodeIndexB.nodeIndex])
                    {
                        if ((num & link.jumpHullMask) != 0 && this.links[linkIndex.linkIndex].minJumpHeight > 0f)
                        {
                            Vector3 position  = this.nodes[link.nodeIndexA.nodeIndex].position;
                            Vector3 position2 = this.nodes[link.nodeIndexB.nodeIndex].position;
                            if (Trajectory.CalculateApex(Trajectory.CalculateInitialYSpeed(Trajectory.CalculateGroundTravelTime(pathRequest.maxSpeed, NodeGraph.DistanceXZ(position, position2)), position2.y - position.y)) > pathRequest.maxJumpHeight)
                            {
                                goto IL_41A;
                            }
                        }
                        if ((link.hullMask & num) != 0 && (link.gateIndex == 0 || this.openGates[(int)link.gateIndex]))
                        {
                            float num3 = array5[invalid.nodeIndex] + link.distanceScore;
                            if (!array2[nodeIndexB.nodeIndex])
                            {
                                array2[nodeIndexB.nodeIndex] = true;
                                array3[i] = nodeIndexB;
                                i++;
                            }
                            else if (num3 >= array5[nodeIndexB.nodeIndex])
                            {
                                goto IL_41A;
                            }
                            array4[nodeIndexB.nodeIndex] = linkIndex;
                            array5[nodeIndexB.nodeIndex] = num3;
                            array6[nodeIndexB.nodeIndex] = array5[nodeIndexB.nodeIndex] + this.HeuristicCostEstimate(this.nodes[nodeIndexB.nodeIndex].position, this.nodes[nodeIndex2.nodeIndex].position);
                        }
                    }
IL_41A:
                    linkIndex.linkIndex++;
                }
            }
            pathRequest.path.Clear();
            pathTask.status = PathTask.TaskStatus.Complete;
            return(pathTask);
        }