MCPcopy Create free account
hub / github.com/SimHacker/micropolis / Bulldozer

Class Bulldozer

micropolis-java/src/micropolisj/engine/Bulldozer.java:13–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11import static micropolisj.engine.TileConstants.*;
12
13class Bulldozer extends ToolStroke
14{
15 Bulldozer(Micropolis city, int xpos, int ypos)
16 {
17 super(city, MicropolisTool.BULLDOZER, xpos, ypos);
18 }
19
20 @Override
21 protected void applyArea(ToolEffectIfc eff)
22 {
23 CityRect b = getBounds();
24
25 // scan selection area for rubble, forest, etc...
26 for (int y = 0; y < b.height; y++) {
27 for (int x = 0; x < b.width; x++) {
28
29 ToolEffectIfc subEff = new TranslatedToolEffect(eff, b.x+x, b.y+y);
30 if (city.isTileDozeable(subEff)) {
31
32 dozeField(subEff);
33 }
34
35 }
36 }
37
38 // scan selection area for zones...
39 for (int y = 0; y < b.height; y++) {
40 for (int x = 0; x < b.width; x++) {
41
42 if (isZoneCenter(eff.getTile(b.x+x,b.y+y))) {
43 dozeZone(new TranslatedToolEffect(eff, b.x+x, b.y+y));
44 }
45 }
46 }
47 }
48
49 void dozeZone(ToolEffectIfc eff)
50 {
51 int currTile = eff.getTile(0, 0);
52
53 // zone center bit is set
54 assert isZoneCenter(currTile);
55
56 CityDimension dim = getZoneSizeFor(currTile);
57 assert dim != null;
58 assert dim.width >= 3;
59 assert dim.height >= 3;
60
61 eff.spend(1);
62
63 // make explosion sound;
64 // bigger zones => bigger explosions
65
66 if (dim.width * dim.height < 16) {
67 eff.makeSound(0, 0, Sound.EXPLOSION_HIGH);
68 }
69 else if (dim.width * dim.height < 36) {
70 eff.makeSound(0, 0, Sound.EXPLOSION_LOW);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected