some minor edit in tiles
This commit is contained in:
@@ -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
|
* @return data object
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ public final class Tile extends Entity<TileData, TileModel, TileRenderContext> {
|
|||||||
|
|
||||||
public static final short ION_MARK = 700;
|
public static final short ION_MARK = 700;
|
||||||
|
|
||||||
|
/** Whether the tile is occupied by an entity */
|
||||||
|
private transient boolean occupied;
|
||||||
|
|
||||||
|
|
||||||
public Tile() {
|
public Tile() {
|
||||||
super();
|
super();
|
||||||
@@ -87,4 +90,29 @@ public final class Tile extends Entity<TileData, TileModel, TileRenderContext> {
|
|||||||
{
|
{
|
||||||
return model.isWalkable(data);
|
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 */
|
/** Items dropped onto this tile */
|
||||||
public final Stack<Item> items = new Stack<>();
|
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);
|
Tiles.register(id, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileData createData()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if this tile type is potentially walkable. Used during world
|
* Test if this tile type is potentially walkable. Used during world
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package mightypork.util.math.color;
|
package mightypork.util.math.color;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.EmptyStackException;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
import mightypork.util.annotations.FactoryMethod;
|
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
|
* Remove a pushed alpha multiplier from the stack. If there's no remaining
|
||||||
* multiplier on the stack, an exception is raised.
|
* 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()
|
public static void popAlpha()
|
||||||
{
|
{
|
||||||
@@ -225,7 +226,7 @@ public abstract class Color {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (alphaStack.isEmpty()) {
|
if (alphaStack.isEmpty()) {
|
||||||
throw new IllegalStateException("Global alpha stack underflow.");
|
throw new EmptyStackException();
|
||||||
}
|
}
|
||||||
|
|
||||||
alphaStack.pop();
|
alphaStack.pop();
|
||||||
|
|||||||
Reference in New Issue
Block a user