#
Junjie
2025-01-12 5ad25a2233c76a5da8077a6862d5ddc3f94f5ad6
src/main/java/com/zy/common/model/NavigateNode.java
@@ -2,11 +2,13 @@
import lombok.Data;
import java.io.Serializable;
/**
 * A*寻路算法Node节点
 */
@Data
public class NavigateNode implements Comparable<NavigateNode>{
public class NavigateNode implements Comparable<NavigateNode>, Cloneable, Serializable {
    private int x;//坐标x
    private int y;//坐标y
@@ -30,7 +32,7 @@
        this.Father = father;
        if (this.Father != null) {
            //走过的步数等于父节点走过的步数加一
            this.G = father.G + 1;
            this.G = father.G + this.G;
        } else { //父节点为空代表它是第一个结点
            this.G = 0;
        }
@@ -46,4 +48,14 @@
        return Integer.compare(this.F, o.F);
    }
    @Override
    public NavigateNode clone() {
        try {
            return (NavigateNode) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return null;
    }
}