//well this was a failure. I am very glad we have a public reference to charge
        //at least the spin calculation wasn't a similarly colossal failure

        // god f****n dammit now i need this to work so I can calculate the overcharge
        private float pseudoCalculateCharge(Run.FixedTimeStamp now, LaserTurbineController self)
        {
            float num  = now - _pseudoSnapshotTime;
            float num2 = self.minSpin * num;
            float num3 = _pseudoInitialSpin - self.minSpin;
            float t    = Mathf.Min(Trajectory.CalculateFlightDuration(num3, -self.spinDecayRate) * 0.5f, num);
            float num4 = Trajectory.CalculatePositionYAtTime(0f, num3, t, -self.spinDecayRate);

            return(Mathf.Min(_pseudoInitialCharge + num2 + num4, 1f));
        }
Example #2
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;
        }