#
luxiaotao1123
2024-12-30 3209b7899f99fbc567c24be9709ba289f33ea73b
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/astart/NavigateNode.java
@@ -3,6 +3,7 @@
import lombok.Data;
import java.io.Serializable;
import java.util.Objects;
import java.util.Optional;
/**
@@ -26,6 +27,7 @@
    private String direction;   //行走方向
    private Integer lastDistance;   // 距离上个节点距离
    private Integer moveDistance;   // 总行走距离
    private Integer weight;        // G 权重
    private String codeData;
@@ -46,7 +48,9 @@
        this.parent = father;
        if (this.parent != null) {
            //走过的步数等于父节点走过的步数加一
            this.G = father.G + Optional.ofNullable(this.lastDistance).orElse(0);
            this.G = father.G
                    + Optional.ofNullable(this.lastDistance).orElse(0)
                    + Optional.ofNullable(this.weight).orElse(0);
        } else { //父节点为空代表它是第一个结点
            this.G = 0;
        }
@@ -71,4 +75,31 @@
        }
        return null;
    }
    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (!(obj instanceof NavigateNode)) return false;
        NavigateNode that = (NavigateNode) obj;
        return this.x == that.x && this.y == that.y;
    }
    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
    public void reset() {
        this.F = 0;
        this.G = 0;
        this.H = 0;
        this.parent = null;
        this.turningPoint = null;
        this.direction = null;
        this.lastDistance = null;
        this.moveDistance = null;
        this.weight = null;
        this.codeData = null;
    }
}