1 package cz.cuni.amis.pogamut.defcon.utils.quadtree;
2
3 import java.util.logging.Logger;
4
5 import cz.cuni.amis.pogamut.defcon.communication.worldview.DefConWorldView;
6
7
8
9
10
11
12
13 public class BuildingPlacementQuadTreeLabellingMethod implements
14 IQuadTreeLabelingMethod {
15
16 private DefConWorldView worldview;
17 private Logger log;
18
19 public BuildingPlacementQuadTreeLabellingMethod(DefConWorldView worldview,
20 Logger log) {
21 this.worldview = worldview;
22 this.log = log;
23 }
24
25
26
27
28
29 @Override
30 public boolean label(QuadTreeNode node) {
31
32 if (node.isLabeled()) {
33 if (node.getNodes() != null &&
34 (node.getFirst().isLabeled() ||
35 node.getSecond().isLabeled() ||
36 node.getThird().isLabeled() ||
37 node.getFourth().isLabeled())) {
38 return true;
39 }
40
41 node.setLabel(false);
42
43 return false;
44 }
45
46 boolean b = node.getNodes() == null && worldview.getGameInfo()
47 .isValidBuildingPlacementLocation(
48 node.getCenter().getX(),
49 node.getCenter().getY());
50
51 return b;
52
53 }
54 }