代写代考 package dungeonmania.map;

package dungeonmania.map;

import java.util.ArrayList;
import java.util.List;

Copyright By PowCoder代写 加微信 powcoder

import dungeonmania.entities.Entity;
import dungeonmania.util.Position;

public class GraphNode {
private Position position;
private List entities = new ArrayList<>();

private int weight = 1;

public GraphNode(Entity entity, int weight) {
this(entity, entity.getPosition(), weight);

public GraphNode(Entity entity) {
this(entity, entity.getPosition(), 1);

public GraphNode(Entity entity, Position p, int weight) {
this.position = p;
this.entities.add(entity);
this.weight = weight;

public boolean canMoveOnto(GameMap map, Entity entity) {
return entities.size() == 0 || entities.stream().allMatch(e -> e.canMoveOnto(map, entity));

public int getWeight() {
return weight;

public void addEntity(Entity entity) {
if (!this.entities.contains(entity))
this.entities.add(entity);

public void removeEntity(Entity entity) {
entities.remove(entity);

public int size() {
return entities.size();

public void mergeNode(GraphNode node) {
List es = node.entities;
es.forEach(this::addEntity);

public List getEntities() {
return entities;

public Position getPosition() {
return position;

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com