behaviors: define a new class TileBehavior to be a base class
this will be a base class of all tile-behavior classes git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@868 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
parent
6bd61e6575
commit
f3ca16a672
1 changed files with 39 additions and 0 deletions
39
src/micropolisj/engine/TileBehavior.java
Normal file
39
src/micropolisj/engine/TileBehavior.java
Normal file
|
@ -0,0 +1,39 @@
|
|||
// This file is part of MicropolisJ.
|
||||
// Copyright (C) 2013 Jason Long
|
||||
// Portions Copyright (C) 1989-2007 Electronic Arts Inc.
|
||||
//
|
||||
// MicropolisJ is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU GPLv3, with additional terms.
|
||||
// See the README file, included in this distribution, for details.
|
||||
|
||||
package micropolisj.engine;
|
||||
|
||||
import java.util.Random;
|
||||
import static micropolisj.engine.TileConstants.*;
|
||||
|
||||
public abstract class TileBehavior
|
||||
{
|
||||
protected final Micropolis city;
|
||||
protected final Random PRNG;
|
||||
int xpos;
|
||||
int ypos;
|
||||
int tile;
|
||||
int rawTile;
|
||||
|
||||
protected TileBehavior(Micropolis city)
|
||||
{
|
||||
this.city = city;
|
||||
this.PRNG = city.PRNG;
|
||||
}
|
||||
|
||||
public final void processTile(int xpos, int ypos)
|
||||
{
|
||||
this.xpos = xpos;
|
||||
this.ypos = ypos;
|
||||
this.rawTile = city.getTile(xpos, ypos);
|
||||
this.tile = rawTile & LOMASK;
|
||||
apply();
|
||||
}
|
||||
|
||||
public abstract void apply();
|
||||
}
|
Reference in a new issue