Merge branch 'stable' of https://github.com/marcus13345/hadean into stable
commit
cc77a0997e
|
|
@ -11,11 +11,17 @@ import xyz.valnet.hadean.util.Layers;
|
||||||
|
|
||||||
public class Stockpile extends WorldObject implements ITileThing, ISelectable {
|
public class Stockpile extends WorldObject implements ITileThing, ISelectable {
|
||||||
|
|
||||||
|
private WorldObject thing;
|
||||||
|
|
||||||
public Stockpile(int x, int y) {
|
public Stockpile(int x, int y) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFree() {
|
||||||
|
return thing == null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render() {
|
public void render() {
|
||||||
Drawing.setLayer(Layers.GROUND);
|
Drawing.setLayer(Layers.GROUND);
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package xyz.valnet.hadean.gameobjects.worldobjects;
|
||||||
import xyz.valnet.engine.graphics.Drawing;
|
import xyz.valnet.engine.graphics.Drawing;
|
||||||
import xyz.valnet.engine.math.Vector2i;
|
import xyz.valnet.engine.math.Vector2i;
|
||||||
import xyz.valnet.engine.math.Vector4f;
|
import xyz.valnet.engine.math.Vector4f;
|
||||||
|
import xyz.valnet.hadean.gameobjects.JobBoard;
|
||||||
import xyz.valnet.hadean.gameobjects.Stockpile;
|
import xyz.valnet.hadean.gameobjects.Stockpile;
|
||||||
import xyz.valnet.hadean.gameobjects.Tile;
|
import xyz.valnet.hadean.gameobjects.Tile;
|
||||||
import xyz.valnet.hadean.interfaces.IHaulable;
|
import xyz.valnet.hadean.interfaces.IHaulable;
|
||||||
|
|
@ -11,10 +12,33 @@ import xyz.valnet.hadean.interfaces.ITileThing;
|
||||||
import xyz.valnet.hadean.util.Action;
|
import xyz.valnet.hadean.util.Action;
|
||||||
import xyz.valnet.hadean.util.Assets;
|
import xyz.valnet.hadean.util.Assets;
|
||||||
import xyz.valnet.hadean.util.Layers;
|
import xyz.valnet.hadean.util.Layers;
|
||||||
|
import xyz.valnet.hadean.util.SmartBoolean;
|
||||||
|
import xyz.valnet.hadean.util.SmartBoolean.IListener;
|
||||||
|
|
||||||
public class Log extends WorldObject implements ITileThing, ISelectable, IHaulable {
|
public class Log extends WorldObject implements ITileThing, ISelectable, IHaulable {
|
||||||
|
|
||||||
private boolean haul = false;
|
private SmartBoolean haul;
|
||||||
|
|
||||||
|
private JobBoard jobboard;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
super.start();
|
||||||
|
jobboard = get(JobBoard.class);
|
||||||
|
Log that = this;
|
||||||
|
|
||||||
|
haul = new SmartBoolean(false, new IListener() {
|
||||||
|
@Override
|
||||||
|
public void rise() {
|
||||||
|
jobboard.postJob(that);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fall() {
|
||||||
|
jobboard.rescindJob(that);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public Log(int x, int y) {
|
public Log(int x, int y) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
|
|
@ -25,7 +49,7 @@ public class Log extends WorldObject implements ITileThing, ISelectable, IHaulab
|
||||||
public void render() {
|
public void render() {
|
||||||
Drawing.setLayer(Layers.GROUND);
|
Drawing.setLayer(Layers.GROUND);
|
||||||
camera.draw(Assets.log, x, y);
|
camera.draw(Assets.log, x, y);
|
||||||
if(haul) {
|
if(haul.value()) {
|
||||||
Drawing.setLayer(Layers.MARKERS);
|
Drawing.setLayer(Layers.MARKERS);
|
||||||
camera.draw(Assets.haulArrow, x, y);
|
camera.draw(Assets.haulArrow, x, y);
|
||||||
}
|
}
|
||||||
|
|
@ -61,7 +85,7 @@ public class Log extends WorldObject implements ITileThing, ISelectable, IHaulab
|
||||||
@Override
|
@Override
|
||||||
public void runAction(Action action) {
|
public void runAction(Action action) {
|
||||||
if(action == ACTION_HAUL) {
|
if(action == ACTION_HAUL) {
|
||||||
haul = !haul;
|
haul.toggle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,7 +96,7 @@ public class Log extends WorldObject implements ITileThing, ISelectable, IHaulab
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasWork() {
|
public boolean hasWork() {
|
||||||
return haul;
|
return haul.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -92,7 +116,7 @@ public class Log extends WorldObject implements ITileThing, ISelectable, IHaulab
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Log take() {
|
public Log take() {
|
||||||
haul = false;
|
haul.set(false);
|
||||||
Tile tile = terrain.getTile((int)x, (int)y);
|
Tile tile = terrain.getTile((int)x, (int)y);
|
||||||
tile.remove(this);
|
tile.remove(this);
|
||||||
return this;
|
return this;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue