Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.dx2.xview.map;
- import net.openrs.cache.def.OverlayDefinition;
- import net.openrs.cache.def.UnderlayDefinition;
- import org.dx2.xview.map.util.TileUtils;
- /**
- * Represents a tile on a MapImage (the 64x64 coordinate).
- * @author `Discardedx2
- */
- public final class MapTileImage {
- /**
- * The x position of this tile.
- */
- private int tileX;
- /**
- * The y position of this tile.
- */
- private int tileY;
- /**
- * This tile's blended colour a.
- */
- private int blendColourA;
- /**
- * This tile's blended colour b.
- */
- private int blendColourB;
- /**
- * This tile's overlay.
- */
- private int overlay;
- /**
- * This tile's underlay.
- */
- private int underlay;
- /**
- * This tile's palette.
- */
- private int[] tilePalette;
- /**
- * This tile's wall.
- */
- private MapTileWall wall;
- /**
- * Constructs a new MapImage.
- * @param tileX The 64x64 x coordinate.
- * @param tileY The 64x64 y coordinate.
- */
- public MapTileImage(int tileX, int tileY) {
- this.tileX = tileX;
- this.tileY = tileY;
- }
- /**
- * Render's this tile's colour palette
- * onto the main image, in which we can then output.
- * @param renderer The renderer to render too.
- */
- public void draw(MapRenderer renderer) {
- int drawX = tileX * 8;
- int drawY = tileY * 8;
- boolean blendedTile = false;
- if (!blendedTile || blendColourA == 0 && blendColourB == 0) {
- if (underlay != 0) {
- tilePalette = UnderlayDefinition.get(underlay).getColourPalette();
- for(int sectorX = 0; sectorX < 8; sectorX++) {
- for(int sectorY = 0; sectorY < 8; sectorY++) {
- renderer.fillPixel((sectorX + drawX), (sectorY + drawY), tilePalette[sectorX * sectorY]);
- }
- }
- }
- if (overlay != 0) {
- tilePalette = OverlayDefinition.get(overlay).getColourPalette();
- for(int sectorX = 0; sectorX < 8; sectorX++) {
- for(int sectorY = 0; sectorY < 8; sectorY++) {
- renderer.fillPixel((sectorX + drawX), (sectorY + drawY), tilePalette[sectorX * sectorY]);
- }
- }
- }
- } else {
- int[][] blendedTilePixels = TileUtils.getBlendedPixels(blendColourA);
- for(int pixel = 0; pixel < blendedTilePixels.length; pixel++) {
- renderer.fillPixel((blendedTilePixels[pixel][0] + drawX), (blendedTilePixels[pixel][1] + drawY), 0xe43243);
- }
- }
- if (wall != null) {
- int sizeX = tileX * 8;
- int sizeY = tileY * 8;
- switch(wall.getType()) {
- case 0:
- for (int x = 0; x < sizeX; x++) {
- for (int i = 0; i < 5; i++) {
- renderer.fillPixel((x + sizeX), (sizeY + i), 0xFFFFFF);
- }
- }
- break;
- }
- }
- }
- /**
- * Gets the 64x64 x coordinate.
- * @return the tileX.
- */
- public int getTileX() {
- return tileX;
- }
- /**
- * Gets the 64x64 y coordinate.
- * @return the tileY.
- */
- public int getTileY() {
- return tileY;
- }
- /**
- * Gets this tile's blended colour a.
- * @return the shapeA.
- */
- public int getBlendedColourA() {
- return blendColourA;
- }
- /**
- * Sets this tile's shape a.
- * @param shapeA the shapeA to set.
- */
- public void setBlendedColourA(int shapeA) {
- this.blendColourA = shapeA;
- }
- /**
- * Gets this tile's blended colour b.
- * @return the shapeB.
- */
- public int getBlendedColourB() {
- return blendColourB;
- }
- /**
- * Sets this tile's blended colour b.
- * @param shapeB the shapeB to set.
- */
- public void setBlendedColourB(int shapeB) {
- this.blendColourB = shapeB;
- }
- /**
- * Gets this tile's overlay.
- * @return the overlay.
- */
- public int getOverlay() {
- return overlay;
- }
- /**
- * Sets this tile's overlay.
- * @param overlay the overlay to set.
- */
- public void setOverlay(int overlay) {
- this.overlay = overlay;
- }
- /**
- * Gets this tile's underlay.
- * @return the underlay.
- */
- public int getUnderlay() {
- return underlay;
- }
- /**
- * Sets this tile's underlay.
- * @param underlay the underlay to set.
- */
- public void setUnderlay(int underlay) {
- this.underlay = underlay;
- }
- /**
- * Gets this tiles wall.
- * @return the wall.
- */
- public MapTileWall getWall() {
- return wall;
- }
- /**
- * Sets this tile's wall.
- * @param wall the wall to set.
- */
- public void setWall(MapTileWall wall) {
- this.wall = wall;
- }
- }
Add Comment
Please, Sign In to add comment