Пример #1
0
        public override void Prepare()
        {
            VInt3     num;
            AstarData targetAstarData = this.targetAstarData;

            this.startNode = targetAstarData.GetNearestByRasterizer(this.startPoint, out num);
            if (this.startNode != null)
            {
                this.startPoint = num;
            }
            if (this.hasEndPoint)
            {
                this.endNode = targetAstarData.GetNearestByRasterizer(this.endPoint, out num);
                if (this.endNode != null)
                {
                    this.endPoint = num;
                }
                base.hTarget     = this.endPoint;
                base.hTargetNode = this.endNode;
            }
            if (((this.startNode == null) && this.hasEndPoint) && (this.endNode == null))
            {
                base.Error();
                base.LogError("Couldn't find close nodes to the start point or the end point");
            }
            else if (this.startNode == null)
            {
                base.Error();
                base.LogError("Couldn't find a close node to the start point");
            }
            else if ((this.endNode == null) && this.hasEndPoint)
            {
                base.Error();
                base.LogError("Couldn't find a close node to the end point");
            }
            else if (!this.startNode.Walkable)
            {
                base.Error();
                base.LogError("The node closest to the start point is not walkable");
            }
            else if (this.hasEndPoint && !this.endNode.Walkable)
            {
                base.Error();
                base.LogError("The node closest to the end point is not walkable");
            }
            else if (this.hasEndPoint && (this.startNode.Area != this.endNode.Area))
            {
                base.Error();
                base.LogError(string.Concat(new object[] { "There is no valid path to the target (start area: ", this.startNode.Area, ", target area: ", this.endNode.Area, ")" }));
            }
        }
Пример #2
0
        public override void Prepare()
        {
            AstarData targetAstarData = this.targetAstarData;
            Int3      vInt;

            this.startNode = targetAstarData.GetNearestByRasterizer(this.startPoint, out vInt);
            if (this.startNode != null)
            {
                this.startPoint = vInt;
            }
            if (this.hasEndPoint)
            {
                this.endNode = targetAstarData.GetNearestByRasterizer(this.endPoint, out vInt);
                if (this.endNode != null)
                {
                    this.endPoint = vInt;
                }
                this.hTarget     = this.endPoint;
                this.hTargetNode = this.endNode;
            }
            if (this.startNode == null && this.hasEndPoint && this.endNode == null)
            {
                base.Error();
                Logger.err("Couldn't find close nodes to the start point or the end point");
                return;
            }
            if (this.startNode == null)
            {
                base.Error();
                Logger.err("Couldn't find a close node to the start point");
                return;
            }
            if (this.endNode == null && this.hasEndPoint)
            {
                base.Error();
                Logger.err("Couldn't find a close node to the end point");
                return;
            }
            if (!this.startNode.Walkable)
            {
                base.Error();
                Logger.err("The node closest to the start point is not walkable");
                return;
            }
            if (this.hasEndPoint && !this.endNode.Walkable)
            {
                base.Error();
                Logger.err("The node closest to the end point is not walkable");
                return;
            }
            if (this.hasEndPoint && this.startNode.Area != this.endNode.Area)
            {
                base.Error();
                Logger.err(string.Concat(new object[]
                {
                    "There is no valid path to the target (start area: ",
                    this.startNode.Area,
                    ", target area: ",
                    this.endNode.Area,
                    ")"
                }));
                return;
            }
        }