Skip to content

Commit

Permalink
refactor use of ZoneCache
Browse files Browse the repository at this point in the history
  • Loading branch information
thelsing committed Nov 7, 2023
1 parent 49acfe4 commit b81e7b5
Showing 1 changed file with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1670,9 +1670,10 @@ private void fillViewportWith(ZoneCache.GdxPaint paint) {
// startY = (((int) startY) / texture.getHeight()) * texture.getHeight() - texture.getHeight();
var vertices =
new float[] {
startX, startY, startX, startY + h, startX + w, startY + h, startX + w, startY,
startX, startY, startX, startY + h, startX + w, startY + h, startX + w, startY
};
var indices = new short[] {0, 1, 2, 0, 2, 4};

var indices = new short[] {1, 0, 3, 3, 2, 1};

var polySprite = new PolygonSprite(new PolygonRegion(paint.textureRegion(), vertices, indices));
polySprite.setColor(paint.color());
Expand Down Expand Up @@ -3187,24 +3188,25 @@ private void highlightCell(ZonePoint zp, TextureRegion image, float size) {

@Subscribe
void onZoneActivated(ZoneActivated event) {
if (!initialized) return;

renderZone = false;

fogX = null;
fogY = null;

var newZone = event.zone();
zoneCache = new ZoneCache(newZone, atlas);
lineTemplateDrawer.setZoneCache(zoneCache);
lineCellTemplateDrawer.setZoneCache(zoneCache);
radiusTemplateDrawer.setZoneCache(zoneCache);
burstTemplateDrawer.setZoneCache(zoneCache);
coneTemplateDrawer.setZoneCache(zoneCache);
blastTemplateDrawer.setZoneCache(zoneCache);
radiusCellTemplateDrawer.setZoneCache(zoneCache);
shapeDrawableDrawer.setZoneCache(zoneCache);
renderZone = true;
Gdx.app.postRunnable(
() -> {
renderZone = false;

fogX = null;
fogY = null;

var newZone = event.zone();
zoneCache = new ZoneCache(newZone, atlas);
lineTemplateDrawer.setZoneCache(zoneCache);
lineCellTemplateDrawer.setZoneCache(zoneCache);
radiusTemplateDrawer.setZoneCache(zoneCache);
burstTemplateDrawer.setZoneCache(zoneCache);
coneTemplateDrawer.setZoneCache(zoneCache);
blastTemplateDrawer.setZoneCache(zoneCache);
radiusCellTemplateDrawer.setZoneCache(zoneCache);
shapeDrawableDrawer.setZoneCache(zoneCache);
renderZone = true;
});
}

public void setScale(Scale scale) {
Expand Down

0 comments on commit b81e7b5

Please sign in to comment.