From 8cfe8f90900e242b3b59c11f5b64de26f24616a0 Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Thu, 21 Feb 2019 00:35:06 -0800 Subject: [PATCH] NPC paths now show action index at points --- core/src/gdx/diablo/entity/Entity.java | 2 +- core/src/gdx/diablo/entity/Monster.java | 15 ++++++++++++++- core/src/gdx/diablo/map/MapRenderer.java | 6 +++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/core/src/gdx/diablo/entity/Entity.java b/core/src/gdx/diablo/entity/Entity.java index e2e1658e..f85db534 100644 --- a/core/src/gdx/diablo/entity/Entity.java +++ b/core/src/gdx/diablo/entity/Entity.java @@ -432,7 +432,7 @@ public class Entity { shapes.set(ShapeRenderer.ShapeType.Line); } - public void drawDebugPath(ShapeRenderer shapes) {} + public void drawDebugPath(PaletteIndexedBatch batch, ShapeRenderer shapes) {} public void draw(Batch batch) { draw((PaletteIndexedBatch) batch); diff --git a/core/src/gdx/diablo/entity/Monster.java b/core/src/gdx/diablo/entity/Monster.java index 5349bff7..489c796f 100644 --- a/core/src/gdx/diablo/entity/Monster.java +++ b/core/src/gdx/diablo/entity/Monster.java @@ -53,7 +53,7 @@ public class Monster extends Entity { } @Override - public void drawDebugPath(ShapeRenderer shapes) { + public void drawDebugPath(PaletteIndexedBatch batch, ShapeRenderer shapes) { DS1.Path path = object.path; if (path == null) return; float p1x = +(position.x * Tile.SUBTILE_WIDTH50) - (position.y * Tile.SUBTILE_WIDTH50); @@ -91,6 +91,19 @@ public class Monster extends Entity { shapes.setColor(Color.WHITE); shapes.rect(p1x - HALF_BOX, p1y - HALF_BOX, BOX_SIZE, BOX_SIZE); } + + shapes.end(); + batch.begin(); + batch.setShader(null); + for (int i = 0; i < path.numPoints; i++) { + DS1.Path.Point point = path.points[i]; + p1x = +(point.x * Tile.SUBTILE_WIDTH50) - (point.y * Tile.SUBTILE_WIDTH50); + p1y = -(point.x * Tile.SUBTILE_HEIGHT50) - (point.y * Tile.SUBTILE_HEIGHT50); + Diablo.fonts.consolas16.draw(batch, Integer.toString(point.action), p1x, p1y - BOX_SIZE, 0, Align.center, false); + } + batch.end(); + batch.setShader(Diablo.shader); + shapes.begin(ShapeRenderer.ShapeType.Filled); } @Override diff --git a/core/src/gdx/diablo/map/MapRenderer.java b/core/src/gdx/diablo/map/MapRenderer.java index c87928b0..8c923e9c 100644 --- a/core/src/gdx/diablo/map/MapRenderer.java +++ b/core/src/gdx/diablo/map/MapRenderer.java @@ -491,7 +491,7 @@ public class MapRenderer { } if (RENDER_DEBUG_PATHS) - drawDebugPaths(shapes); + drawDebugPaths(batch, shapes); if (RENDER_DEBUG_CAMERA) { float viewportWidth = width; @@ -883,7 +883,7 @@ public class MapRenderer { } } - private void drawDebugPaths(ShapeRenderer shapes) { + private void drawDebugPaths(PaletteIndexedBatch batch, ShapeRenderer shapes) { shapes.set(ShapeRenderer.ShapeType.Filled); int startX2 = startX; int startY2 = startY; @@ -901,7 +901,7 @@ public class MapRenderer { Vector3 position = entity.position(); if ((stx <= position.x && position.x < stx + Tile.SUBTILE_SIZE) && (sty <= position.y && position.y < sty + Tile.SUBTILE_SIZE)) { - entity.drawDebugPath(shapes); + entity.drawDebugPath(batch, shapes); } } }