Added some debug messaging for entity AI state

This commit is contained in:
Collin Smith 2019-04-11 16:07:18 -07:00
parent a5db1b4e48
commit 022aea2013
8 changed files with 45 additions and 1 deletions

View File

@ -15,4 +15,8 @@ public abstract class AI {
public void interact(GameScreen gameScreen) {}
public void update(float delta) {}
public String getState() {
return "";
}
}

View File

@ -119,4 +119,9 @@ public class Fallen extends AI {
break;
}
}
@Override
public String getState() {
return stateMachine.getCurrentState().name();
}
}

View File

@ -7,4 +7,9 @@ public class Idle extends AI {
@Override
public void update(float delta) {}
@Override
public String getState() {
return "IDLE";
}
}

View File

@ -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 "";
}
}
}

View File

@ -33,4 +33,9 @@ public class QuillRat extends AI {
entity.setPath(entity.map, dst);
}
}
@Override
public String getState() {
return "WANDER";
}
}

View File

@ -119,4 +119,9 @@ public class Zombie extends AI {
break;
}
}
@Override
public String getState() {
return stateMachine.getCurrentState().name();
}
}

View File

@ -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);

View File

@ -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');
}
}
}