some minor edit in tiles

This commit is contained in:
Ondřej Hruška
2014-04-19 03:57:42 +02:00
parent b18b248762
commit d18ff99fa8
5 changed files with 39 additions and 6 deletions
+2 -1
View File
@@ -46,7 +46,8 @@ public abstract class EntityModel<D, R extends RectBound> {
/**
* Create a data object and populate it with default values.
* Create a data object and populate it with default values.<br>
* It's allowed to return null for no data.
*
* @return data object
*/
+28
View File
@@ -14,6 +14,9 @@ public final class Tile extends Entity<TileData, TileModel, TileRenderContext> {
public static final short ION_MARK = 700;
/** Whether the tile is occupied by an entity */
private transient boolean occupied;
public Tile() {
super();
@@ -87,4 +90,29 @@ public final class Tile extends Entity<TileData, TileModel, TileRenderContext> {
{
return model.isWalkable(data);
}
public boolean hasItem()
{
return !data.items.isEmpty();
}
public Item removeItem()
{
if(!hasItem()) return null;
return data.items.pop();
}
public boolean isOccupied()
{
return occupied;
}
public void setOccupied(boolean occupied)
{
this.occupied = occupied;
}
}
@@ -16,7 +16,4 @@ public abstract class TileData {
/** Items dropped onto this tile */
public final Stack<Item> items = new Stack<>();
/** Whether the tile is occupied by an entity */
public boolean occupied;
}
@@ -12,6 +12,12 @@ public abstract class TileModel extends EntityModel<TileData, TileRenderContext>
Tiles.register(id, this);
}
@Override
public TileData createData()
{
return null;
}
/**
* Test if this tile type is potentially walkable. Used during world
+3 -2
View File
@@ -1,6 +1,7 @@
package mightypork.util.math.color;
import java.util.EmptyStackException;
import java.util.Stack;
import mightypork.util.annotations.FactoryMethod;
@@ -216,7 +217,7 @@ public abstract class Color {
* Remove a pushed alpha multiplier from the stack. If there's no remaining
* multiplier on the stack, an exception is raised.
*
* @throws IllegalStateException if the stack is empty
* @throws EmptyStackException if the stack is empty
*/
public static void popAlpha()
{
@@ -225,7 +226,7 @@ public abstract class Color {
}
if (alphaStack.isEmpty()) {
throw new IllegalStateException("Global alpha stack underflow.");
throw new EmptyStackException();
}
alphaStack.pop();