public static bool Linecast(INavmesh graph, VInt3 tmp_origin, VInt3 tmp_end, GraphNode hint, out GraphHitInfo hit, List <GraphNode> trace)
        {
            VInt3 vInt  = tmp_end;
            VInt3 vInt2 = tmp_origin;

            hit = default(GraphHitInfo);
            if (float.IsNaN((float)(tmp_origin.x + tmp_origin.y + tmp_origin.z)))
            {
                throw new ArgumentException("origin is NaN");
            }
            if (float.IsNaN((float)(tmp_end.x + tmp_end.y + tmp_end.z)))
            {
                throw new ArgumentException("end is NaN");
            }
            TriangleMeshNode triangleMeshNode = hint as TriangleMeshNode;

            if (triangleMeshNode == null)
            {
                triangleMeshNode = ((graph as NavGraph).GetNearest(tmp_origin, NNConstraint.None).node as TriangleMeshNode);
                if (triangleMeshNode == null)
                {
                    Debug.LogError("Could not find a valid node to start from");
                    hit.point = tmp_origin;
                    return(true);
                }
            }
            if (vInt2 == vInt)
            {
                hit.node = triangleMeshNode;
                return(false);
            }
            vInt2      = (VInt3)triangleMeshNode.ClosestPointOnNode((Vector3)vInt2);
            hit.origin = vInt2;
            if (!triangleMeshNode.Walkable)
            {
                hit.point         = vInt2;
                hit.tangentOrigin = vInt2;
                return(true);
            }
            List <VInt3> list = ListPool <VInt3> .Claim();

            List <VInt3> list2 = ListPool <VInt3> .Claim();

            int num = 0;

            while (true)
            {
                num++;
                if (num > 2000)
                {
                    break;
                }
                TriangleMeshNode triangleMeshNode2 = null;
                if (trace != null)
                {
                    trace.Add(triangleMeshNode);
                }
                if (triangleMeshNode.ContainsPoint(vInt))
                {
                    goto Block_9;
                }
                for (int i = 0; i < triangleMeshNode.connections.Length; i++)
                {
                    if (triangleMeshNode.connections[i].GraphIndex == triangleMeshNode.GraphIndex)
                    {
                        list.Clear();
                        list2.Clear();
                        if (triangleMeshNode.GetPortal(triangleMeshNode.connections[i], list, list2, false))
                        {
                            VInt3 vInt3 = list.get_Item(0);
                            VInt3 vInt4 = list2.get_Item(0);
                            float num2;
                            float num3;
                            if ((Polygon.LeftNotColinear(vInt3, vInt4, hit.origin) || !Polygon.LeftNotColinear(vInt3, vInt4, tmp_end)) && Polygon.IntersectionFactor(vInt3, vInt4, hit.origin, tmp_end, out num2, out num3) && num3 >= 0f && num2 >= 0f && num2 <= 1f)
                            {
                                triangleMeshNode2 = (triangleMeshNode.connections[i] as TriangleMeshNode);
                                break;
                            }
                        }
                    }
                }
                if (triangleMeshNode2 == null)
                {
                    goto Block_17;
                }
                triangleMeshNode = triangleMeshNode2;
            }
            Debug.LogError("Linecast was stuck in infinite loop. Breaking.");
            ListPool <VInt3> .Release(list);

            ListPool <VInt3> .Release(list2);

            return(true);

Block_9:
            ListPool <VInt3> .Release(list);

            ListPool <VInt3> .Release(list2);

            return(false);

Block_17:
            int vertexCount = triangleMeshNode.GetVertexCount();

            for (int j = 0; j < vertexCount; j++)
            {
                VInt3   vertex  = triangleMeshNode.GetVertex(j);
                VInt3   vertex2 = triangleMeshNode.GetVertex((j + 1) % vertexCount);
                VFactor vFactor;
                VFactor vFactor2;
                if ((Polygon.LeftNotColinear(vertex, vertex2, hit.origin) || !Polygon.LeftNotColinear(vertex, vertex2, tmp_end)) && Polygon.IntersectionFactor(vertex, vertex2, hit.origin, tmp_end, out vFactor, out vFactor2) && !vFactor2.IsNegative && !vFactor.IsNegative && vFactor.nom / vFactor.den <= 1L)
                {
                    VInt3 vInt5 = (vertex2 - vertex) * (float)vFactor.nom;
                    vInt5             = IntMath.Divide(vInt5, vFactor.den);
                    vInt5            += vertex;
                    hit.point         = vInt5;
                    hit.node          = triangleMeshNode;
                    hit.tangent       = vertex2 - vertex;
                    hit.tangentOrigin = vertex;
                    ListPool <VInt3> .Release(list);

                    ListPool <VInt3> .Release(list2);

                    return(true);
                }
            }
            Debug.LogWarning("Linecast failing because point not inside node, and line does not hit any edges of it");
            ListPool <VInt3> .Release(list);

            ListPool <VInt3> .Release(list2);

            return(false);
        }
示例#2
0
 public static int Lerp(int src, int dest, int nom, int den)
 {
     return(IntMath.Divide(src * den + (dest - src) * nom, den));
 }
示例#3
0
    private static void MoveAlongEdge(TriangleMeshNode node, int edge, VInt3 srcLoc, VInt3 destLoc, out VInt3 result)
    {
        bool flag;

        DebugHelper.Assert((edge >= 0) && (edge <= 2));
        VInt3 vertex = node.GetVertex(edge);
        VInt3 num2   = node.GetVertex((edge + 1) % 3);
        VInt3 num3   = destLoc - srcLoc;

        num3.y = 0;
        VInt3 a = num2 - vertex;

        a.y = 0;
        a.NormalizeTo(0x3e8);
        int   num5 = (a.x * num3.x) + (a.z * num3.z);
        VInt3 rhs  = Polygon.IntersectionPoint(ref vertex, ref num2, ref srcLoc, ref destLoc, out flag);

        if (!flag)
        {
            if (!Polygon.IsColinear(vertex, num2, srcLoc) || !Polygon.IsColinear(vertex, num2, destLoc))
            {
                result = srcLoc;
                return;
            }
            if (num5 >= 0)
            {
                int num7 = (a.x * (num2.x - vertex.x)) + (a.z * (num2.z - vertex.z));
                int num8 = (a.x * (destLoc.x - vertex.x)) + (a.z * (destLoc.z - vertex.z));
                rhs = (num7 <= num8) ? num2 : destLoc;
                DebugHelper.Assert((num7 >= 0) && (num8 >= 0));
            }
            else
            {
                int num9  = (-a.x * (vertex.x - num2.x)) - (a.z * (vertex.z - num2.z));
                int num10 = (-a.x * (destLoc.x - num2.x)) - (a.z * (destLoc.z - num2.z));
                rhs = (Mathf.Abs(num9) <= Mathf.Abs(num10)) ? vertex : destLoc;
                DebugHelper.Assert((num9 >= 0) && (num10 >= 0));
            }
        }
        int num11 = -IntMath.Sqrt(vertex.XZSqrMagnitude(rhs) * 0xf4240L);
        int num12 = IntMath.Sqrt(num2.XZSqrMagnitude(rhs) * 0xf4240L);

        if ((num5 >= num11) && (num5 <= num12))
        {
            result = IntMath.Divide(a, (long)num5, 0xf4240L) + srcLoc;
            if (!node.ContainsPoint(result))
            {
                int     num15;
                int     num16;
                int     num17;
                int     num18;
                Vector3 vector = (Vector3)(num2 - vertex);
                vector.y = 0f;
                vector.Normalize();
                VInt3 num13 = num2 - vertex;
                num13.y = 0;
                num13  *= 0x2710;
                long    magnitude = num13.magnitude;
                VFactor factor    = new VFactor {
                    nom = num5,
                    den = magnitude * 0x3e8L
                };
                getMinMax(out num15, out num17, (long)num13.x, ref factor);
                getMinMax(out num16, out num18, (long)num13.z, ref factor);
                if (!MakePointInTriangle(ref result, node, num15, num17, num16, num18, srcLoc) && !MakePointInTriangle(ref result, node, num15 - 4, num17 + 4, num16 - 4, num18 + 4, srcLoc))
                {
                    result = srcLoc;
                }
            }
            if (MoveAxisY)
            {
                CalculateY(ref result, node);
            }
        }
        else
        {
            int   num19;
            int   num20;
            VInt3 num21;
            int   num22;
            if (num5 < num11)
            {
                num19 = num5 - num11;
                num20 = (edge + 2) % 3;
                num21 = vertex;
            }
            else
            {
                num19 = num5 - num12;
                num20 = (edge + 1) % 3;
                num21 = num2;
            }
            TriangleMeshNode neighborByEdge = node.GetNeighborByEdge(num20, out num22);
            if (neighborByEdge != null)
            {
                VInt3 num23 = ((VInt3)((a * num19) / 1000000f)) + num21;
                checkedNodes.Add(node);
                MoveFromNode(neighborByEdge, num22, num21, num23, out result);
            }
            else
            {
                result = num21;
            }
        }
    }
    private static void MoveAlongEdge(TriangleMeshNode node, int edge, VInt3 srcLoc, VInt3 destLoc, MoveDirectionState state, out VInt3 result, bool checkAnotherEdge = true)
    {
        DebugHelper.Assert(edge >= 0 && edge <= 2);
        VInt3 vertex  = node.GetVertex(edge);
        VInt3 vertex2 = node.GetVertex((edge + 1) % 3);
        VInt3 vInt    = destLoc - srcLoc;

        vInt.y = 0;
        VInt3 vInt2 = vertex2 - vertex;

        vInt2.y = 0;
        vInt2.NormalizeTo(1000);
        int num;

        if (state != null)
        {
            num = vInt.magnitude2D * 1000;
            VInt3 vInt3 = state.enabled ? state.firstAdjDir : vInt;
            if (VInt3.Dot(ref vInt2, ref vInt3) < 0)
            {
                num   = -num;
                vInt3 = -vInt2;
            }
            else
            {
                vInt3 = vInt2;
            }
            if (!state.enabled)
            {
                state.enabled     = true;
                state.firstAdjDir = VInt3.Lerp(vInt, vInt3, 1, 3);
                state.firstDir    = state.curDir;
                state.adjDir      = vInt3;
            }
            else if (VInt3.Dot(ref state.adjDir, ref vInt3) >= 0)
            {
                state.adjDir = vInt3;
            }
            else
            {
                num = 0;
            }
            state.applied = true;
        }
        else
        {
            num = vInt2.x * vInt.x + vInt2.z * vInt.z;
        }
        bool  flag;
        VInt3 rhs = Polygon.IntersectionPoint(ref vertex, ref vertex2, ref srcLoc, ref destLoc, out flag);

        if (!flag)
        {
            if (!Polygon.IsColinear(vertex, vertex2, srcLoc) || !Polygon.IsColinear(vertex, vertex2, destLoc))
            {
                result = srcLoc;
                return;
            }
            if (num >= 0)
            {
                int num2 = vInt2.x * (vertex2.x - vertex.x) + vInt2.z * (vertex2.z - vertex.z);
                int num3 = vInt2.x * (destLoc.x - vertex.x) + vInt2.z * (destLoc.z - vertex.z);
                rhs = ((num2 > num3) ? destLoc : vertex2);
                DebugHelper.Assert(num2 >= 0 && num3 >= 0);
            }
            else
            {
                int num4 = -vInt2.x * (vertex.x - vertex2.x) - vInt2.z * (vertex.z - vertex2.z);
                int num5 = -vInt2.x * (destLoc.x - vertex2.x) - vInt2.z * (destLoc.z - vertex2.z);
                rhs = ((Mathf.Abs(num4) > Mathf.Abs(num5)) ? destLoc : vertex);
                DebugHelper.Assert(num4 >= 0 && num5 >= 0);
            }
        }
        int num6 = -IntMath.Sqrt(vertex.XZSqrMagnitude(rhs) * 1000000L);
        int num7 = IntMath.Sqrt(vertex2.XZSqrMagnitude(rhs) * 1000000L);

        if (num >= num6 && num <= num7)
        {
            result = IntMath.Divide(vInt2, (long)num, 1000000L) + rhs;
            if (!node.ContainsPoint(result))
            {
                Vector3 vector = (Vector3)(vertex2 - vertex);
                vector.y = 0f;
                vector.Normalize();
                VInt3 lhs = vertex2 - vertex;
                lhs.y = 0;
                lhs  *= 10000;
                long    num8    = (long)lhs.magnitude;
                VFactor vFactor = default(VFactor);
                vFactor.nom = (long)num;
                vFactor.den = num8 * 1000L;
                int num9;
                int num10;
                PathfindingUtility.getMinMax(out num9, out num10, (long)lhs.x, ref vFactor);
                int num11;
                int num12;
                PathfindingUtility.getMinMax(out num11, out num12, (long)lhs.z, ref vFactor);
                if (!PathfindingUtility.MakePointInTriangle(ref result, node, num9, num10, num11, num12, srcLoc) && !PathfindingUtility.MakePointInTriangle(ref result, node, num9 - 4, num10 + 4, num11 - 4, num12 + 4, srcLoc))
                {
                    result = srcLoc;
                }
            }
            if (PathfindingUtility.MoveAxisY)
            {
                PathfindingUtility.CalculateY(ref result, node);
            }
        }
        else
        {
            int   rhs2;
            int   edge2;
            VInt3 vInt4;
            if (num < num6)
            {
                rhs2  = num - num6;
                edge2 = (edge + 2) % 3;
                vInt4 = vertex;
            }
            else
            {
                rhs2  = num - num7;
                edge2 = (edge + 1) % 3;
                vInt4 = vertex2;
            }
            VInt3            vInt5 = vInt2 * rhs2 / 1000000f;
            int              startEdge;
            TriangleMeshNode neighborByEdge = node.GetNeighborByEdge(edge2, out startEdge);
            if (neighborByEdge != null)
            {
                PathfindingUtility.checkedNodes.Add(node);
                PathfindingUtility.MoveFromNode(neighborByEdge, startEdge, vInt4, vInt5 + vInt4, state, out result);
            }
            else
            {
                if (checkAnotherEdge)
                {
                    VInt3 vertex3 = node.GetVertex((edge + 2) % 3);
                    VInt3 lhs2    = (vertex3 - vInt4).NormalizeTo(1000);
                    if (VInt3.Dot(lhs2, vInt5) > 0)
                    {
                        PathfindingUtility.checkedNodes.Add(node);
                        PathfindingUtility.MoveAlongEdge(node, edge2, vInt4, vInt5 + vInt4, state, out result, false);
                        return;
                    }
                }
                result = vInt4;
            }
        }
    }
示例#5
0
 public static VInt3 Transform(VInt3 point, ref VInt3 axis_x, ref VInt3 axis_y, ref VInt3 axis_z, ref VInt3 trans)
 {
     return(new VInt3(IntMath.Divide(axis_x.x * point.x + axis_y.x * point.y + axis_z.x * point.z, 1000) + trans.x, IntMath.Divide(axis_x.y * point.x + axis_y.y * point.y + axis_z.y * point.z, 1000) + trans.y, IntMath.Divide(axis_x.z * point.x + axis_y.z * point.y + axis_z.z * point.z, 1000) + trans.z));
 }
示例#6
0
 public static VInt3 Lerp(VInt3 a, VInt3 b, VFactor f)
 {
     return(new VInt3(((int)IntMath.Divide((long)((b.x - a.x) * f.nom), f.den)) + a.x, ((int)IntMath.Divide((long)((b.y - a.y) * f.nom), f.den)) + a.y, ((int)IntMath.Divide((long)((b.z - a.z) * f.nom), f.den)) + a.z));
 }
示例#7
0
    public void Move(out VInt3 targetDir, int dt)
    {
        targetDir = VInt3.forward;
        if (this.targetReached || !this.canMove)
        {
            return;
        }
        ActorRoot handle   = this.actor.get_handle();
        VInt3     location = handle.location;
        VInt3     vInt     = this.CaculateDir(location);

        if (this.targetDirection.x != 0 || this.targetDirection.z != 0)
        {
            targetDir = this.targetDirection;
            targetDir.NormalizeTo(1000);
        }
        else
        {
            targetDir = handle.forward;
        }
        VInt3 vInt2 = handle.location;
        VInt3 vInt3 = vInt;

        vInt3 *= this.speed * dt / 1000;
        vInt3 /= 1000f;
        bool flag = this.rvo != null && this.rvo.enabled;
        bool hasReachedNavEdge = false;

        if (this.checkNavNode && !flag)
        {
            VInt groundY;
            vInt3          = PathfindingUtility.Move(this.actor, vInt3, out groundY, out hasReachedNavEdge, null);
            handle.groundY = groundY;
        }
        if ((handle.location - this.targetPos).get_sqrMagnitudeLong2D() <= vInt3.get_sqrMagnitudeLong2D())
        {
            if (this.checkNavNode && !this.targetPosIsValid)
            {
                vInt2 = handle.location + vInt3;
            }
            else
            {
                vInt2 = this.targetPos;
            }
            this.targetReached = true;
            this.OnTargetReached();
        }
        else
        {
            vInt2 = handle.location + vInt3;
        }
        if (flag)
        {
            VInt3 vInt4 = vInt2 - handle.location;
            vInt4 = IntMath.Divide(vInt4, 1000L, (long)dt);
            this.rvo.Move(vInt4);
        }
        else
        {
            handle.location          = vInt2;
            handle.hasReachedNavEdge = hasReachedNavEdge;
        }
    }
示例#8
0
 public static Int2 operator *(Int2 v, VFactor f)
 {
     return(IntMath.Divide(v, f.nom, f.den));
 }
示例#9
0
 public static Int3 operator /(Int3 v, VFactor f)
 {
     return(IntMath.Divide(v, f.den, f.nom));
 }
示例#10
0
        public int GetLerpMotionDistance(int _allTime)
        {
            long a = ((long)this.lerpMotionSpeed * (long)_allTime << 1) + (long)this.curLerpAccelaration * ((long)_allTime * (long)_allTime) / 1000L;

            return((int)IntMath.Divide(a, 2000L));
        }
示例#11
0
 public override void Enter(AGE.Action _action, Track _track)
 {
     this.done_ = false;
     base.Enter(_action, _track);
     this.actor_ = _action.GetActorHandle(this.targetId);
     if (this.actor_ != 0)
     {
         if (!this.actor_.handle.isMovable)
         {
             this.actor_.Release();
             this.done_ = true;
         }
         else
         {
             this.actor_.handle.ActorControl.TerminateMove();
             this.actor_.handle.ActorControl.AddNoAbilityFlag(ObjAbilityType.ObjAbility_Move);
             this.lastTime_       = 0;
             this.movement        = this.actor_.handle.MovementComponent as PlayerMovement;
             this.motionControler = new AccelerateMotionControler();
             if (this.movement != null)
             {
                 int motionControlerCount = this.movement.GravityMode.GetMotionControlerCount();
                 if (motionControlerCount < 3)
                 {
                     if (motionControlerCount == 0)
                     {
                         this.motionControler.InitMotionControler(base.length, 0, this.gravity);
                     }
                     else if (motionControlerCount == 1)
                     {
                         this.motionControler.InitMotionControler(base.length, 0, IntMath.Divide((int)(this.gravity * 6), 10));
                     }
                     else if (motionControlerCount == 2)
                     {
                         this.motionControler.InitMotionControler(base.length, 0, IntMath.Divide((int)(this.gravity * 4), 10));
                     }
                     this.movement.GravityMode.AddMotionControler(this.motionControler);
                     this.movement.isFlying = true;
                     this.bMotionControl    = true;
                 }
             }
         }
     }
 }
示例#12
0
        public override int GetMotionDistance(int _allTime)
        {
            long a = ((long)this.motionSpeed * (long)_allTime << 1) + (long)this.curAccelaration * ((long)_allTime * (long)_allTime) / 1000L;

            return((int)IntMath.Divide(a, 2000L));
        }
        public void ProcessInner(AGE.Action _action, Track _track, int delta)
        {
            VInt3 location = this.moveActor.handle.location;

            if ((this.MoveType == ActorMoveType.Target) && (this.tarActor != 0))
            {
                this.destPosition = this.tarActor.handle.location;
                if ((this.tarActor != 0) && (this.tarActor.handle.CharInfo != null))
                {
                    CActorInfo charInfo = this.tarActor.handle.CharInfo;
                    this.hitHeight = charInfo.iBulletHeight;
                    VInt3 a = this.moveActor.handle.location - this.destPosition;
                    a.y = 0;
                    a   = a.NormalizeTo(0x3e8);
                    this.destPosition += IntMath.Divide(a, (long)charInfo.iCollisionSize.x, 0x3e8L);
                }
                this.destPosition.y += this.hitHeight;
            }
            this.moveDirection = this.destPosition - location;
            this.lerpDirection = this.moveDirection;
            if (this.bMoveRotate)
            {
                this.RotateMoveBullet(this.moveDirection);
            }
            int newMagn = 0;

            if (!this.shouldUseAcceleration)
            {
                newMagn = (this.velocity * delta) / 0x3e8;
            }
            else
            {
                long num4 = (this.lastVelocity * delta) + ((((this.acceleration * delta) * delta) / 2L) / 0x3e8L);
                num4              /= 0x3e8L;
                newMagn            = (int)num4;
                this.lastVelocity += (this.acceleration * delta) / 0x3e8;
            }
            if ((newMagn * newMagn) >= this.moveDirection.sqrMagnitudeLong2D)
            {
                this.moveActor.handle.location = this.destPosition;
                this.stopCondtion = true;
            }
            else
            {
                VInt3 num5;
                if (this.gravity < 0)
                {
                    VInt num6;
                    this.moveDirection.y = 0;
                    num5    = location + this.moveDirection.NormalizeTo(newMagn);
                    num5.y += this.gravityControler.GetMotionDeltaDistance(delta);
                    if (PathfindingUtility.GetGroundY(this.destPosition, out num6) && (num5.y < num6.i))
                    {
                        num5.y = num6.i;
                    }
                }
                else
                {
                    num5 = location + this.moveDirection.NormalizeTo(newMagn);
                }
                this.moveActor.handle.location = num5;
            }
            SkillUseContext refParamObject = _action.refParams.GetRefParamObject <SkillUseContext>("SkillContext");

            if (refParamObject != null)
            {
                refParamObject.EffectPos = this.moveActor.handle.location;
                refParamObject.EffectDir = this.moveDirection;
            }
        }
 public void Enter(AGE.Action _action)
 {
     this.skillContext = _action.refParams.GetRefParamObject <SkillUseContext>("SkillContext");
     this.lastTime     = 0;
     this.lastVelocity = this.lastLerpVelocity = this.velocity;
     this.stopCondtion = false;
     this.moveActor    = _action.GetActorHandle(this.targetId);
     if (this.moveActor != 0)
     {
         this.gravityControler = new AccelerateMotionControler();
         this.moveActor.handle.ObjLinker.AddCustomMoveLerp(new CustomMoveLerpFunc(this.ActionMoveLerp));
         if (this.MoveType == ActorMoveType.Target)
         {
             this.tarActor = _action.GetActorHandle(this.destId);
             if (this.tarActor == 0)
             {
                 return;
             }
             this.destPosition = this.tarActor.handle.location;
             CActorInfo charInfo = this.tarActor.handle.CharInfo;
             if (charInfo != null)
             {
                 this.hitHeight = charInfo.iBulletHeight;
                 VInt3 a = this.moveActor.handle.location - this.destPosition;
                 a.y = 0;
                 a   = a.NormalizeTo(0x3e8);
                 this.destPosition += IntMath.Divide(a, (long)charInfo.iCollisionSize.x, 0x3e8L);
             }
             this.destPosition.y += this.hitHeight;
         }
         else if (this.MoveType == ActorMoveType.Directional)
         {
             VInt3 one = VInt3.one;
             if (this.skillContext == null)
             {
                 return;
             }
             PoolObjHandle <ActorRoot> originator = this.skillContext.Originator;
             if (originator == 0)
             {
                 return;
             }
             one = originator.handle.forward.RotateY(this.offsetDir.y);
             this.destPosition   = this.moveActor.handle.location + one.NormalizeTo(this.distance);
             this.destPosition.y = this.moveActor.handle.location.y;
         }
         else if (this.MoveType == ActorMoveType.Position)
         {
             this.destPosition = this.targetPosition;
         }
         if (this.bAdjustSpeed)
         {
             VInt3 num3 = this.destPosition - this.moveActor.handle.location;
             int   num4 = this.length - 100;
             num4          = (num4 > 0) ? num4 : this.length;
             this.velocity = (int)IntMath.Divide((long)(num3.magnitude2D * 0x3e8L), (long)num4);
         }
         if (this.gravity < 0)
         {
             if (this.velocity == 0)
             {
                 this.stopCondtion = true;
             }
             else
             {
                 VInt3 num5 = this.destPosition - this.moveActor.handle.location;
                 int   num6 = 0;
                 if (!this.shouldUseAcceleration)
                 {
                     num6 = (int)IntMath.Divide((long)(num5.magnitude2D * 0x3e8L), (long)this.velocity);
                 }
                 else
                 {
                     long velocity     = this.velocity;
                     long acceleration = this.acceleration;
                     long num9         = num5.magnitude2D;
                     long num10        = (velocity * velocity) + ((2L * acceleration) * num9);
                     num6 = (int)IntMath.Divide((long)((IntMath.Sqrt(num10) - velocity) * 0x3e8L), acceleration);
                     this.lastVelocity = this.lastLerpVelocity = this.velocity;
                 }
                 if (num6 == 0)
                 {
                     this.stopCondtion = true;
                 }
                 else
                 {
                     VInt num11;
                     if (PathfindingUtility.GetGroundY(this.destPosition, out num11))
                     {
                         this.gravityControler.InitMotionControler(num6, num11.i - this.moveActor.handle.location.y, this.gravity);
                     }
                     else
                     {
                         this.gravityControler.InitMotionControler(num6, 0, this.gravity);
                     }
                 }
             }
         }
     }
 }
示例#15
0
 public static VInt3 Cross(VInt3 lhs, VInt3 rhs)
 {
     return(new VInt3(IntMath.Divide(lhs.y * rhs.z - lhs.z * rhs.y, 1000), IntMath.Divide(lhs.z * rhs.x - lhs.x * rhs.z, 1000), IntMath.Divide(lhs.x * rhs.y - lhs.y * rhs.x, 1000)));
 }
 public void Enter(Action _action)
 {
     this.skillContext = _action.refParams.GetRefParamObject <SkillUseContext>("SkillContext");
     this.lastTime     = 0;
     this.lastVelocity = (this.lastLerpVelocity = this.velocity);
     this.stopCondtion = false;
     this.moveActor    = _action.GetActorHandle(this.targetId);
     if (!this.moveActor)
     {
         return;
     }
     this.gravityControler = new AccelerateMotionControler();
     this.xControler       = new xAxisAccelerateMotionControler();
     this.moveActor.handle.ObjLinker.AddCustomMoveLerp(new CustomMoveLerpFunc(this.ActionMoveLerp));
     if (this.MoveType == ActorMoveType.Target)
     {
         if (this.bFindTargetByRotateBodyBullet)
         {
             _action.refParams.GetRefParam("FindEnemyActor", ref this.tarActor);
         }
         else
         {
             this.tarActor = _action.GetActorHandle(this.destId);
         }
         if (!this.tarActor)
         {
             return;
         }
         this.destPosition = this.tarActor.handle.location;
         CActorInfo charInfo = this.tarActor.handle.CharInfo;
         if (charInfo != null)
         {
             this.hitHeight = charInfo.iBulletHeight;
             VInt3 a = this.moveActor.handle.location - this.destPosition;
             a.y = 0;
             a   = a.NormalizeTo(1000);
             this.destPosition += IntMath.Divide(a, (long)charInfo.iCollisionSize.x, 1000L);
         }
         this.destPosition.y = this.destPosition.y + this.hitHeight;
     }
     else if (this.MoveType == ActorMoveType.Directional)
     {
         VInt3 vInt = VInt3.one;
         if (this.skillContext == null)
         {
             return;
         }
         PoolObjHandle <ActorRoot> originator = this.skillContext.Originator;
         if (!originator)
         {
             return;
         }
         if (this.bBulletUseDir)
         {
             _action.refParams.GetRefParam("_BulletUseDir", ref vInt);
         }
         else if (this.bUseIndicatorDir)
         {
             SkillUseContext refParamObject = _action.refParams.GetRefParamObject <SkillUseContext>("SkillContext");
             VInt3           vInt2;
             if (refParamObject != null && refParamObject.CalcAttackerDir(out vInt2, originator))
             {
                 vInt = vInt2;
             }
             else
             {
                 vInt = originator.handle.forward;
             }
         }
         else
         {
             vInt = originator.handle.forward;
         }
         this.moveActor.handle.forward  = vInt;
         this.moveActor.handle.rotation = Quaternion.LookRotation((Vector3)vInt);
         vInt = vInt.RotateY(this.offsetDir.y);
         if (this.bResetMoveDistance)
         {
             int num = 0;
             _action.refParams.GetRefParam("_BulletRealFlyingTime", ref num);
             int num2 = num * this.velocity / 1000;
             this.distance = ((num2 > 0) ? num2 : this.distance);
         }
         this.destPosition   = this.moveActor.handle.location + vInt.NormalizeTo(this.distance);
         this.destPosition.y = this.moveActor.handle.location.y;
     }
     else if (this.MoveType == ActorMoveType.Position)
     {
         if (this.bReachDestStop)
         {
             this.destPosition = this.targetPosition;
         }
         else
         {
             VInt3 lhs = this.targetPosition - this.moveActor.handle.location;
             lhs.y             = 0;
             lhs               = lhs.NormalizeTo(1000);
             this.destPosition = this.moveActor.handle.location + lhs * (this.length * this.velocity / 1000);
             VInt vInt3;
             if (PathfindingUtility.GetGroundY(this.destPosition, out vInt3))
             {
                 this.destPosition.y = vInt3.i;
             }
         }
     }
     else if (this.MoveType == ActorMoveType.RotateBody)
     {
         this.originateActor = this.skillContext.Originator;
         if (!this.originateActor)
         {
             DebugHelper.Assert(false, "产生子弹的originateActor不能为空!!!");
             return;
         }
         this.rotateBodyBulletCount       = Mathf.Clamp(this.rotateBodyBulletCount, 1, 360);
         this.rotateBodyCurDirDegreeAngle = 360 / this.rotateBodyBulletCount * this.skillContext.BulletPos.x;
         VInt3 vInt4 = this.moveActor.handle.forward.RotateY(-this.rotateBodyCurDirDegreeAngle);
         this.moveActor.handle.forward  = vInt4;
         this.moveActor.handle.rotation = Quaternion.LookRotation((Vector3)vInt4);
     }
     if (this.bAdjustSpeed)
     {
         VInt3 vInt5 = this.destPosition - this.moveActor.handle.location;
         int   num3  = this.length - 100;
         num3          = ((num3 <= 0) ? this.length : num3);
         this.velocity = (int)IntMath.Divide((long)vInt5.magnitude2D * 1000L, (long)num3);
     }
     if (this.gravity < 0)
     {
         if (this.velocity == 0)
         {
             this.stopCondtion = true;
             return;
         }
         VInt3 vInt6 = this.destPosition - this.moveActor.handle.location;
         int   num4;
         if (!this.shouldUseAcceleration)
         {
             num4 = (int)IntMath.Divide((long)vInt6.magnitude2D * 1000L, (long)this.velocity);
         }
         else
         {
             long num5 = (long)this.velocity;
             long num6 = (long)this.acceleration;
             long num7 = (long)vInt6.magnitude2D;
             long a2   = num5 * num5 + 2L * num6 * num7;
             num4 = (int)IntMath.Divide(((long)IntMath.Sqrt(a2) - num5) * 1000L, num6);
             this.lastVelocity = (this.lastLerpVelocity = this.velocity);
         }
         if (num4 == 0)
         {
             this.stopCondtion = true;
             return;
         }
         VInt vInt7;
         if (PathfindingUtility.GetGroundY(this.destPosition, out vInt7))
         {
             this.gravityControler.InitMotionControler(num4, vInt7.i - this.moveActor.handle.location.y, this.gravity);
         }
         else
         {
             this.gravityControler.InitMotionControler(num4, 0, this.gravity);
         }
     }
     if (this.bMoveOnXAxis)
     {
         this.zDirection   = this.destPosition - this.moveActor.handle.location;
         this.xDirection   = VInt3.Cross(VInt3.up, this.zDirection);
         this.zCurPosition = this.moveActor.handle.location;
         if (this.bReachDestStop)
         {
             int[]   array  = new int[3];
             VInt3[] array2 = new VInt3[]
             {
                 default(VInt3),
                 default(VInt3),
                 this.destPosition - this.moveActor.handle.location
             };
             array2[0] = array2[2];
             array2[1] = array2[2];
             array2[0].NormalizeTo(this.distanceZ0);
             array2[1].NormalizeTo(this.distanceZ1);
             for (int i = 0; i < array.Length; i++)
             {
                 if (!this.shouldUseAcceleration)
                 {
                     array[i] = (int)IntMath.Divide((long)array2[i].magnitude2D * 1000L, (long)this.velocity);
                 }
                 else
                 {
                     long num8  = (long)this.velocity;
                     long num9  = (long)this.acceleration;
                     long num10 = (long)array2[i].magnitude2D;
                     long a3    = num8 * num8 + 2L * num9 * num10;
                     array[i] = (int)IntMath.Divide(((long)IntMath.Sqrt(a3) - num8) * 1000L, num9);
                 }
             }
             if (array[2] > array[1] && array[1] > array[0] && array[0] > 0)
             {
                 this.xControler.InitMotionControler(array[0], array[1], array[2], this.distanceZ0, this.distanceZ1, this.distanceX);
                 int desPostion = this.xControler.getDesPostion();
                 this.xDestPosition = this.xDirection;
                 this.xDestPosition.NormalizeTo(Math.Abs(desPostion));
                 if (desPostion < 0)
                 {
                     this.xDestPosition = -this.xDestPosition;
                 }
             }
             else
             {
                 this.bMoveOnXAxis = false;
             }
         }
     }
 }
示例#17
0
 public static VInt3 Cross(VInt3 lhs, VInt3 rhs)
 {
     return(new VInt3(IntMath.Divide((int)((lhs.y * rhs.z) - (lhs.z * rhs.y)), 0x3e8), IntMath.Divide((int)((lhs.z * rhs.x) - (lhs.x * rhs.z)), 0x3e8), IntMath.Divide((int)((lhs.x * rhs.y) - (lhs.y * rhs.x)), 0x3e8)));
 }
        public void ProcessInner(Action _action, Track _track, int delta)
        {
            if (this.MoveType == ActorMoveType.RotateBody)
            {
                int   num  = this.rotateBodyDegreeSpeed * delta / 1000;
                VInt3 vInt = this.moveActor.handle.forward.RotateY(-num);
                this.moveActor.handle.forward     = vInt;
                this.moveActor.handle.rotation    = Quaternion.LookRotation((Vector3)vInt);
                this.rotateBodyCurDirDegreeAngle += num;
                this.rotateBodyCurDirDegreeAngle %= 360;
                long    nom = (long)((float)this.rotateBodyCurDirDegreeAngle * 0.0174532924f * 1000f);
                VFactor f;
                VFactor f2;
                IntMath.sincos(out f, out f2, nom, 1000L);
                this.destPosition.x            = this.originateActor.handle.location.x + this.rotateBodyRadius * f2;
                this.destPosition.y            = this.rotateBodyHeight;
                this.destPosition.z            = this.originateActor.handle.location.z + this.rotateBodyRadius * f;
                this.moveDirection             = this.destPosition - this.moveActor.handle.location;
                this.lerpDirection             = this.moveDirection;
                this.moveActor.handle.location = this.destPosition;
            }
            else
            {
                VInt3 location = this.moveActor.handle.location;
                if (this.MoveType == ActorMoveType.Target && this.tarActor)
                {
                    this.destPosition = this.tarActor.handle.location;
                    if (this.tarActor && this.tarActor.handle.CharInfo != null)
                    {
                        CActorInfo charInfo = this.tarActor.handle.CharInfo;
                        this.hitHeight = charInfo.iBulletHeight;
                        VInt3 a = this.moveActor.handle.location - this.destPosition;
                        a.y = 0;
                        a   = a.NormalizeTo(1000);
                        this.destPosition += IntMath.Divide(a, (long)charInfo.iCollisionSize.x, 1000L);
                    }
                    this.destPosition.y = this.destPosition.y + this.hitHeight;
                }
                if (this.bMoveOnXAxis)
                {
                    this.moveDirection = this.destPosition - this.zCurPosition;
                }
                else
                {
                    this.moveDirection = this.destPosition - location;
                }
                this.lerpDirection = this.moveDirection;
                if (this.bMoveRotate && !this.bMoveOnXAxis)
                {
                    this.RotateMoveBullet(this.moveDirection);
                }
                int num2;
                if (!this.shouldUseAcceleration)
                {
                    num2 = this.velocity * delta / 1000;
                }
                else
                {
                    long num3 = (long)this.lastVelocity * (long)delta + (long)this.acceleration * (long)delta * (long)delta / 2L / 1000L;
                    num3 /= 1000L;
                    num2  = (int)num3;
                    this.lastVelocity += this.acceleration * delta / 1000;
                }
                if ((long)num2 * (long)num2 >= this.moveDirection.sqrMagnitudeLong2D && this.bReachDestStop)
                {
                    int magnitude2D = (this.destPosition - this.moveActor.handle.location).magnitude2D;
                    if (this.bMoveOnXAxis)
                    {
                        this.destPosition += this.xDestPosition;
                    }
                    this.moveActor.handle.location = this.destPosition;
                    this.stopCondtion = true;
                    if (this.moveActor.handle.TheActorMeta.ActorType == ActorTypeDef.Actor_Type_Bullet)
                    {
                        BulletWrapper bulletWrapper = this.moveActor.handle.ActorControl as BulletWrapper;
                        if (bulletWrapper != null && bulletWrapper.GetMoveCollisiong())
                        {
                            bulletWrapper.SetMoveDelta(magnitude2D);
                        }
                    }
                }
                else
                {
                    VInt3 vInt2;
                    if (this.gravity < 0)
                    {
                        this.moveDirection.y = 0;
                        vInt2    = location + this.moveDirection.NormalizeTo(num2);
                        vInt2.y += this.gravityControler.GetMotionDeltaDistance(delta);
                        VInt vInt3;
                        if (PathfindingUtility.GetGroundY(this.destPosition, out vInt3) && vInt2.y < vInt3.i)
                        {
                            vInt2.y = vInt3.i;
                        }
                    }
                    else
                    {
                        vInt2 = location + this.moveDirection.NormalizeTo(num2);
                    }
                    if (this.bMoveOnXAxis)
                    {
                        this.zCurPosition += this.moveDirection.NormalizeTo(num2);
                        int   motionDeltaDistance = this.xControler.GetMotionDeltaDistance(delta);
                        VInt3 vInt4 = this.xDirection;
                        vInt4.NormalizeTo(Math.Abs(motionDeltaDistance));
                        if (motionDeltaDistance < 0)
                        {
                            vInt4 = -vInt4;
                        }
                        vInt2 += vInt4;
                        if (this.bMoveRotate)
                        {
                            VInt3 dir = vInt2 - location;
                            this.RotateMoveBullet(dir);
                        }
                    }
                    if (this.moveActor.handle.TheActorMeta.ActorType == ActorTypeDef.Actor_Type_Bullet)
                    {
                        BulletWrapper bulletWrapper2 = this.moveActor.handle.ActorControl as BulletWrapper;
                        if (bulletWrapper2 != null && bulletWrapper2.GetMoveCollisiong())
                        {
                            bulletWrapper2.SetMoveDelta(num2);
                        }
                    }
                    this.moveActor.handle.location = vInt2;
                }
            }
            SkillUseContext refParamObject = _action.refParams.GetRefParamObject <SkillUseContext>("SkillContext");

            if (refParamObject != null)
            {
                refParamObject.EffectPos = this.moveActor.handle.location;
                refParamObject.EffectDir = this.moveDirection;
            }
        }
示例#19
0
 public static VInt3 Lerp(VInt3 a, VInt3 b, int factorNom, int factorDen)
 {
     return(new VInt3(IntMath.Divide((int)((b.x - a.x) * factorNom), factorDen) + a.x, IntMath.Divide((int)((b.y - a.y) * factorNom), factorDen) + a.y, IntMath.Divide((int)((b.z - a.z) * factorNom), factorDen) + a.z));
 }
示例#20
0
 public static VInt3 operator *(VInt3 v, VFactor f)
 {
     return(IntMath.Divide(v, f.nom, f.den));
 }
示例#21
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="node">所在node</param>
    /// <param name="edge">所沿着的边</param>
    /// <param name="srcLoc">from</param>
    /// <param name="destLoc">to</param>
    /// <param name="result">实际可到达的点</param>
    private static void MoveAlongEdge(NavMeshNode node, int edge, Int3 srcLoc, Int3 destLoc, out Int3 result, bool checkAnotherEdge = true)
    {
        bool flag;
        //DebugHelper.Assert((edge >= 0) && (edge <= 2));
        Int3 vertex = node.GetVertex(edge);
        Int3 num2   = node.GetVertex((edge + 1) % 3);
        Int3 a      = destLoc - srcLoc;

        a.y = 0;
        Int3 lhs = num2 - vertex;

        lhs.y = 0;
        lhs.NormalizeTo(1000);
        int num5 = 0;

        // 点乘移动向量和边向量
        num5 = (lhs.x * a.x) + (lhs.z * a.z);

        // 移动向量和边向量的交点
        Int3 rhs = Polygon.IntersectionPoint(ref vertex, ref num2, ref srcLoc, ref destLoc, out flag);

        // 不相交?
        if (!flag)
        {
            // 边和from to存在不共线,则不能移动
            if (!VectorMath.IsColinearXZ(vertex, num2, srcLoc) || !VectorMath.IsColinearXZ(vertex, num2, destLoc))
            {
                result = srcLoc;
                return;
            }

            // 计算本三角形内可移动到的点 rhs
            // 移动向量和边向量 同向
            if (num5 >= 0)
            {
                int num8 = (lhs.x * (num2.x - vertex.x)) + (lhs.z * (num2.z - vertex.z));
                int num9 = (lhs.x * (destLoc.x - vertex.x)) + (lhs.z * (destLoc.z - vertex.z));
                rhs = (num8 <= num9) ? num2 : destLoc;
                //DebugHelper.Assert((num8 >= 0) && (num9 >= 0));
            }
            else
            {
                // 移动向量和边向量 异向
                int num10 = (-lhs.x * (vertex.x - num2.x)) - (lhs.z * (vertex.z - num2.z));
                int num11 = (-lhs.x * (destLoc.x - num2.x)) - (lhs.z * (destLoc.z - num2.z));
                rhs = (Mathf.Abs(num10) <= Mathf.Abs(num11)) ? vertex : destLoc;
                //DebugHelper.Assert((num10 >= 0) && (num11 >= 0));
            }
        }

        // 计算交点到边的顶点的距离1000倍
        int num12 = -IntMath.Sqrt(vertex.XZSqrMagnitude(rhs) * 0xf4240L);        // 一百万
        int num13 = IntMath.Sqrt(num2.XZSqrMagnitude(rhs) * 0xf4240L);

        // num5是在边上的投影

        if ((num5 >= num12) && (num5 <= num13))
        {
            result = IntMath.Divide(lhs, (long)num5, 0xf4240L) + rhs;
            if (!node.ContainsPoint(result))
            {
                int     num16;
                int     num17;
                int     num18;
                int     num19;
                Vector3 vector = (Vector3)(num2 - vertex);
                vector.y = 0f;
                vector.Normalize();
                Int3 num14 = num2 - vertex;
                num14.y = 0;
                num14  *= 10000;
                long    magnitude = num14.magnitude;
                VFactor factor    = new VFactor();
                factor.nom = num5;
                factor.den = magnitude * 1000L;
                getMinMax(out num16, out num18, (long)num14.x, ref factor);
                getMinMax(out num17, out num19, (long)num14.z, ref factor);
                if (!MakePointInTriangle(ref result, node, num16, num18, num17, num19, srcLoc) && !MakePointInTriangle(ref result, node, num16 - 4, num18 + 4, num17 - 4, num19 + 4, srcLoc))
                {
                    result = srcLoc;
                }
            }
            if (MoveAxisY)
            {
                CalculateY(ref result, node);
            }
        }
        else
        {
            int  num20;
            int  num21;
            Int3 num22;
            int  num24;
            if (num5 < num12)
            {
                num20 = num5 - num12;
                num21 = (edge + 2) % 3;
                num22 = vertex;
            }
            else
            {
                num20 = num5 - num13;
                num21 = (edge + 1) % 3;
                num22 = num2;
            }
            Int3        num23          = (Int3)((lhs * num20) / 1000000f);
            NavMeshNode neighborByEdge = node.GetNeighborByEdge(num21, out num24);
            if (neighborByEdge != null)
            {
                checkedNodes.Add(node);
                MoveFromNode(neighborByEdge, num24, num22, num23 + num22, out result);
            }
            else
            {
                if (checkAnotherEdge)
                {
                    Int3 num27 = node.GetVertex((edge + 2) % 3) - num22;
                    if (Int3.Dot(num27.NormalizeTo(1000), num23) > 0)
                    {
                        checkedNodes.Add(node);
                        MoveAlongEdge(node, num21, num22, num23 + num22, out result, false);
                        return;
                    }
                }
                result = num22;
            }
        }
    }
示例#22
0
 public static VInt2 operator /(VInt2 v, VFactor f)
 {
     return(IntMath.Divide(v, f.den, f.nom));
 }
示例#23
0
 public static VInt2 Divide(VInt2 a, long m, long b)
 {
     a.x = (int)IntMath.Divide((long)a.x * m, b);
     a.y = (int)IntMath.Divide((long)a.y * m, b);
     return(a);
 }
示例#24
0
 public static int operator *(int i, VFactor f)
 {
     return((int)IntMath.Divide((long)i * f.nom, f.den));
 }
示例#25
0
    public static VInt3 Transform(ref VInt3 point, ref VInt3 axis_x, ref VInt3 axis_y, ref VInt3 axis_z, ref VInt3 trans, ref VInt3 scale)
    {
        long num  = (long)point.x * (long)scale.x;
        long num2 = (long)point.y * (long)scale.x;
        long num3 = (long)point.z * (long)scale.x;

        return(new VInt3((int)IntMath.Divide((long)axis_x.x * num + (long)axis_y.x * num2 + (long)axis_z.x * num3, 1000000L) + trans.x, (int)IntMath.Divide((long)axis_x.y * num + (long)axis_y.y * num2 + (long)axis_z.y * num3, 1000000L) + trans.y, (int)IntMath.Divide((long)axis_x.z * num + (long)axis_y.z * num2 + (long)axis_z.z * num3, 1000000L) + trans.z));
    }
示例#26
0
 public void Enter(Action _action)
 {
     this.skillContext = _action.refParams.GetRefParamObject <SkillUseContext>("SkillContext");
     this.lastTime     = 0;
     this.lastVelocity = (this.lastLerpVelocity = this.velocity);
     this.stopCondtion = false;
     this.moveActor    = _action.GetActorHandle(this.targetId);
     if (!this.moveActor)
     {
         return;
     }
     this.gravityControler = new AccelerateMotionControler();
     this.moveActor.get_handle().ObjLinker.AddCustomMoveLerp(new CustomMoveLerpFunc(this.ActionMoveLerp));
     if (this.MoveType == ActorMoveType.Target)
     {
         this.tarActor = _action.GetActorHandle(this.destId);
         if (!this.tarActor)
         {
             return;
         }
         this.destPosition = this.tarActor.get_handle().location;
         CActorInfo charInfo = this.tarActor.get_handle().CharInfo;
         if (charInfo != null)
         {
             this.hitHeight = charInfo.iBulletHeight;
             VInt3 vInt = this.moveActor.get_handle().location - this.destPosition;
             vInt.y             = 0;
             vInt               = vInt.NormalizeTo(1000);
             this.destPosition += IntMath.Divide(vInt, (long)charInfo.iCollisionSize.x, 1000L);
         }
         this.destPosition.y = this.destPosition.y + this.hitHeight;
     }
     else if (this.MoveType == ActorMoveType.Directional)
     {
         VInt3 vInt2 = VInt3.one;
         if (this.skillContext == null)
         {
             return;
         }
         PoolObjHandle <ActorRoot> originator = this.skillContext.Originator;
         if (!originator)
         {
             return;
         }
         if (this.bBulletUseDir)
         {
             _action.refParams.GetRefParam("_BulletUseDir", ref vInt2);
         }
         else if (this.bUseIndicatorDir)
         {
             SkillUseContext refParamObject = _action.refParams.GetRefParamObject <SkillUseContext>("SkillContext");
             VInt3           vInt3;
             if (refParamObject != null && refParamObject.CalcAttackerDir(out vInt3, originator))
             {
                 vInt2 = vInt3;
             }
             else
             {
                 vInt2 = originator.get_handle().forward;
             }
         }
         else
         {
             vInt2 = originator.get_handle().forward;
         }
         vInt2 = vInt2.RotateY(this.offsetDir.y);
         if (this.bResetMoveDistance)
         {
             int num = 0;
             _action.refParams.GetRefParam("_BulletRealFlyingTime", ref num);
             int num2 = num * this.velocity / 1000;
             this.distance = ((num2 <= 0) ? this.distance : num2);
         }
         this.destPosition   = this.moveActor.get_handle().location + vInt2.NormalizeTo(this.distance);
         this.destPosition.y = this.moveActor.get_handle().location.y;
     }
     else if (this.MoveType == ActorMoveType.Position)
     {
         if (this.bReachDestStop)
         {
             this.destPosition = this.targetPosition;
         }
         else
         {
             VInt3 vInt4 = this.targetPosition - this.moveActor.get_handle().location;
             vInt4.y           = 0;
             vInt4             = vInt4.NormalizeTo(1000);
             this.destPosition = this.moveActor.get_handle().location + vInt4 * (this.length * this.velocity / 1000);
             VInt vInt5;
             if (PathfindingUtility.GetGroundY(this.destPosition, out vInt5))
             {
                 this.destPosition.y = vInt5.i;
             }
         }
     }
     if (this.bAdjustSpeed)
     {
         VInt3 vInt6 = this.destPosition - this.moveActor.get_handle().location;
         int   num3  = this.length - 100;
         num3          = ((num3 > 0) ? num3 : this.length);
         this.velocity = (int)IntMath.Divide((long)vInt6.get_magnitude2D() * 1000L, (long)num3);
     }
     if (this.gravity < 0)
     {
         if (this.velocity == 0)
         {
             this.stopCondtion = true;
             return;
         }
         VInt3 vInt7 = this.destPosition - this.moveActor.get_handle().location;
         int   num4;
         if (!this.shouldUseAcceleration)
         {
             num4 = (int)IntMath.Divide((long)vInt7.get_magnitude2D() * 1000L, (long)this.velocity);
         }
         else
         {
             long num5 = (long)this.velocity;
             long num6 = (long)this.acceleration;
             long num7 = (long)vInt7.get_magnitude2D();
             long num8 = num5 * num5 + 2L * num6 * num7;
             num4 = (int)IntMath.Divide(((long)IntMath.Sqrt(num8) - num5) * 1000L, num6);
             this.lastVelocity = (this.lastLerpVelocity = this.velocity);
         }
         if (num4 == 0)
         {
             this.stopCondtion = true;
             return;
         }
         VInt vInt8;
         if (PathfindingUtility.GetGroundY(this.destPosition, out vInt8))
         {
             this.gravityControler.InitMotionControler(num4, vInt8.i - this.moveActor.get_handle().location.y, this.gravity);
         }
         else
         {
             this.gravityControler.InitMotionControler(num4, 0, this.gravity);
         }
     }
 }
示例#27
0
 public static long Lerp(long src, long dest, long nom, long den)
 {
     return(IntMath.Divide(src * den + (dest - src) * nom, den));
 }
示例#28
0
        public void ProcessInner(Action _action, Track _track, int delta)
        {
            VInt3 location = this.moveActor.get_handle().location;

            if (this.MoveType == ActorMoveType.Target && this.tarActor)
            {
                this.destPosition = this.tarActor.get_handle().location;
                if (this.tarActor && this.tarActor.get_handle().CharInfo != null)
                {
                    CActorInfo charInfo = this.tarActor.get_handle().CharInfo;
                    this.hitHeight = charInfo.iBulletHeight;
                    VInt3 vInt = this.moveActor.get_handle().location - this.destPosition;
                    vInt.y             = 0;
                    vInt               = vInt.NormalizeTo(1000);
                    this.destPosition += IntMath.Divide(vInt, (long)charInfo.iCollisionSize.x, 1000L);
                }
                this.destPosition.y = this.destPosition.y + this.hitHeight;
            }
            this.moveDirection = this.destPosition - location;
            this.lerpDirection = this.moveDirection;
            if (this.bMoveRotate)
            {
                this.RotateMoveBullet(this.moveDirection);
            }
            int num;

            if (!this.shouldUseAcceleration)
            {
                num = this.velocity * delta / 1000;
            }
            else
            {
                long num2 = (long)this.lastVelocity * (long)delta + (long)this.acceleration * (long)delta * (long)delta / 2L / 1000L;
                num2 /= 1000L;
                num   = (int)num2;
                this.lastVelocity += this.acceleration * delta / 1000;
            }
            if ((long)num * (long)num >= this.moveDirection.get_sqrMagnitudeLong2D() && this.bReachDestStop)
            {
                int magnitude2D = (this.destPosition - this.moveActor.get_handle().location).get_magnitude2D();
                this.moveActor.get_handle().location = this.destPosition;
                this.stopCondtion = true;
                if (this.moveActor.get_handle().TheActorMeta.ActorType == ActorTypeDef.Actor_Type_Bullet)
                {
                    BulletWrapper bulletWrapper = this.moveActor.get_handle().ActorControl as BulletWrapper;
                    if (bulletWrapper != null && bulletWrapper.GetMoveCollisiong())
                    {
                        bulletWrapper.SetMoveDelta(magnitude2D);
                    }
                }
            }
            else
            {
                VInt3 location2;
                if (this.gravity < 0)
                {
                    this.moveDirection.y = 0;
                    location2            = location + this.moveDirection.NormalizeTo(num);
                    location2.y         += this.gravityControler.GetMotionDeltaDistance(delta);
                    VInt vInt2;
                    if (PathfindingUtility.GetGroundY(this.destPosition, out vInt2) && location2.y < vInt2.i)
                    {
                        location2.y = vInt2.i;
                    }
                }
                else
                {
                    location2 = location + this.moveDirection.NormalizeTo(num);
                }
                if (this.moveActor.get_handle().TheActorMeta.ActorType == ActorTypeDef.Actor_Type_Bullet)
                {
                    BulletWrapper bulletWrapper2 = this.moveActor.get_handle().ActorControl as BulletWrapper;
                    if (bulletWrapper2 != null && bulletWrapper2.GetMoveCollisiong())
                    {
                        bulletWrapper2.SetMoveDelta(num);
                    }
                }
                this.moveActor.get_handle().location = location2;
            }
            SkillUseContext refParamObject = _action.refParams.GetRefParamObject <SkillUseContext>("SkillContext");

            if (refParamObject != null)
            {
                refParamObject.EffectPos = this.moveActor.get_handle().location;
                refParamObject.EffectDir = this.moveDirection;
            }
        }
示例#29
0
 public static Int2 Divide(Int2 a, long b)
 {
     a.x = (int)IntMath.Divide((long)a.x, b);
     a.y = (int)IntMath.Divide((long)a.y, b);
     return(a);
 }
示例#30
0
        public override int GetMotionDistance(int _allTime)
        {
            long a = ((base.motionSpeed * _allTime) << 1) + (this.accelerateSpeed * (_allTime * _allTime));

            return((int)IntMath.Divide(a, 0x7d0L));
        }