public ResearchNode copy() { ResearchNode copy = new ResearchNode(name, defaultState); copy.dependencies.addAll(dependencies); copy.dependants.addAll(dependants); copy.mapName = mapName; copy.locked = false; return copy; }
public final void addDependency(ResearchNode node) { if (locked) { throw new IllegalStateException("Node " + name + " is locked, cannot add new dependencies"); } dependencies.add(node.getName()); node.addDependant(this); }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof ResearchNode)) { return false; } ResearchNode node = (ResearchNode) o; return (name.equals(node.getName()) && mapName.equals(node.mapName)); }
private void addDependant(ResearchNode node) { if (locked) { throw new IllegalStateException("Node " + name + " is locked, cannot add new dependants"); } dependants.add(node.getName()); }
public final boolean dependsOn(ResearchNode node) { return dependencies.contains(node.getName()) && Objects.equals(node.mapName, mapName); }