diff --git a/core/src/com/riiablo/ai/AI.java b/core/src/com/riiablo/ai/AI.java index 3c5702e2..be96d8be 100644 --- a/core/src/com/riiablo/ai/AI.java +++ b/core/src/com/riiablo/ai/AI.java @@ -15,4 +15,8 @@ public abstract class AI { public void interact(GameScreen gameScreen) {} public void update(float delta) {} + + public String getState() { + return ""; + } } diff --git a/core/src/com/riiablo/ai/Fallen.java b/core/src/com/riiablo/ai/Fallen.java index 3b21fa20..60129764 100644 --- a/core/src/com/riiablo/ai/Fallen.java +++ b/core/src/com/riiablo/ai/Fallen.java @@ -119,4 +119,9 @@ public class Fallen extends AI { break; } } + + @Override + public String getState() { + return stateMachine.getCurrentState().name(); + } } diff --git a/core/src/com/riiablo/ai/Idle.java b/core/src/com/riiablo/ai/Idle.java index 13f60dd6..7877d42f 100644 --- a/core/src/com/riiablo/ai/Idle.java +++ b/core/src/com/riiablo/ai/Idle.java @@ -7,4 +7,9 @@ public class Idle extends AI { @Override public void update(float delta) {} + + @Override + public String getState() { + return "IDLE"; + } } diff --git a/core/src/com/riiablo/ai/Npc.java b/core/src/com/riiablo/ai/Npc.java index e5f5badc..ddd6f1e4 100644 --- a/core/src/com/riiablo/ai/Npc.java +++ b/core/src/com/riiablo/ai/Npc.java @@ -187,4 +187,13 @@ public class Npc extends AI { return 4; } } + + @Override + public String getState() { // TODO: proper NPC state machine -- PATH, IDLE, S1/S2, INTERACTING + if (actionTimer == Float.POSITIVE_INFINITY) { + return "INTERACT"; + } else { + return ""; + } + } } diff --git a/core/src/com/riiablo/ai/QuillRat.java b/core/src/com/riiablo/ai/QuillRat.java index 598b4e38..2a6f2451 100644 --- a/core/src/com/riiablo/ai/QuillRat.java +++ b/core/src/com/riiablo/ai/QuillRat.java @@ -33,4 +33,9 @@ public class QuillRat extends AI { entity.setPath(entity.map, dst); } } + + @Override + public String getState() { + return "WANDER"; + } } diff --git a/core/src/com/riiablo/ai/Zombie.java b/core/src/com/riiablo/ai/Zombie.java index 8279d7ec..ef6ff648 100644 --- a/core/src/com/riiablo/ai/Zombie.java +++ b/core/src/com/riiablo/ai/Zombie.java @@ -119,4 +119,9 @@ public class Zombie extends AI { break; } } + + @Override + public String getState() { + return stateMachine.getCurrentState().name(); + } } diff --git a/core/src/com/riiablo/entity/Entity.java b/core/src/com/riiablo/entity/Entity.java index 4af7d03c..9150ddbf 100644 --- a/core/src/com/riiablo/entity/Entity.java +++ b/core/src/com/riiablo/entity/Entity.java @@ -514,8 +514,10 @@ public abstract class Entity implements Animation.AnimationListener { .append('/') .append(StringUtils.leftPad(Integer.toString(animation.getNumFramesPerDir() - 1), 2)) .append(' ') - .append(animation.getFrameDelta()); + .append(animation.getFrameDelta()) + .append('\n'); } + appendToStatus(builder); GlyphLayout layout = Riiablo.fonts.consolas12.draw(batch, builder.toString(), x, y - Tile.SUBTILE_HEIGHT50, 0, Align.center, false); Pools.free(layout); batch.end(); @@ -523,6 +525,8 @@ public abstract class Entity implements Animation.AnimationListener { shapes.begin(ShapeRenderer.ShapeType.Line); } + protected void appendToStatus(StringBuilder builder) {} + public void drawDebugTarget(ShapeRenderer shapes) { if (target.isZero() || !path.isEmpty()) return; float srcX = +(position.x * Tile.SUBTILE_WIDTH50) - (position.y * Tile.SUBTILE_WIDTH50); diff --git a/core/src/com/riiablo/entity/Monster.java b/core/src/com/riiablo/entity/Monster.java index 0dc678b5..a517a68f 100644 --- a/core/src/com/riiablo/entity/Monster.java +++ b/core/src/com/riiablo/entity/Monster.java @@ -205,4 +205,11 @@ public class Monster extends Entity { batch.setShader(Riiablo.shader); shapes.begin(ShapeRenderer.ShapeType.Filled); } + + @Override + protected void appendToStatus(StringBuilder builder) { + if (ai != null) { + builder.append(ai.getState()).append('\n'); + } + } }