javadocs: document methods in the MapScanner class
git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@542 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
parent
082d752c21
commit
feb04ae09a
1 changed files with 74 additions and 0 deletions
|
@ -14,6 +14,11 @@ import static micropolisj.engine.TileConstants.*;
|
||||||
import static micropolisj.engine.Micropolis.ZoneType;
|
import static micropolisj.engine.Micropolis.ZoneType;
|
||||||
import static micropolisj.engine.Animate.Smoke;
|
import static micropolisj.engine.Animate.Smoke;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process individual tiles of the map for each cycle.
|
||||||
|
* In each sim cycle each tile will get activated, and this
|
||||||
|
* class contains the activation code.
|
||||||
|
*/
|
||||||
class MapScanner
|
class MapScanner
|
||||||
{
|
{
|
||||||
final Micropolis city;
|
final Micropolis city;
|
||||||
|
@ -29,6 +34,9 @@ class MapScanner
|
||||||
this.PRNG = city.PRNG;
|
this.PRNG = city.PRNG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activate the tile identified by xpos and ypos properties.
|
||||||
|
*/
|
||||||
public void scanTile()
|
public void scanTile()
|
||||||
{
|
{
|
||||||
cchr9 = (char) (cchr & LOMASK);
|
cchr9 = (char) (cchr & LOMASK);
|
||||||
|
@ -90,6 +98,9 @@ class MapScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the current tile is a radioactive tile.
|
||||||
|
*/
|
||||||
void doRadioactiveTile()
|
void doRadioactiveTile()
|
||||||
{
|
{
|
||||||
if (PRNG.nextInt(4096) == 0)
|
if (PRNG.nextInt(4096) == 0)
|
||||||
|
@ -100,6 +111,10 @@ class MapScanner
|
||||||
}
|
}
|
||||||
|
|
||||||
static int [] TRAFFIC_DENSITY_TAB = { ROADBASE, LTRFBASE, HTRFBASE };
|
static int [] TRAFFIC_DENSITY_TAB = { ROADBASE, LTRFBASE, HTRFBASE };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the current tile is a road tile.
|
||||||
|
*/
|
||||||
void doRoad()
|
void doRoad()
|
||||||
{
|
{
|
||||||
city.roadTotal++;
|
city.roadTotal++;
|
||||||
|
@ -158,6 +173,9 @@ class MapScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the current tile is an active fire.
|
||||||
|
*/
|
||||||
void doFire()
|
void doFire()
|
||||||
{
|
{
|
||||||
final int [] DX = { 0, 1, 0, -1 };
|
final int [] DX = { 0, 1, 0, -1 };
|
||||||
|
@ -195,6 +213,9 @@ class MapScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the current tile is a flooding tile.
|
||||||
|
*/
|
||||||
void doFlood()
|
void doFlood()
|
||||||
{
|
{
|
||||||
final int [] DX = { 0, 1, 0, -1 };
|
final int [] DX = { 0, 1, 0, -1 };
|
||||||
|
@ -229,6 +250,9 @@ class MapScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the current tile is railroad.
|
||||||
|
*/
|
||||||
void doRail()
|
void doRail()
|
||||||
{
|
{
|
||||||
city.railTotal++;
|
city.railTotal++;
|
||||||
|
@ -249,6 +273,9 @@ class MapScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the current tile is a road bridge over water.
|
||||||
|
*/
|
||||||
boolean doBridge()
|
boolean doBridge()
|
||||||
{
|
{
|
||||||
final int HDx[] = { -2, 2, -2, -1, 0, 1, 2 };
|
final int HDx[] = { -2, 2, -2, -1, 0, 1, 2 };
|
||||||
|
@ -330,6 +357,9 @@ class MapScanner
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function for doBridge- it toggles the draw-bridge.
|
||||||
|
*/
|
||||||
private void applyBridgeChange(int [] Dx, int [] Dy, char [] fromTab, char [] toTab)
|
private void applyBridgeChange(int [] Dx, int [] Dy, char [] fromTab, char [] toTab)
|
||||||
{
|
{
|
||||||
for (int z = 0; z < 7; z++) {
|
for (int z = 0; z < 7; z++) {
|
||||||
|
@ -345,6 +375,10 @@ class MapScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate how far away the boat currently is from the
|
||||||
|
* current tile.
|
||||||
|
*/
|
||||||
int getBoatDis()
|
int getBoatDis()
|
||||||
{
|
{
|
||||||
int dist = 99999;
|
int dist = 99999;
|
||||||
|
@ -361,6 +395,9 @@ class MapScanner
|
||||||
return dist;
|
return dist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the current tile is the key tile of an airport.
|
||||||
|
*/
|
||||||
void doAirport()
|
void doAirport()
|
||||||
{
|
{
|
||||||
if (PRNG.nextInt(6) == 0) {
|
if (PRNG.nextInt(6) == 0) {
|
||||||
|
@ -372,6 +409,9 @@ class MapScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the current tile is the key tile of any zone.
|
||||||
|
*/
|
||||||
void doZone()
|
void doZone()
|
||||||
{
|
{
|
||||||
// set power bit in map, from powermap
|
// set power bit in map, from powermap
|
||||||
|
@ -435,6 +475,9 @@ class MapScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Place a 3x3 zone on to the map.
|
||||||
|
*/
|
||||||
boolean zonePlop(int xpos, int ypos, int base)
|
boolean zonePlop(int xpos, int ypos, int base)
|
||||||
{
|
{
|
||||||
if (!city.testBounds(xpos-1, ypos-1))
|
if (!city.testBounds(xpos-1, ypos-1))
|
||||||
|
@ -465,6 +508,10 @@ class MapScanner
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the current tile is the key tile of a "special" zone.
|
||||||
|
* @param powerOn indicates whether the building has power
|
||||||
|
*/
|
||||||
void doSpecialZone(boolean powerOn)
|
void doSpecialZone(boolean powerOn)
|
||||||
{
|
{
|
||||||
switch (cchr9)
|
switch (cchr9)
|
||||||
|
@ -605,6 +652,9 @@ class MapScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Place hospital or church if needed.
|
||||||
|
*/
|
||||||
void makeHospital()
|
void makeHospital()
|
||||||
{
|
{
|
||||||
if (city.needHospital > 0)
|
if (city.needHospital > 0)
|
||||||
|
@ -620,6 +670,11 @@ class MapScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the current tile is the key tile of a
|
||||||
|
* hospital or church.
|
||||||
|
* @param powerOn indicates whether the building has power
|
||||||
|
*/
|
||||||
void doHospitalChurch(boolean powerOn)
|
void doHospitalChurch(boolean powerOn)
|
||||||
{
|
{
|
||||||
if (cchr9 == HOSPITAL)
|
if (cchr9 == HOSPITAL)
|
||||||
|
@ -690,6 +745,11 @@ class MapScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the current tile is the key tile of a commercial
|
||||||
|
* zone.
|
||||||
|
* @param powerOn indicates whether the building has power
|
||||||
|
*/
|
||||||
void doCommercial(boolean powerOn)
|
void doCommercial(boolean powerOn)
|
||||||
{
|
{
|
||||||
city.comZoneCount++;
|
city.comZoneCount++;
|
||||||
|
@ -739,6 +799,9 @@ class MapScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @param powerOn indicates whether the building has power
|
||||||
|
*/
|
||||||
void setSmoke(int xpos, int ypos, boolean powerOn)
|
void setSmoke(int xpos, int ypos, boolean powerOn)
|
||||||
{
|
{
|
||||||
int cchr9 = city.map[ypos][xpos] & LOMASK;
|
int cchr9 = city.map[ypos][xpos] & LOMASK;
|
||||||
|
@ -788,6 +851,11 @@ class MapScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the current tile is the key tile of an
|
||||||
|
* industrial zone.
|
||||||
|
* @param powerOn indicates whether the building has power
|
||||||
|
*/
|
||||||
void doIndustrial(boolean powerOn)
|
void doIndustrial(boolean powerOn)
|
||||||
{
|
{
|
||||||
city.indZoneCount++;
|
city.indZoneCount++;
|
||||||
|
@ -836,6 +904,11 @@ class MapScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the current tile is the key tile of a
|
||||||
|
* residential zone.
|
||||||
|
* @param powerOn indicates whether the building has power
|
||||||
|
*/
|
||||||
void doResidential(boolean powerOn)
|
void doResidential(boolean powerOn)
|
||||||
{
|
{
|
||||||
city.resZoneCount++;
|
city.resZoneCount++;
|
||||||
|
@ -1214,6 +1287,7 @@ class MapScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO- rename to adjustROG
|
||||||
void incrementROG(int xpos, int ypos, int amount)
|
void incrementROG(int xpos, int ypos, int amount)
|
||||||
{
|
{
|
||||||
city.rateOGMem[ypos/8][xpos/8] += 4*amount;
|
city.rateOGMem[ypos/8][xpos/8] += 4*amount;
|
||||||
|
|
Reference in a new issue