Esempio n. 1
0
    public static bool ValidateTarget(VInt3 loc, VInt3 target, out VInt3 newTarget, out int nodeIndex)
    {
        newTarget = target;
        nodeIndex = -1;
        if (AstarPath.active == null)
        {
            return(false);
        }
        AstarData astarData = AstarPath.active.astarData;

        if (astarData.GetLocatedByRasterizer(target) == null)
        {
            int edge = -1;
            TriangleMeshNode node2 = astarData.IntersectByRasterizer(target, loc, out edge);
            if (node2 == null)
            {
                return(false);
            }
            VInt3[] numArray = _staticVerts;
            node2.GetPoints(out numArray[0], out numArray[1], out numArray[2]);
            bool  intersects = false;
            VInt3 num2       = Polygon.IntersectionPoint(ref target, ref loc, ref numArray[edge], ref numArray[(edge + 1) % 3], out intersects);
            if (!intersects)
            {
                return(false);
            }
            newTarget = num2;
        }
        return(true);
    }
Esempio n. 2
0
    private static VInt3 InternalMove(VInt3 srcLoc, VInt3 delta, ref VInt groundY, ActorRoot actor, MoveDirectionState state = null)
    {
        VInt3 num4;

        if (AstarPath.active == null)
        {
            return(VInt3.zero);
        }
        if ((delta.x == 0) && (delta.z == 0))
        {
            return(delta);
        }
        VInt3            end                 = srcLoc + delta;
        int              edge                = -1;
        int              actorCamp           = (int)actor.TheActorMeta.ActorCamp;
        AstarData        data                = AstarPath.active.GetData(actorCamp);
        TriangleMeshNode locatedByRasterizer = data.GetLocatedByRasterizer(srcLoc);

        if (locatedByRasterizer == null)
        {
            TriangleMeshNode node2 = data.IntersectByRasterizer(srcLoc, end, out edge);
            if (node2 == null)
            {
                return(VInt3.zero);
            }
            locatedByRasterizer = node2;
        }
        if (state != null)
        {
            state.BeginMove();
            MoveFromNode(locatedByRasterizer, edge, srcLoc, end, state, out num4);
            state.EndMove();
        }
        else
        {
            MoveFromNode(locatedByRasterizer, edge, srcLoc, end, null, out num4);
        }
        checkedNodes.Clear();
        groundY = num4.y;
        if (!MoveAxisY)
        {
            num4.y = srcLoc.y;
        }
        return(num4 - srcLoc);
    }
    private static VInt3 InternalMove(VInt3 srcLoc, VInt3 delta, ref VInt groundY, ActorRoot actor, MoveDirectionState state = null)
    {
        if (!AstarPath.active)
        {
            return(VInt3.zero);
        }
        if (delta.x == 0 && delta.z == 0)
        {
            return(delta);
        }
        VInt3            vInt             = srcLoc + delta;
        int              startEdge        = -1;
        int              actorCamp        = (int)actor.TheActorMeta.ActorCamp;
        AstarData        data             = AstarPath.active.GetData(actorCamp);
        TriangleMeshNode triangleMeshNode = data.GetLocatedByRasterizer(srcLoc);

        if (triangleMeshNode == null)
        {
            TriangleMeshNode triangleMeshNode2 = data.IntersectByRasterizer(srcLoc, vInt, out startEdge);
            if (triangleMeshNode2 == null)
            {
                return(VInt3.zero);
            }
            triangleMeshNode = triangleMeshNode2;
        }
        VInt3 lhs;

        if (state != null)
        {
            state.BeginMove();
            PathfindingUtility.MoveFromNode(triangleMeshNode, startEdge, srcLoc, vInt, state, out lhs);
            state.EndMove();
        }
        else
        {
            PathfindingUtility.MoveFromNode(triangleMeshNode, startEdge, srcLoc, vInt, null, out lhs);
        }
        PathfindingUtility.checkedNodes.Clear();
        groundY = lhs.y;
        if (!PathfindingUtility.MoveAxisY)
        {
            lhs.y = srcLoc.y;
        }
        return(lhs - srcLoc);
    }
    private static Int3 InternalMove(Int3 srcLoc, Int3 delta, ref Int1 groundY, Actor actor)
    {
        if (!AstarPath.active)
        {
            return(Int3.zero);
        }

        //if (delta.x == 0 && delta.z == 0)
        //{
        //  return delta;
        //}

        Int3             vInt             = srcLoc + delta;
        int              startEdge        = -1;
        int              actorCamp        = (int)actor.CampId;
        AstarData        data             = AstarPath.active.astarData;
        TriangleMeshNode triangleMeshNode = data.GetLocatedByRasterizer(srcLoc);

        if (triangleMeshNode == null)
        {
            TriangleMeshNode triangleMeshNode2 = data.IntersectByRasterizer(srcLoc, vInt, out startEdge);
            if (triangleMeshNode2 == null)
            {
                return(Int3.zero);
            }
            triangleMeshNode = triangleMeshNode2;
        }
        Int3 lhs;

        PathfindingUtility.MoveFromNode(triangleMeshNode, startEdge, srcLoc, vInt, out lhs);

        PathfindingUtility.checkedNodes.Clear();
        groundY = lhs.y;
        if (!PathfindingUtility.MoveAxisY)
        {
            lhs.y = srcLoc.y;
        }
        return(lhs - srcLoc);
    }
    public static bool ValidateTarget(VInt3 loc, VInt3 target, out VInt3 newTarget, out int nodeIndex)
    {
        newTarget = target;
        nodeIndex = -1;
        if (!AstarPath.active)
        {
            return(false);
        }
        AstarData        astarData           = AstarPath.active.astarData;
        TriangleMeshNode locatedByRasterizer = astarData.GetLocatedByRasterizer(target);

        if (locatedByRasterizer != null)
        {
            return(true);
        }
        int num = -1;
        TriangleMeshNode triangleMeshNode = astarData.IntersectByRasterizer(target, loc, out num);

        if (triangleMeshNode == null)
        {
            return(false);
        }
        VInt3[] staticVerts = PathfindingUtility._staticVerts;
        triangleMeshNode.GetPoints(out staticVerts[0], out staticVerts[1], out staticVerts[2]);
        bool  flag = false;
        VInt3 vInt = Polygon.IntersectionPoint(ref target, ref loc, ref staticVerts[num], ref staticVerts[(num + 1) % 3], out flag);

        if (!flag)
        {
            return(false);
        }
        if (!PathfindingUtility.MakePointInTriangle(ref vInt, triangleMeshNode, -4, 4, -4, 4, VInt3.zero))
        {
            return(false);
        }
        newTarget = vInt;
        return(true);
    }