From 45e6558d907f8867ed27b1c18d6ef06a7da8434f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Thu, 1 May 2014 14:20:40 +0200 Subject: [PATCH] improved mouse controls; cleanup --- .../gamecore/eventbus/BusEvent.java | 4 +- .../gamecore/eventbus/EventChannel.java | 4 +- .../gamecore/eventbus/clients/BusNode.java | 4 +- .../layout/HorizontalFixedFlowLayout.java | 4 +- .../layout/VerticalFixedFlowLayout.java | 4 +- .../gamecore/gui/screens/ScreenRegistry.java | 4 +- src/mightypork/gamecore/input/KeyStroke.java | 4 +- src/mightypork/gamecore/logging/Log.java | 8 +- .../logging/writers/ArchivingLog.java | 4 +- src/mightypork/gamecore/render/Render.java | 4 +- .../gamecore/resources/audio/SoundBank.java | 8 +- .../gamecore/resources/fonts/FontBank.java | 4 +- .../resources/fonts/impl/CachedFont.java | 2 +- .../resources/loading/DeferredResource.java | 4 +- .../gamecore/resources/textures/QuadGrid.java | 21 ++-- .../gamecore/util/files/FileSuffixFilter.java | 4 +- .../gamecore/util/files/FileTreeDiff.java | 4 +- .../gamecore/util/files/FileUtils.java | 24 +++-- .../gamecore/util/files/OsUtils.java | 8 +- .../util/files/config/PropertyManager.java | 4 +- .../util/files/config/SortedProperties.java | 4 +- src/mightypork/gamecore/util/ion/Ion.java | 16 ++- .../gamecore/util/ion/IonOutput.java | 4 +- src/mightypork/gamecore/util/math/Calc.java | 8 +- .../algo/pathfinding/PathFinderProxy.java | 4 +- .../gamecore/util/math/color/Color.java | 12 ++- .../util/math/constraints/rect/Rect.java | 4 +- .../constraints/rect/builders/TiledRect.java | 8 +- .../gamecore/util/math/timing/TimedTask.java | 3 +- .../gamecore/util/math/timing/TimerFps.java | 8 +- .../gamecore/util/objects/Convert.java | 8 +- .../gamecore/util/objects/Pair.java | 8 +- .../gamecore/util/objects/VarargsParser.java | 4 +- src/mightypork/rogue/Res.java | 2 +- .../rogue/screens/game/WorldLayer.java | 12 +-- src/mightypork/rogue/world/PlayerControl.java | 12 ++- src/mightypork/rogue/world/World.java | 6 +- src/mightypork/rogue/world/WorldProvider.java | 4 +- .../rogue/world/entity/Entities.java | 12 ++- .../rogue/world/entity/EntityModel.java | 2 + .../rogue/world/entity/EntityPathFinder.java | 6 +- .../world/entity/entities/MonsterAi.java | 4 +- .../world/entity/entities/PlayerEntity.java | 10 +- .../world/entity/entities/RatEntity.java | 5 +- .../entity/modules/EntityModuleHealth.java | 4 +- .../entity/modules/EntityModulePosition.java | 11 +- .../entity/renderers/EntityRenderer.java | 3 +- .../rogue/world/gen/LevelGenerator.java | 13 ++- src/mightypork/rogue/world/gen/MapTheme.java | 4 +- src/mightypork/rogue/world/gen/RoomDesc.java | 4 +- .../rogue/world/gen/ScratchMap.java | 12 ++- .../world/gen/rooms/AbstractRectRoom.java | 18 ++-- src/mightypork/rogue/world/gui/MapView.java | 12 +-- .../gui/interaction/MIPClickPathfWalk.java | 62 ----------- .../{MIPKeyWalk.java => MIPKeyboard.java} | 8 +- .../rogue/world/gui/interaction/MIPMouse.java | 102 ++++++++++++++++++ .../world/gui/interaction/MIPMouseWalk.java | 83 -------------- .../world/gui/interaction/MIPTileClick.java | 44 -------- .../gui/interaction/MapInteractionPlugin.java | 6 +- src/mightypork/rogue/world/level/Level.java | 3 +- src/mightypork/rogue/world/tile/Tile.java | 2 +- .../rogue/world/tile/TileGenData.java | 1 + .../rogue/world/tile/TileModel.java | 2 +- .../rogue/world/tile/TileRenderer.java | 14 ++- src/mightypork/rogue/world/tile/Tiles.java | 17 +-- .../tile/renderers/DoorTileRenderer.java | 9 +- .../tile/renderers/NullTileRenderer.java | 1 - .../rogue/world/tile/tiles/NullTile.java | 1 + .../rogue/world/tile/tiles/TileBaseFloor.java | 7 +- .../world/tile/tiles/TileBasePassage.java | 2 +- .../world/tile/tiles/TileBaseSecretDoor.java | 4 - .../rogue/world/tile/tiles/TileBaseWall.java | 5 +- .../rogue/world/tile/tiles/TileSolid.java | 1 - .../rogue/world/tile/tiles/TileWalkable.java | 1 - .../world/tile/tiles/brick/TileBrickDoor.java | 3 +- .../tile/tiles/brick/TileBrickFloor.java | 4 +- .../tile/tiles/brick/TileBrickPassage.java | 1 - .../tile/tiles/brick/TileBrickSecretDoor.java | 6 +- .../world/tile/tiles/brick/TileBrickWall.java | 4 +- 79 files changed, 407 insertions(+), 360 deletions(-) delete mode 100644 src/mightypork/rogue/world/gui/interaction/MIPClickPathfWalk.java rename src/mightypork/rogue/world/gui/interaction/{MIPKeyWalk.java => MIPKeyboard.java} (87%) create mode 100644 src/mightypork/rogue/world/gui/interaction/MIPMouse.java delete mode 100644 src/mightypork/rogue/world/gui/interaction/MIPMouseWalk.java delete mode 100644 src/mightypork/rogue/world/gui/interaction/MIPTileClick.java diff --git a/src/mightypork/gamecore/eventbus/BusEvent.java b/src/mightypork/gamecore/eventbus/BusEvent.java index 8cab991..1086a5c 100644 --- a/src/mightypork/gamecore/eventbus/BusEvent.java +++ b/src/mightypork/gamecore/eventbus/BusEvent.java @@ -54,7 +54,9 @@ public abstract class BusEvent { { if (consumed) throw new IllegalStateException("Already consumed."); - if (getClass().isAnnotationPresent(NonConsumableEvent.class)) { throw new UnsupportedOperationException("Not consumable."); } + if (getClass().isAnnotationPresent(NonConsumableEvent.class)) { + throw new UnsupportedOperationException("Not consumable."); + } consumed = true; } diff --git a/src/mightypork/gamecore/eventbus/EventChannel.java b/src/mightypork/gamecore/eventbus/EventChannel.java index e9ea588..31c1200 100644 --- a/src/mightypork/gamecore/eventbus/EventChannel.java +++ b/src/mightypork/gamecore/eventbus/EventChannel.java @@ -31,7 +31,9 @@ class EventChannel, CLIENT> { public EventChannel(Class eventClass, Class clientClass) { - if (eventClass == null || clientClass == null) { throw new NullPointerException("Null Event or Client class."); } + if (eventClass == null || clientClass == null) { + throw new NullPointerException("Null Event or Client class."); + } this.clientClass = clientClass; this.eventClass = eventClass; diff --git a/src/mightypork/gamecore/eventbus/clients/BusNode.java b/src/mightypork/gamecore/eventbus/clients/BusNode.java index 063323c..44e2430 100644 --- a/src/mightypork/gamecore/eventbus/clients/BusNode.java +++ b/src/mightypork/gamecore/eventbus/clients/BusNode.java @@ -62,7 +62,9 @@ public abstract class BusNode implements BusAccess, ClientHub { @Override public void addChildClient(Object client) { - if (client instanceof RootBusNode) { throw new IllegalArgumentException("Cannot nest RootBusNode."); } + if (client instanceof RootBusNode) { + throw new IllegalArgumentException("Cannot nest RootBusNode."); + } clients.add(client); } diff --git a/src/mightypork/gamecore/gui/components/layout/HorizontalFixedFlowLayout.java b/src/mightypork/gamecore/gui/components/layout/HorizontalFixedFlowLayout.java index 79f903e..28c40a0 100644 --- a/src/mightypork/gamecore/gui/components/layout/HorizontalFixedFlowLayout.java +++ b/src/mightypork/gamecore/gui/components/layout/HorizontalFixedFlowLayout.java @@ -34,7 +34,9 @@ public class HorizontalFixedFlowLayout extends LayoutComponent { this.colWidth = elementWidth; this.align = align; - if (align != AlignX.LEFT && align != AlignX.RIGHT) { throw new IllegalArgumentException("Can align only left or right."); } + if (align != AlignX.LEFT && align != AlignX.RIGHT) { + throw new IllegalArgumentException("Can align only left or right."); + } } diff --git a/src/mightypork/gamecore/gui/components/layout/VerticalFixedFlowLayout.java b/src/mightypork/gamecore/gui/components/layout/VerticalFixedFlowLayout.java index 4feb5df..a7955e9 100644 --- a/src/mightypork/gamecore/gui/components/layout/VerticalFixedFlowLayout.java +++ b/src/mightypork/gamecore/gui/components/layout/VerticalFixedFlowLayout.java @@ -34,7 +34,9 @@ public class VerticalFixedFlowLayout extends LayoutComponent { this.rowHeight = elementHeight; this.align = align; - if (align != AlignY.TOP && align != AlignY.BOTTOM) { throw new IllegalArgumentException("Can align only to top or bottom."); } + if (align != AlignY.TOP && align != AlignY.BOTTOM) { + throw new IllegalArgumentException("Can align only to top or bottom."); + } } diff --git a/src/mightypork/gamecore/gui/screens/ScreenRegistry.java b/src/mightypork/gamecore/gui/screens/ScreenRegistry.java index 295ab66..8680ddf 100644 --- a/src/mightypork/gamecore/gui/screens/ScreenRegistry.java +++ b/src/mightypork/gamecore/gui/screens/ScreenRegistry.java @@ -69,7 +69,9 @@ public class ScreenRegistry extends AppModule implements ScreenRequestListener, // find screen to show final Screen toShow = screens.get(key); - if (toShow == null) { throw new RuntimeException("Screen " + key + " not defined."); } + if (toShow == null) { + throw new RuntimeException("Screen " + key + " not defined."); + } // deactivate last screen if (active != null) { diff --git a/src/mightypork/gamecore/input/KeyStroke.java b/src/mightypork/gamecore/input/KeyStroke.java index 9339e10..75b6644 100644 --- a/src/mightypork/gamecore/input/KeyStroke.java +++ b/src/mightypork/gamecore/input/KeyStroke.java @@ -82,7 +82,9 @@ public class KeyStroke { if (keys == null) { if (other.keys != null) return false; - } else if (!keys.equals(other.keys)) { return false; } + } else if (!keys.equals(other.keys)) { + return false; + } if (fallingEdge != other.fallingEdge) return false; diff --git a/src/mightypork/gamecore/logging/Log.java b/src/mightypork/gamecore/logging/Log.java index 71468ae..6e344ac 100644 --- a/src/mightypork/gamecore/logging/Log.java +++ b/src/mightypork/gamecore/logging/Log.java @@ -295,7 +295,9 @@ public class Log { final String nl = System.getProperty("line.separator"); - if (message.equals("\n")) { return nl; } + if (message.equals("\n")) { + return nl; + } if (message.charAt(0) == '\n') { message = nl + message.substring(1); @@ -357,7 +359,9 @@ public class Log { public static String str(Class cls) { final LogAlias ln = cls.getAnnotation(LogAlias.class); - if (ln != null) { return ln.name(); } + if (ln != null) { + return ln.name(); + } String name = cls.getName(); diff --git a/src/mightypork/gamecore/logging/writers/ArchivingLog.java b/src/mightypork/gamecore/logging/writers/ArchivingLog.java index 5a55e25..ba926de 100644 --- a/src/mightypork/gamecore/logging/writers/ArchivingLog.java +++ b/src/mightypork/gamecore/logging/writers/ArchivingLog.java @@ -112,7 +112,9 @@ public class ArchivingLog extends SimpleLog { // playing with fireee for (int i = 0; i < oldLogs.size() - logs_to_keep; i++) { - if (!oldLogs.get(i).delete()) { throw new RuntimeException("Could not delete old log file."); } + if (!oldLogs.get(i).delete()) { + throw new RuntimeException("Could not delete old log file."); + } } } diff --git a/src/mightypork/gamecore/render/Render.java b/src/mightypork/gamecore/render/Render.java index babb75a..e3afe42 100644 --- a/src/mightypork/gamecore/render/Render.java +++ b/src/mightypork/gamecore/render/Render.java @@ -455,9 +455,9 @@ public class Render { final RectDigest q = quad.digest(); final RectDigest u = txquad.uvs.digest(); - double offs = 0.0001;// hack to avoid white stitching + final double offs = 0.0001;// hack to avoid white stitching - double tL = u.left+offs, tR = u.right-offs, tT = u.top+offs, tB = u.bottom-offs; + double tL = u.left + offs, tR = u.right - offs, tT = u.top + offs, tB = u.bottom - offs; // handle flip if (txquad.isFlippedY()) { diff --git a/src/mightypork/gamecore/resources/audio/SoundBank.java b/src/mightypork/gamecore/resources/audio/SoundBank.java index 6b98bfa..82167f6 100644 --- a/src/mightypork/gamecore/resources/audio/SoundBank.java +++ b/src/mightypork/gamecore/resources/audio/SoundBank.java @@ -70,7 +70,9 @@ public class SoundBank extends LightAppModule { public LoopPlayer getLoop(String key) { final LoopPlayer p = loops.get(key); - if (p == null) { throw new RuntimeException("Unknown sound loop \"" + key + "\"."); } + if (p == null) { + throw new RuntimeException("Unknown sound loop \"" + key + "\"."); + } return p; } @@ -84,7 +86,9 @@ public class SoundBank extends LightAppModule { public EffectPlayer getEffect(String key) { final EffectPlayer p = effects.get(key); - if (p == null) { throw new RuntimeException("Unknown sound effect \"" + key + "\"."); } + if (p == null) { + throw new RuntimeException("Unknown sound effect \"" + key + "\"."); + } return p; } } diff --git a/src/mightypork/gamecore/resources/fonts/FontBank.java b/src/mightypork/gamecore/resources/fonts/FontBank.java index 2d908d4..790234d 100644 --- a/src/mightypork/gamecore/resources/fonts/FontBank.java +++ b/src/mightypork/gamecore/resources/fonts/FontBank.java @@ -80,7 +80,9 @@ public class FontBank extends LightAppModule { if (f == null) f = fonts.get(aliases.get(key)); - if (f == null) { throw new RuntimeException("There's no font called " + key + "!"); } + if (f == null) { + throw new RuntimeException("There's no font called " + key + "!"); + } return f; } diff --git a/src/mightypork/gamecore/resources/fonts/impl/CachedFont.java b/src/mightypork/gamecore/resources/fonts/impl/CachedFont.java index 7b59814..b0fe3de 100644 --- a/src/mightypork/gamecore/resources/fonts/impl/CachedFont.java +++ b/src/mightypork/gamecore/resources/fonts/impl/CachedFont.java @@ -88,7 +88,7 @@ public class CachedFont implements GLFont { */ public CachedFont(java.awt.Font font, boolean antialias, FilterMode filter, String chars) { - this(font, antialias, filter, (" "+chars).toCharArray()); + this(font, antialias, filter, (" " + chars).toCharArray()); } diff --git a/src/mightypork/gamecore/resources/loading/DeferredResource.java b/src/mightypork/gamecore/resources/loading/DeferredResource.java index af2fbf8..ec3ca6e 100644 --- a/src/mightypork/gamecore/resources/loading/DeferredResource.java +++ b/src/mightypork/gamecore/resources/loading/DeferredResource.java @@ -41,7 +41,9 @@ public abstract class DeferredResource implements Deferred, Destroyable { loadFailed = false; try { - if (resource == null) { throw new NullPointerException("Resource string cannot be null for non-null resource."); } + if (resource == null) { + throw new NullPointerException("Resource string cannot be null for non-null resource."); + } Log.f3(" Loading: " + this); loadResource(resource); diff --git a/src/mightypork/gamecore/resources/textures/QuadGrid.java b/src/mightypork/gamecore/resources/textures/QuadGrid.java index 7ee044a..4fb2d7f 100644 --- a/src/mightypork/gamecore/resources/textures/QuadGrid.java +++ b/src/mightypork/gamecore/resources/textures/QuadGrid.java @@ -37,7 +37,9 @@ public class QuadGrid { */ public TxQuad makeQuad(int x, int y) { - if (x < 0 || x >= txWidth || y < 0 || y >= txHeight) { throw new IndexOutOfBoundsException("Requested invalid txquad coordinates."); } + if (x < 0 || x >= txWidth || y < 0 || y >= txHeight) { + throw new IndexOutOfBoundsException("Requested invalid txquad coordinates."); + } return makeQuad(x, y, 1, 1); } @@ -55,9 +57,13 @@ public class QuadGrid { */ public TxQuad makeQuad(double x, double y, double width, double height) { - if (x < 0 || x >= txWidth || y < 0 || y >= txHeight) { throw new IndexOutOfBoundsException("Requested invalid txquad coordinates."); } + if (x < 0 || x >= txWidth || y < 0 || y >= txHeight) { + throw new IndexOutOfBoundsException("Requested invalid txquad coordinates."); + } - if (x + width > txWidth || y + height > txHeight) { throw new IndexOutOfBoundsException("Requested invalid txquad size (would go beyond texture size)."); } + if (x + width > txWidth || y + height > txHeight) { + throw new IndexOutOfBoundsException("Requested invalid txquad size (would go beyond texture size)."); + } return tx.makeQuad(Rect.make(tileW * x, tileH * y, tileW * width, tileH * height)); } @@ -74,10 +80,13 @@ public class QuadGrid { */ public TxSheet makeSheet(int x, int y, int width, int height) { - if (x < 0 || x >= txWidth || y < 0 || y >= txHeight) { throw new IndexOutOfBoundsException("Requested invalid txquad coordinates."); } + if (x < 0 || x >= txWidth || y < 0 || y >= txHeight) { + throw new IndexOutOfBoundsException("Requested invalid txquad coordinates."); + } - if (x + width > txWidth || y + height > txHeight) { throw new IndexOutOfBoundsException( - "Requested invalid txsheet size (would go beyond texture size)."); } + if (x + width > txWidth || y + height > txHeight) { + throw new IndexOutOfBoundsException("Requested invalid txsheet size (would go beyond texture size)."); + } return makeQuad(x, y).makeSheet(width, height); } diff --git a/src/mightypork/gamecore/util/files/FileSuffixFilter.java b/src/mightypork/gamecore/util/files/FileSuffixFilter.java index cc50221..8e1cc9c 100644 --- a/src/mightypork/gamecore/util/files/FileSuffixFilter.java +++ b/src/mightypork/gamecore/util/files/FileSuffixFilter.java @@ -35,7 +35,9 @@ public class FileSuffixFilter implements FileFilter { final String fname = pathname.getName().toLowerCase().trim(); for (final String suffix : suffixes) { - if (fname.endsWith(suffix.toLowerCase().trim())) { return true; } + if (fname.endsWith(suffix.toLowerCase().trim())) { + return true; + } } return false; diff --git a/src/mightypork/gamecore/util/files/FileTreeDiff.java b/src/mightypork/gamecore/util/files/FileTreeDiff.java index 7961330..8e03748 100644 --- a/src/mightypork/gamecore/util/files/FileTreeDiff.java +++ b/src/mightypork/gamecore/util/files/FileTreeDiff.java @@ -82,7 +82,9 @@ public class FileTreeDiff { final int read1 = cin1.read(BUFFER); final int read2 = cin2.read(BUFFER); - if (read1 != read2 || ck1.getValue() != ck2.getValue()) { throw new NotEqualException("Bytes differ:\n" + pair.a + "\n" + pair.b); } + if (read1 != read2 || ck1.getValue() != ck2.getValue()) { + throw new NotEqualException("Bytes differ:\n" + pair.a + "\n" + pair.b); + } if (read1 == -1) break; } diff --git a/src/mightypork/gamecore/util/files/FileUtils.java b/src/mightypork/gamecore/util/files/FileUtils.java index e2fd102..45f622d 100644 --- a/src/mightypork/gamecore/util/files/FileUtils.java +++ b/src/mightypork/gamecore/util/files/FileUtils.java @@ -39,7 +39,9 @@ public class FileUtils { if (!source.exists()) return; if (source.isDirectory()) { - if (!target.exists() && !target.mkdir()) { throw new IOException("Could not open destination directory."); } + if (!target.exists() && !target.mkdir()) { + throw new IOException("Could not open destination directory."); + } final String[] children = source.list(); for (final String element : children) { @@ -47,7 +49,9 @@ public class FileUtils { } } else { - if (filter != null && !filter.accept(source)) { return; } + if (filter != null && !filter.accept(source)) { + return; + } if (filesCopied != null) filesCopied.add(target); copyFile(source, target); @@ -72,7 +76,9 @@ public class FileUtils { } } else { - if (filter != null && !filter.isValid(source.getAbsolutePath())) { return; } + if (filter != null && !filter.isValid(source.getAbsolutePath())) { + return; + } files.add(source); } @@ -106,9 +112,13 @@ public class FileUtils { */ public static void copyStream(InputStream in, OutputStream out) throws IOException { - if (in == null) { throw new NullPointerException("Input stream is null"); } + if (in == null) { + throw new NullPointerException("Input stream is null"); + } - if (out == null) { throw new NullPointerException("Output stream is null"); } + if (out == null) { + throw new NullPointerException("Output stream is null"); + } final byte[] buf = new byte[2048]; int len; @@ -127,7 +137,9 @@ public class FileUtils { */ public static boolean delete(File path, boolean recursive) { - if (!path.exists()) { return true; } + if (!path.exists()) { + return true; + } if (!recursive || !path.isDirectory()) return path.delete(); diff --git a/src/mightypork/gamecore/util/files/OsUtils.java b/src/mightypork/gamecore/util/files/OsUtils.java index a17c267..18b63b9 100644 --- a/src/mightypork/gamecore/util/files/OsUtils.java +++ b/src/mightypork/gamecore/util/files/OsUtils.java @@ -56,7 +56,9 @@ public class OsUtils { final File f = new File(getWorkDir(dirname), subfolderName); if (!f.exists() && create) { - if (!f.mkdirs()) { throw new RuntimeException("Could not create."); } + if (!f.mkdirs()) { + throw new RuntimeException("Could not create."); + } } return f; @@ -135,7 +137,9 @@ public class OsUtils { if (!file.exists() || !file.isDirectory()) { if (create) { - if (!file.mkdirs()) { throw new RuntimeException("Could not create working directory."); } + if (!file.mkdirs()) { + throw new RuntimeException("Could not create working directory."); + } } } diff --git a/src/mightypork/gamecore/util/files/config/PropertyManager.java b/src/mightypork/gamecore/util/files/config/PropertyManager.java index 24e47ee..94ec0ce 100644 --- a/src/mightypork/gamecore/util/files/config/PropertyManager.java +++ b/src/mightypork/gamecore/util/files/config/PropertyManager.java @@ -182,7 +182,9 @@ public class PropertyManager { { boolean needsSave = false; if (!file.getParentFile().mkdirs()) { - if (!file.getParentFile().exists()) { throw new RuntimeException("Cound not create config file."); } + if (!file.getParentFile().exists()) { + throw new RuntimeException("Cound not create config file."); + } } try(FileInputStream fis = new FileInputStream(file)) { diff --git a/src/mightypork/gamecore/util/files/config/SortedProperties.java b/src/mightypork/gamecore/util/files/config/SortedProperties.java index 32fca9e..a8174d2 100644 --- a/src/mightypork/gamecore/util/files/config/SortedProperties.java +++ b/src/mightypork/gamecore/util/files/config/SortedProperties.java @@ -263,7 +263,9 @@ public class SortedProperties extends java.util.Properties { private static char hexDigit(char ch, int offset) { final int val = (ch >> offset) & 0xF; - if (val <= 9) { return (char) ('0' + val); } + if (val <= 9) { + return (char) ('0' + val); + } return (char) ('A' + val - 10); } diff --git a/src/mightypork/gamecore/util/ion/Ion.java b/src/mightypork/gamecore/util/ion/Ion.java index c0c88ef..1dc56a8 100644 --- a/src/mightypork/gamecore/util/ion/Ion.java +++ b/src/mightypork/gamecore/util/ion/Ion.java @@ -93,9 +93,13 @@ public class Ion { if (mark > 255) throw new IllegalArgumentException("Mark must be < 256."); if (mark < 0) throw new IllegalArgumentException("Mark must be positive."); - if (reservedMarkChecking && mark < 50) { throw new IllegalArgumentException("Marks 0..49 are reserved."); } + if (reservedMarkChecking && mark < 50) { + throw new IllegalArgumentException("Marks 0..49 are reserved."); + } - if (registered[mark] != null) { throw new IllegalArgumentException("Mark " + mark + " is already in use."); } + if (registered[mark] != null) { + throw new IllegalArgumentException("Mark " + mark + " is already in use."); + } try { objClass.getConstructor(); @@ -278,9 +282,13 @@ public class Ion { final Class clz = Ion.getClassForMark(mark); - if (clz == null) { throw new IOException("Not registered - mark: " + mark + ", class: " + Log.str(obj.getClass())); } + if (clz == null) { + throw new IOException("Not registered - mark: " + mark + ", class: " + Log.str(obj.getClass())); + } - if (clz != obj.getClass()) { throw new IOException("Class mismatch - mark: " + mark + ", class: " + Log.str(obj.getClass())); } + if (clz != obj.getClass()) { + throw new IOException("Class mismatch - mark: " + mark + ", class: " + Log.str(obj.getClass())); + } } } diff --git a/src/mightypork/gamecore/util/ion/IonOutput.java b/src/mightypork/gamecore/util/ion/IonOutput.java index 08e6fa5..60a20d4 100644 --- a/src/mightypork/gamecore/util/ion/IonOutput.java +++ b/src/mightypork/gamecore/util/ion/IonOutput.java @@ -281,7 +281,9 @@ public class IonOutput { return; } - if (obj instanceof IonObjBundled) { throw new IOException("Bundled objects cannot be written to ION stream directly at " + obj); } + if (obj instanceof IonObjBundled) { + throw new IOException("Bundled objects cannot be written to ION stream directly at " + obj); + } if (obj instanceof Boolean) { writeMark(Ion.BOOLEAN); diff --git a/src/mightypork/gamecore/util/math/Calc.java b/src/mightypork/gamecore/util/math/Calc.java index b036f7d..c7e5127 100644 --- a/src/mightypork/gamecore/util/math/Calc.java +++ b/src/mightypork/gamecore/util/math/Calc.java @@ -594,7 +594,9 @@ public class Calc { */ public static List parseIntList(String list) { - if (list == null) { return null; } + if (list == null) { + return null; + } final String[] parts = list.split(","); final ArrayList intList = new ArrayList<>(); @@ -654,7 +656,9 @@ public class Calc { */ public static void assertValidIndex(int index, int length) { - if (!inRange(index, 0, length - 1)) { throw new IndexOutOfBoundsException(); } + if (!inRange(index, 0, length - 1)) { + throw new IndexOutOfBoundsException(); + } } diff --git a/src/mightypork/gamecore/util/math/algo/pathfinding/PathFinderProxy.java b/src/mightypork/gamecore/util/math/algo/pathfinding/PathFinderProxy.java index 6012c9e..3e56461 100644 --- a/src/mightypork/gamecore/util/math/algo/pathfinding/PathFinderProxy.java +++ b/src/mightypork/gamecore/util/math/algo/pathfinding/PathFinderProxy.java @@ -6,8 +6,8 @@ import mightypork.gamecore.util.math.algo.Step; /** - * Pathfinder proxy. Can be used to override individual methods but - * keep the rest as is. + * Pathfinder proxy. Can be used to override individual methods but keep the + * rest as is. * * @author MightyPork */ diff --git a/src/mightypork/gamecore/util/math/color/Color.java b/src/mightypork/gamecore/util/math/color/Color.java index d92bc08..d4febc3 100644 --- a/src/mightypork/gamecore/util/math/color/Color.java +++ b/src/mightypork/gamecore/util/math/color/Color.java @@ -205,7 +205,9 @@ public abstract class Color { */ public static void pushAlpha(Num alpha) { - if (!alphaStackEnabled) { return; } + if (!alphaStackEnabled) { + return; + } alphaStack.push(alpha); } @@ -219,9 +221,13 @@ public abstract class Color { */ public static void popAlpha() { - if (!alphaStackEnabled) { return; } + if (!alphaStackEnabled) { + return; + } - if (alphaStack.isEmpty()) { throw new EmptyStackException(); } + if (alphaStack.isEmpty()) { + throw new EmptyStackException(); + } alphaStack.pop(); } diff --git a/src/mightypork/gamecore/util/math/constraints/rect/Rect.java b/src/mightypork/gamecore/util/math/constraints/rect/Rect.java index f3dfced..3abe653 100644 --- a/src/mightypork/gamecore/util/math/constraints/rect/Rect.java +++ b/src/mightypork/gamecore/util/math/constraints/rect/Rect.java @@ -1028,7 +1028,9 @@ public abstract class Rect implements RectBound, Digestable { double rw = other.size().x(); double rh = other.size().y(); - if (rw <= 0 || rh <= 0 || tw <= 0 || th <= 0) { return false; } + if (rw <= 0 || rh <= 0 || tw <= 0 || th <= 0) { + return false; + } final double tx = this.origin().x(); final double ty = this.origin().y(); diff --git a/src/mightypork/gamecore/util/math/constraints/rect/builders/TiledRect.java b/src/mightypork/gamecore/util/math/constraints/rect/builders/TiledRect.java index b107a5a..6256314 100644 --- a/src/mightypork/gamecore/util/math/constraints/rect/builders/TiledRect.java +++ b/src/mightypork/gamecore/util/math/constraints/rect/builders/TiledRect.java @@ -58,9 +58,13 @@ public class TiledRect extends RectProxy { */ public Rect tile(int x, int y) { - if (x >= tilesX || x < 0) { throw new IndexOutOfBoundsException("X coordinate out fo range: " + x); } + if (x >= tilesX || x < 0) { + throw new IndexOutOfBoundsException("X coordinate out fo range: " + x); + } - if (y >= tilesY || y < 0) { throw new IndexOutOfBoundsException("Y coordinate out of range: " + y); } + if (y >= tilesY || y < 0) { + throw new IndexOutOfBoundsException("Y coordinate out of range: " + y); + } return aTile.move(perCol.mul(x), perRow.mul(y)); } diff --git a/src/mightypork/gamecore/util/math/timing/TimedTask.java b/src/mightypork/gamecore/util/math/timing/TimedTask.java index fd0e44c..4c295f1 100644 --- a/src/mightypork/gamecore/util/math/timing/TimedTask.java +++ b/src/mightypork/gamecore/util/math/timing/TimedTask.java @@ -29,7 +29,8 @@ public abstract class TimedTask implements Runnable, Updateable { } - public boolean isRunning() { + public boolean isRunning() + { return !timer.isFinished(); } diff --git a/src/mightypork/gamecore/util/math/timing/TimerFps.java b/src/mightypork/gamecore/util/math/timing/TimerFps.java index 4daf7b6..becdf0a 100644 --- a/src/mightypork/gamecore/util/math/timing/TimerFps.java +++ b/src/mightypork/gamecore/util/math/timing/TimerFps.java @@ -64,11 +64,15 @@ public class TimerFps { */ public double getFraction() { - if (getSkipped() >= 1) { return 1; } + if (getSkipped() >= 1) { + return 1; + } final long time = getTime(); - if (time <= nextFrame) { return (double) (time - lastFrame) / (double) FRAME; } + if (time <= nextFrame) { + return (double) (time - lastFrame) / (double) FRAME; + } return 1; } diff --git a/src/mightypork/gamecore/util/objects/Convert.java b/src/mightypork/gamecore/util/objects/Convert.java index 1a873a0..4df136a 100644 --- a/src/mightypork/gamecore/util/objects/Convert.java +++ b/src/mightypork/gamecore/util/objects/Convert.java @@ -137,7 +137,9 @@ public class Convert { return String.format("{%f|%f}", c.getMin(), c.getMax()); } - if (o instanceof Class) { return Log.str(o); } + if (o instanceof Class) { + return Log.str(o); + } return o.toString(); } @@ -177,7 +179,9 @@ public class Convert { final double x = Double.parseDouble(parts[0].trim()); final double y = Double.parseDouble(parts[1].trim()); - if (parts.length == 2) { return Vect.make(x, y); } + if (parts.length == 2) { + return Vect.make(x, y); + } final double z = Double.parseDouble(parts[2].trim()); diff --git a/src/mightypork/gamecore/util/objects/Pair.java b/src/mightypork/gamecore/util/objects/Pair.java index 0747154..8eff987 100644 --- a/src/mightypork/gamecore/util/objects/Pair.java +++ b/src/mightypork/gamecore/util/objects/Pair.java @@ -59,9 +59,13 @@ public class Pair { @Override public boolean equals(Object obj) { - if (obj == null) { return false; } + if (obj == null) { + return false; + } - if (!this.getClass().equals(obj.getClass())) { return false; } + if (!this.getClass().equals(obj.getClass())) { + return false; + } final Pair t = (Pair) obj; diff --git a/src/mightypork/gamecore/util/objects/VarargsParser.java b/src/mightypork/gamecore/util/objects/VarargsParser.java index 2ca0809..c5fb12f 100644 --- a/src/mightypork/gamecore/util/objects/VarargsParser.java +++ b/src/mightypork/gamecore/util/objects/VarargsParser.java @@ -34,7 +34,9 @@ public class VarargsParser { { final LinkedHashMap attrs = new LinkedHashMap<>(); - if (args.length % 2 != 0) { throw new IllegalArgumentException("Odd number of elements in varargs map!"); } + if (args.length % 2 != 0) { + throw new IllegalArgumentException("Odd number of elements in varargs map!"); + } K key = null; for (final Object o : args) { diff --git a/src/mightypork/rogue/Res.java b/src/mightypork/rogue/Res.java index 6d07161..c87f2ff 100644 --- a/src/mightypork/rogue/Res.java +++ b/src/mightypork/rogue/Res.java @@ -86,7 +86,7 @@ public final class Res { textures.addSheet("tile.brick.floor", tiles.makeSheet(0, 1, 5, 1)); textures.addSheet("tile.brick.wall", tiles.makeSheet(0, 0, 8, 1)); - + textures.addSheet("tile.brick.door.locked", tiles.makeSheet(1, 2, 1, 1));//TODO unique tx textures.addSheet("tile.brick.door.closed", tiles.makeSheet(1, 2, 1, 1)); textures.addSheet("tile.brick.door.open", tiles.makeSheet(2, 2, 1, 1)); diff --git a/src/mightypork/rogue/screens/game/WorldLayer.java b/src/mightypork/rogue/screens/game/WorldLayer.java index 5bfd500..35af5aa 100644 --- a/src/mightypork/rogue/screens/game/WorldLayer.java +++ b/src/mightypork/rogue/screens/game/WorldLayer.java @@ -5,10 +5,8 @@ import mightypork.gamecore.gui.screens.Screen; import mightypork.gamecore.gui.screens.ScreenLayer; import mightypork.gamecore.util.math.constraints.num.Num; import mightypork.rogue.world.gui.MapView; -import mightypork.rogue.world.gui.interaction.MIPClickPathfWalk; -import mightypork.rogue.world.gui.interaction.MIPKeyWalk; -import mightypork.rogue.world.gui.interaction.MIPMouseWalk; -import mightypork.rogue.world.gui.interaction.MIPTileClick; +import mightypork.rogue.world.gui.interaction.MIPKeyboard; +import mightypork.rogue.world.gui.interaction.MIPMouse; public class WorldLayer extends ScreenLayer { @@ -25,10 +23,8 @@ public class WorldLayer extends ScreenLayer { worldView = new MapView(); // map input plugins - worldView.addPlugin(new MIPKeyWalk()); - worldView.addPlugin(new MIPTileClick()); - worldView.addPlugin(new MIPClickPathfWalk()); - worldView.addPlugin(new MIPMouseWalk()); + worldView.addPlugin(new MIPKeyboard()); + worldView.addPlugin(new MIPMouse()); // size of lower navbar final Num lownav = root.width().min(root.height()).max(700).perc(7); diff --git a/src/mightypork/rogue/world/PlayerControl.java b/src/mightypork/rogue/world/PlayerControl.java index 6550d4d..c0174af 100644 --- a/src/mightypork/rogue/world/PlayerControl.java +++ b/src/mightypork/rogue/world/PlayerControl.java @@ -103,14 +103,16 @@ public abstract class PlayerControl { return getLevel().getTile(getCoord().add(side)).isWalkable(); } + public boolean clickTile(Step side) { return clickTile(getCoord().add(side)); } + public boolean clickTile(Coord pos) { - if(pos.dist(getCoord()) > 8) return false; // too far + if (pos.dist(getCoord()) > 8) return false; // too far return getLevel().getTile(pos).onClick(); } @@ -121,4 +123,12 @@ public abstract class PlayerControl { getPlayerEntity().pos.cancelPath(); getPlayerEntity().pos.addStep(side); } + + + public boolean tryGo(Step e) + { + if (!canGo(e)) return false; + go(e); + return true; + } } diff --git a/src/mightypork/rogue/world/World.java b/src/mightypork/rogue/world/World.java index 3330807..e82fbbc 100644 --- a/src/mightypork/rogue/world/World.java +++ b/src/mightypork/rogue/world/World.java @@ -9,7 +9,6 @@ import mightypork.gamecore.util.ion.IonBundle; import mightypork.gamecore.util.ion.IonObjBundled; import mightypork.rogue.world.entity.Entities; import mightypork.rogue.world.entity.Entity; -import mightypork.rogue.world.entity.EntityModel; import mightypork.rogue.world.level.Level; @@ -95,9 +94,12 @@ public class World implements IonObjBundled, Updateable { return eid++; } + public void createPlayer(int level) { - if (playerInfo.isInitialized()) { throw new RuntimeException("Player already created."); } + if (playerInfo.isInitialized()) { + throw new RuntimeException("Player already created."); + } // make entity final int playerEid = getNewEID(); diff --git a/src/mightypork/rogue/world/WorldProvider.java b/src/mightypork/rogue/world/WorldProvider.java index 4dbef6d..ea6cba4 100644 --- a/src/mightypork/rogue/world/WorldProvider.java +++ b/src/mightypork/rogue/world/WorldProvider.java @@ -32,7 +32,9 @@ public class WorldProvider extends RootBusNode { public static WorldProvider get() { - if (inst == null) { throw new IllegalStateException("World provider not initialized."); } + if (inst == null) { + throw new IllegalStateException("World provider not initialized."); + } return inst; } diff --git a/src/mightypork/rogue/world/entity/Entities.java b/src/mightypork/rogue/world/entity/Entities.java index c728bfc..019de4d 100644 --- a/src/mightypork/rogue/world/entity/Entities.java +++ b/src/mightypork/rogue/world/entity/Entities.java @@ -25,9 +25,13 @@ public final class Entities { public static void register(int id, EntityModel model) { - if (id < 0 || id >= entities.length) { throw new IllegalArgumentException("Entity model ID " + id + " is out of range."); } + if (id < 0 || id >= entities.length) { + throw new IllegalArgumentException("Entity model ID " + id + " is out of range."); + } - if (entities[id] != null) { throw new IllegalArgumentException("Entity model ID " + id + " already in use."); } + if (entities[id] != null) { + throw new IllegalArgumentException("Entity model ID " + id + " already in use."); + } entities[id] = model; } @@ -37,7 +41,9 @@ public final class Entities { { final EntityModel e = entities[id]; - if (e == null) { throw new IllegalArgumentException("No entity model with ID " + id + "."); } + if (e == null) { + throw new IllegalArgumentException("No entity model with ID " + id + "."); + } return e; } diff --git a/src/mightypork/rogue/world/entity/EntityModel.java b/src/mightypork/rogue/world/entity/EntityModel.java index 2119d21..60ffa08 100644 --- a/src/mightypork/rogue/world/entity/EntityModel.java +++ b/src/mightypork/rogue/world/entity/EntityModel.java @@ -28,11 +28,13 @@ public final class EntityModel { this.tileClass = entity; } + public Entity createEntity(World world) { return createEntity(world.getNewEID()); } + public Entity createEntity(int eid) { try { diff --git a/src/mightypork/rogue/world/entity/EntityPathFinder.java b/src/mightypork/rogue/world/entity/EntityPathFinder.java index 9714823..00c6057 100644 --- a/src/mightypork/rogue/world/entity/EntityPathFinder.java +++ b/src/mightypork/rogue/world/entity/EntityPathFinder.java @@ -27,13 +27,15 @@ public class EntityPathFinder extends PathFinder { @Override - public int getCost(Coord from, Coord to) { + public int getCost(Coord from, Coord to) + { return 10; } @Override - public int getMinCost() { + public int getMinCost() + { return 10; } diff --git a/src/mightypork/rogue/world/entity/entities/MonsterAi.java b/src/mightypork/rogue/world/entity/entities/MonsterAi.java index 0ffca59..90c033b 100644 --- a/src/mightypork/rogue/world/entity/entities/MonsterAi.java +++ b/src/mightypork/rogue/world/entity/entities/MonsterAi.java @@ -52,7 +52,7 @@ public class MonsterAi extends EntityModule implements EntityMoveListener { { if (!chasing) return; - Entity prey = getPreyEntity(); + final Entity prey = getPreyEntity(); if (prey == null || prey.isDead()) { //System.out.println("prey dead?"); @@ -178,7 +178,7 @@ public class MonsterAi extends EntityModule implements EntityMoveListener { timerAttack.update(delta); if (chasing && !entity.pos.isMoving()) { - Entity prey = getPreyEntity(); + final Entity prey = getPreyEntity(); if (!isPreyInAttackRange(prey)) { //System.out.println("-upd STEP--"); diff --git a/src/mightypork/rogue/world/entity/entities/PlayerEntity.java b/src/mightypork/rogue/world/entity/entities/PlayerEntity.java index 68b0b1f..d263fc1 100644 --- a/src/mightypork/rogue/world/entity/entities/PlayerEntity.java +++ b/src/mightypork/rogue/world/entity/entities/PlayerEntity.java @@ -3,7 +3,11 @@ package mightypork.rogue.world.entity.entities; import mightypork.gamecore.util.math.algo.Coord; import mightypork.gamecore.util.math.algo.pathfinding.PathFinder; -import mightypork.rogue.world.entity.*; +import mightypork.rogue.world.entity.Entity; +import mightypork.rogue.world.entity.EntityModel; +import mightypork.rogue.world.entity.EntityModule; +import mightypork.rogue.world.entity.EntityPathFinder; +import mightypork.rogue.world.entity.EntityType; import mightypork.rogue.world.entity.modules.EntityMoveListener; import mightypork.rogue.world.entity.renderers.EntityRenderer; import mightypork.rogue.world.entity.renderers.EntityRendererMobLR; @@ -74,12 +78,12 @@ public class PlayerEntity extends Entity { @Override public int getCost(Coord from, Coord to) - { + { if (!getLevel().getTile(pos.getCoord()).isExplored()) { return 1000; } - return super.getCost(from, to); + return super.getCost(from, to); }; }; } diff --git a/src/mightypork/rogue/world/entity/entities/RatEntity.java b/src/mightypork/rogue/world/entity/entities/RatEntity.java index 8a4e050..07a06da 100644 --- a/src/mightypork/rogue/world/entity/entities/RatEntity.java +++ b/src/mightypork/rogue/world/entity/entities/RatEntity.java @@ -2,7 +2,10 @@ package mightypork.rogue.world.entity.entities; import mightypork.gamecore.util.math.algo.pathfinding.PathFinder; -import mightypork.rogue.world.entity.*; +import mightypork.rogue.world.entity.Entity; +import mightypork.rogue.world.entity.EntityModel; +import mightypork.rogue.world.entity.EntityPathFinder; +import mightypork.rogue.world.entity.EntityType; import mightypork.rogue.world.entity.renderers.EntityRenderer; import mightypork.rogue.world.entity.renderers.EntityRendererMobLR; diff --git a/src/mightypork/rogue/world/entity/modules/EntityModuleHealth.java b/src/mightypork/rogue/world/entity/modules/EntityModuleHealth.java index d9ffc36..6ec619f 100644 --- a/src/mightypork/rogue/world/entity/modules/EntityModuleHealth.java +++ b/src/mightypork/rogue/world/entity/modules/EntityModuleHealth.java @@ -94,8 +94,8 @@ public class EntityModuleHealth extends EntityModule { { setHealth(health - attackStrength); } - - + + public void fill() { setHealth(maxHealth); diff --git a/src/mightypork/rogue/world/entity/modules/EntityModulePosition.java b/src/mightypork/rogue/world/entity/modules/EntityModulePosition.java index f45272e..0c5afe9 100644 --- a/src/mightypork/rogue/world/entity/modules/EntityModulePosition.java +++ b/src/mightypork/rogue/world/entity/modules/EntityModulePosition.java @@ -11,7 +11,6 @@ import java.util.Set; import mightypork.gamecore.util.ion.IonBundle; import mightypork.gamecore.util.math.algo.Coord; import mightypork.gamecore.util.math.algo.Step; -import mightypork.gamecore.util.math.algo.pathfinding.PathFinder; import mightypork.gamecore.util.math.constraints.vect.VectConst; import mightypork.rogue.world.entity.Entity; import mightypork.rogue.world.entity.EntityModule; @@ -202,11 +201,17 @@ public class EntityModulePosition extends EntityModule { { return entityPos.getVisualPos(); } - - + + public boolean isMoving() { return walking; } + + public boolean hasPath() + { + return isMoving() || !path.isEmpty(); + } + } diff --git a/src/mightypork/rogue/world/entity/renderers/EntityRenderer.java b/src/mightypork/rogue/world/entity/renderers/EntityRenderer.java index 7dadbf7..b7aeade 100644 --- a/src/mightypork/rogue/world/entity/renderers/EntityRenderer.java +++ b/src/mightypork/rogue/world/entity/renderers/EntityRenderer.java @@ -1,11 +1,10 @@ package mightypork.rogue.world.entity.renderers; -import mightypork.rogue.world.entity.Entity; import mightypork.rogue.world.level.render.MapRenderContext; -public abstract class EntityRenderer { +public abstract class EntityRenderer { public abstract void render(MapRenderContext context); diff --git a/src/mightypork/rogue/world/gen/LevelGenerator.java b/src/mightypork/rogue/world/gen/LevelGenerator.java index 3f66132..392a011 100644 --- a/src/mightypork/rogue/world/gen/LevelGenerator.java +++ b/src/mightypork/rogue/world/gen/LevelGenerator.java @@ -7,7 +7,6 @@ import mightypork.gamecore.util.math.algo.Coord; import mightypork.rogue.world.World; import mightypork.rogue.world.entity.Entities; import mightypork.rogue.world.entity.Entity; -import mightypork.rogue.world.gen.rooms.DeadEndRoom; import mightypork.rogue.world.gen.rooms.Rooms; import mightypork.rogue.world.gen.themes.ThemeBrick; import mightypork.rogue.world.level.Level; @@ -45,16 +44,16 @@ public class LevelGenerator { // TODO tmp // spawn rats - Coord pos = Coord.make(0,0); - for(int i=0; i<1;i++) { // 4+complexity + rand.nextInt(1+complexity) - - Entity e = Entities.RAT.createEntity(world); + final Coord pos = Coord.make(0, 0); + for (int i = 0; i < 1; i++) { // 4+complexity + rand.nextInt(1+complexity) + + final Entity e = Entities.RAT.createEntity(world); - for(int j=0; j<20;j++) { + for (int j = 0; j < 20; j++) { pos.x = rand.nextInt(lvl.getWidth()); pos.y = rand.nextInt(lvl.getHeight()); - if(lvl.addEntity(e, pos)) break; + if (lvl.addEntity(e, pos)) break; } } diff --git a/src/mightypork/rogue/world/gen/MapTheme.java b/src/mightypork/rogue/world/gen/MapTheme.java index 1250397..e3704e1 100644 --- a/src/mightypork/rogue/world/gen/MapTheme.java +++ b/src/mightypork/rogue/world/gen/MapTheme.java @@ -21,7 +21,7 @@ public interface MapTheme { TileModel passage(); - - + + TileModel secretDoor(); } diff --git a/src/mightypork/rogue/world/gen/RoomDesc.java b/src/mightypork/rogue/world/gen/RoomDesc.java index 4d2f622..e3dc346 100644 --- a/src/mightypork/rogue/world/gen/RoomDesc.java +++ b/src/mightypork/rogue/world/gen/RoomDesc.java @@ -30,7 +30,9 @@ public class RoomDesc { int rw = amax.x - amin.x; int rh = amax.y - amin.y; - if (rw <= 0 || rh <= 0 || tw <= 0 || th <= 0) { return false; } + if (rw <= 0 || rh <= 0 || tw <= 0 || th <= 0) { + return false; + } final int tx = min.x; final int ty = min.y; diff --git a/src/mightypork/rogue/world/gen/ScratchMap.java b/src/mightypork/rogue/world/gen/ScratchMap.java index ea17080..e657dae 100644 --- a/src/mightypork/rogue/world/gen/ScratchMap.java +++ b/src/mightypork/rogue/world/gen/ScratchMap.java @@ -41,8 +41,8 @@ public class ScratchMap { @Override public boolean isAccessible(Coord pos) { - if(!isIn(pos)) return false; - Tile t = get(pos); + if (!isIn(pos)) return false; + final Tile t = get(pos); return t.isPotentiallyWalkable() || (t.genData.protection != TileProtectLevel.STRONG); } @@ -189,7 +189,9 @@ public class ScratchMap { public Tile get(Coord pos) { - if (!isIn(pos)) { throw new IndexOutOfBoundsException("Tile not in map: " + pos); } + if (!isIn(pos)) { + throw new IndexOutOfBoundsException("Tile not in map: " + pos); + } return map[pos.y][pos.x]; } @@ -203,7 +205,9 @@ public class ScratchMap { public boolean set(Coord pos, Tile tile) { - if (!isIn(pos)) { throw new IndexOutOfBoundsException("Tile not in map: " + pos); } + if (!isIn(pos)) { + throw new IndexOutOfBoundsException("Tile not in map: " + pos); + } map[pos.y][pos.x] = tile; return true; diff --git a/src/mightypork/rogue/world/gen/rooms/AbstractRectRoom.java b/src/mightypork/rogue/world/gen/rooms/AbstractRectRoom.java index af81b42..534af06 100644 --- a/src/mightypork/rogue/world/gen/rooms/AbstractRectRoom.java +++ b/src/mightypork/rogue/world/gen/rooms/AbstractRectRoom.java @@ -21,15 +21,15 @@ public abstract class AbstractRectRoom implements RoomBuilder { { // half width, half height actually final Coord innerSize = getInnerSize(rand); - final int width = 2+innerSize.x; - final int height = 2+innerSize.y; + final int width = 2 + innerSize.x; + final int height = 2 + innerSize.y; - int wLow = width/2; - int wHigh = width - wLow; - int hLow = height/2; - int hHigh = height - hLow; + final int wLow = width / 2; + final int wHigh = width - wLow; + final int hLow = height / 2; + final int hHigh = height - hLow; - final Coord min = new Coord(center.x-wLow, center.y-hLow); + final Coord min = new Coord(center.x - wLow, center.y - hLow); final Coord max = new Coord(center.x + wHigh, center.y + hHigh); if (!map.isClear(min.add(-1, -1), max)) return null; @@ -48,8 +48,8 @@ public abstract class AbstractRectRoom implements RoomBuilder { protected void placeDoors(ScratchMap map, MapTheme theme, Random rand, Coord min, Coord max) { - int width = max.x - min.x; - int height = max.y - min.y; + final int width = max.x - min.x; + final int height = max.y - min.y; for (int i = 0, j = 0; i <= getDoorCount(rand) && j < 100; j++) { // j is to prevent inf loop final Coord door = min.copy(); diff --git a/src/mightypork/rogue/world/gui/MapView.java b/src/mightypork/rogue/world/gui/MapView.java index c5216ad..1ae116c 100644 --- a/src/mightypork/rogue/world/gui/MapView.java +++ b/src/mightypork/rogue/world/gui/MapView.java @@ -1,7 +1,6 @@ package mightypork.rogue.world.gui; -import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Set; @@ -22,7 +21,6 @@ import mightypork.rogue.world.WorldProvider; import mightypork.rogue.world.WorldRenderer; import mightypork.rogue.world.entity.modules.EntityMoveListener; import mightypork.rogue.world.gui.interaction.MapInteractionPlugin; -import mightypork.rogue.world.tile.Tile; /** @@ -73,7 +71,7 @@ public class MapView extends InputComponent implements KeyListener, MouseButtonL public void onStepFinished() { for (final MapInteractionPlugin p : plugins) { - if(p.onStepEnd(this, pc)) break; + if (p.onStepEnd(this, pc)) break; } } @@ -82,7 +80,7 @@ public class MapView extends InputComponent implements KeyListener, MouseButtonL public void onPathFinished() { for (final MapInteractionPlugin p : plugins) { - if(p.onStepEnd(this, pc)) break; + if (p.onStepEnd(this, pc)) break; } } @@ -91,7 +89,7 @@ public class MapView extends InputComponent implements KeyListener, MouseButtonL public void onPathInterrupted() { for (final MapInteractionPlugin p : plugins) { - if(p.onStepEnd(this, pc)) break; + if (p.onStepEnd(this, pc)) break; } } @@ -102,7 +100,7 @@ public class MapView extends InputComponent implements KeyListener, MouseButtonL if (!event.isOver(this)) return; for (final MapInteractionPlugin p : plugins) { - if(p.onClick(this, pc, event.getPos(), event.getButton(), event.isDown())) { + if (p.onClick(this, pc, event.getPos(), event.getButton(), event.isDown())) { event.consume(); break; } @@ -114,7 +112,7 @@ public class MapView extends InputComponent implements KeyListener, MouseButtonL public void receive(KeyEvent event) { for (final MapInteractionPlugin p : plugins) { - if(p.onKey(this, pc, event.getKey(), event.isDown())) break; + if (p.onKey(this, pc, event.getKey(), event.isDown())) break; } if (event.getKey() == Keys.Z) { diff --git a/src/mightypork/rogue/world/gui/interaction/MIPClickPathfWalk.java b/src/mightypork/rogue/world/gui/interaction/MIPClickPathfWalk.java deleted file mode 100644 index 99ace0f..0000000 --- a/src/mightypork/rogue/world/gui/interaction/MIPClickPathfWalk.java +++ /dev/null @@ -1,62 +0,0 @@ -package mightypork.rogue.world.gui.interaction; - - -import mightypork.gamecore.input.InputSystem; -import mightypork.gamecore.util.math.algo.Coord; -import mightypork.gamecore.util.math.constraints.vect.Vect; -import mightypork.rogue.world.PlayerControl; -import mightypork.rogue.world.gui.MapView; -import mightypork.rogue.world.tile.Tile; - - -public class MIPClickPathfWalk implements MapInteractionPlugin { - - private static final int BTN = 0; // left - - - @Override - public void update(MapView view, PlayerControl pc, double delta) - { - if(pc.getPlayerEntity().pos.isMoving()) return; - if (InputSystem.isMouseButtonDown(BTN)) { - - troToNav(view, pc, InputSystem.getMousePos()); - } - } - - - @Override - public boolean onClick(MapView view, PlayerControl player, Vect mouse, int button, boolean down) - { - if (down || button != BTN) return false; - - return troToNav(view, player, mouse); - } - - - private boolean troToNav(MapView view, PlayerControl player, Vect mouse) - { - final Coord clicked = view.toWorldPos(mouse); - - Tile t = player.getLevel().getTile(clicked); - if (!t.isWalkable() || !t.isExplored()) return false; - - player.navigateTo(clicked); - return true; - } - - - @Override - public boolean onKey(MapView view, PlayerControl player, int key, boolean down) - { - return false; - } - - - @Override - public boolean onStepEnd(MapView mapView, PlayerControl player) - { - return false; - } - -} diff --git a/src/mightypork/rogue/world/gui/interaction/MIPKeyWalk.java b/src/mightypork/rogue/world/gui/interaction/MIPKeyboard.java similarity index 87% rename from src/mightypork/rogue/world/gui/interaction/MIPKeyWalk.java rename to src/mightypork/rogue/world/gui/interaction/MIPKeyboard.java index f4d429d..6a40e32 100644 --- a/src/mightypork/rogue/world/gui/interaction/MIPKeyWalk.java +++ b/src/mightypork/rogue/world/gui/interaction/MIPKeyboard.java @@ -10,7 +10,7 @@ import mightypork.rogue.world.PlayerControl; import mightypork.rogue.world.gui.MapView; -public class MIPKeyWalk implements MapInteractionPlugin { +public class MIPKeyboard implements MapInteractionPlugin { private static final int[] keys = { Keys.LEFT, Keys.RIGHT, Keys.UP, Keys.DOWN }; private static final Step[] sides = { Sides.W, Sides.E, Sides.N, Sides.S }; @@ -33,7 +33,7 @@ public class MIPKeyWalk implements MapInteractionPlugin { @Override public boolean onKey(MapView view, PlayerControl player, int key, boolean down) { - if(down) return false; // not interested + if (down) return false; // not interested for (int i = 0; i < 4; i++) { if (key == keys[i]) { @@ -47,12 +47,12 @@ public class MIPKeyWalk implements MapInteractionPlugin { private boolean walkByKey(PlayerControl pc) { - if(pc.getPlayerEntity().pos.isMoving()) return false; + if (pc.getPlayerEntity().pos.isMoving()) return false; for (int i = 0; i < 4; i++) { if (InputSystem.isKeyDown(keys[i])) { - Step side = sides[i]; + final Step side = sides[i]; if (pc.canGo(side)) { pc.go(side); return true; diff --git a/src/mightypork/rogue/world/gui/interaction/MIPMouse.java b/src/mightypork/rogue/world/gui/interaction/MIPMouse.java new file mode 100644 index 0000000..8a264ce --- /dev/null +++ b/src/mightypork/rogue/world/gui/interaction/MIPMouse.java @@ -0,0 +1,102 @@ +package mightypork.rogue.world.gui.interaction; + + +import mightypork.gamecore.input.InputSystem; +import mightypork.gamecore.util.math.Calc.Deg; +import mightypork.gamecore.util.math.Polar; +import mightypork.gamecore.util.math.algo.Coord; +import mightypork.gamecore.util.math.algo.Sides; +import mightypork.gamecore.util.math.constraints.vect.Vect; +import mightypork.rogue.world.PlayerControl; +import mightypork.rogue.world.gui.MapView; +import mightypork.rogue.world.tile.Tile; + + +public class MIPMouse implements MapInteractionPlugin { + + private static final int BTN = 0; // left + + + @Override + public void update(MapView view, PlayerControl pc, double delta) + { + if (pc.getPlayerEntity().pos.hasPath()) return; + + final Vect pos = InputSystem.getMousePos(); + + if (InputSystem.isMouseButtonDown(BTN)) { + if (mouseWalk(view, pc, pos)) return; + if (troToNav(view, pc, pos)) return; + } + } + + + @Override + public boolean onClick(MapView view, PlayerControl pc, Vect mouse, int button, boolean down) + { + if (!down && button == BTN) { + + final Coord pos = view.toWorldPos(mouse); + final Tile t = pc.getLevel().getTile(pos); + if (t.onClick()) return true; + + if (troToNav(view, pc, mouse)) return true; + } + + return false; + } + + + private boolean troToNav(MapView view, PlayerControl pc, Vect mouse) + { + final Coord clicked = view.toWorldPos(mouse); + + final Tile t = pc.getLevel().getTile(clicked); + if (!t.isWalkable() || !t.isExplored()) return false; + + pc.navigateTo(clicked); + return true; + } + + + private boolean mouseWalk(MapView view, PlayerControl pc, Vect pos) + { + final Coord plpos = pc.getCoord(); + final Coord clicked = view.toWorldPos(pos); + + final Polar p = Polar.fromCoord(clicked.x - plpos.x, clicked.y - plpos.y); + + final int dir = Deg.round90(p.getAngleDeg()) / 90; + + switch (dir) { + case 0: + return pc.tryGo(Sides.E); + + case 1: + return pc.tryGo(Sides.S); + + case 2: + return pc.tryGo(Sides.W); + + case 3: + return pc.tryGo(Sides.N); + } + + return false; + } + + + @Override + public boolean onKey(MapView view, PlayerControl player, int key, boolean down) + { + return false; + } + + + @Override + public boolean onStepEnd(MapView mapView, PlayerControl player) + { + return false; + } + +} diff --git a/src/mightypork/rogue/world/gui/interaction/MIPMouseWalk.java b/src/mightypork/rogue/world/gui/interaction/MIPMouseWalk.java deleted file mode 100644 index 4ffd69f..0000000 --- a/src/mightypork/rogue/world/gui/interaction/MIPMouseWalk.java +++ /dev/null @@ -1,83 +0,0 @@ -package mightypork.rogue.world.gui.interaction; - - -import mightypork.gamecore.input.InputSystem; -import mightypork.gamecore.util.math.Calc.Deg; -import mightypork.gamecore.util.math.Polar; -import mightypork.gamecore.util.math.algo.Coord; -import mightypork.gamecore.util.math.constraints.vect.Vect; -import mightypork.rogue.world.PlayerControl; -import mightypork.rogue.world.gui.MapView; -import mightypork.rogue.world.tile.Tile; - - -public class MIPMouseWalk implements MapInteractionPlugin { - - @Override - public void update(MapView view, PlayerControl pc, double delta) - { - if (InputSystem.isMouseButtonDown(0)) { - // walk by holding btn - tryWalk(view, pc, InputSystem.getMousePos()); - } - } - - - @Override - public boolean onClick(MapView view, PlayerControl pc, Vect mouse, int button, boolean down) - { - if (!down || button != 0) return false; - - tryWalk(view, pc, mouse); - return true; - } - - - private void tryWalk(MapView view, PlayerControl pc, Vect pos) - { - if (pc.getPlayerEntity().pos.isMoving()) return; - - final Coord plpos = pc.getCoord(); - final Coord clicked = view.toWorldPos(pos); - - final Polar p = Polar.fromCoord(clicked.x - plpos.x, clicked.y - plpos.y); - - final int dir = Deg.round90(p.getAngleDeg()) / 90; - - switch (dir) { - case 0: - pc.goEast(); - break; - - case 1: - pc.goSouth(); - break; - - case 2: - pc.goWest(); - break; - - case 3: - pc.goNorth(); - break; - } - } - - - @Override - public boolean onKey(MapView world, PlayerControl player, int key, boolean down) - { - return false; - } - - - @Override - public boolean onStepEnd(MapView view, PlayerControl pc) - { - if(!InputSystem.isMouseButtonDown(0)) return false; - - tryWalk(view, pc, InputSystem.getMousePos()); - return true; - } - -} diff --git a/src/mightypork/rogue/world/gui/interaction/MIPTileClick.java b/src/mightypork/rogue/world/gui/interaction/MIPTileClick.java deleted file mode 100644 index 3396566..0000000 --- a/src/mightypork/rogue/world/gui/interaction/MIPTileClick.java +++ /dev/null @@ -1,44 +0,0 @@ -package mightypork.rogue.world.gui.interaction; - - -import mightypork.gamecore.util.math.algo.Coord; -import mightypork.gamecore.util.math.constraints.vect.Vect; -import mightypork.rogue.world.PlayerControl; -import mightypork.rogue.world.WorldProvider; -import mightypork.rogue.world.gui.MapView; - - -public class MIPTileClick implements MapInteractionPlugin { - - @Override - public boolean onStepEnd(MapView wv, PlayerControl player) - { - return false; - } - - - @Override - public boolean onClick(MapView wv, PlayerControl player, Vect mouse, int button, boolean down) - { - if (!down && button == 0) { - Coord pos = wv.toWorldPos(mouse); - player.clickTile(pos); - System.out.println("~"); - return true; - } - - return false; - } - - - @Override - public boolean onKey(MapView wv, PlayerControl player, int key, boolean down) - { - return false; - } - - @Override - public void update(MapView mapView, PlayerControl pc, double delta) - { - } -} diff --git a/src/mightypork/rogue/world/gui/interaction/MapInteractionPlugin.java b/src/mightypork/rogue/world/gui/interaction/MapInteractionPlugin.java index 2f01df9..041d290 100644 --- a/src/mightypork/rogue/world/gui/interaction/MapInteractionPlugin.java +++ b/src/mightypork/rogue/world/gui/interaction/MapInteractionPlugin.java @@ -15,8 +15,8 @@ public interface MapInteractionPlugin { boolean onKey(MapView mapView, PlayerControl player, int key, boolean down); - - - void update(MapView mapView, PlayerControl pc, double delta); + + + void update(MapView mapView, PlayerControl pc, double delta); } diff --git a/src/mightypork/rogue/world/level/Level.java b/src/mightypork/rogue/world/level/Level.java index f7f74eb..56f56c8 100644 --- a/src/mightypork/rogue/world/level/Level.java +++ b/src/mightypork/rogue/world/level/Level.java @@ -243,13 +243,14 @@ public class Level implements MapAccess, IonObjBinary { /** * Try to add entity at given pos + * * @param entity the entity * @param pos pos * @return true if added (false if void, wall etc) */ public boolean addEntity(Entity entity, Coord pos) { - Tile t = getTile(pos); + final Tile t = getTile(pos); if (!t.isWalkable()) return false; addEntity(entity); diff --git a/src/mightypork/rogue/world/tile/Tile.java b/src/mightypork/rogue/world/tile/Tile.java index f811583..c18e929 100644 --- a/src/mightypork/rogue/world/tile/Tile.java +++ b/src/mightypork/rogue/world/tile/Tile.java @@ -49,7 +49,7 @@ public abstract class Tile implements IonObjBlob { { if (!isExplored()) return; - TileRenderer r = getRenderer(); + final TileRenderer r = getRenderer(); if (r == null) { Log.e("Tile with no renderer: " + Log.str(this)); return; diff --git a/src/mightypork/rogue/world/tile/TileGenData.java b/src/mightypork/rogue/world/tile/TileGenData.java index a990dc9..1270596 100644 --- a/src/mightypork/rogue/world/tile/TileGenData.java +++ b/src/mightypork/rogue/world/tile/TileGenData.java @@ -1,5 +1,6 @@ package mightypork.rogue.world.tile; + import mightypork.rogue.world.gen.TileProtectLevel; diff --git a/src/mightypork/rogue/world/tile/TileModel.java b/src/mightypork/rogue/world/tile/TileModel.java index a593914..8821f48 100644 --- a/src/mightypork/rogue/world/tile/TileModel.java +++ b/src/mightypork/rogue/world/tile/TileModel.java @@ -8,7 +8,7 @@ import mightypork.gamecore.util.ion.IonOutput; /** - * Tile model (logic of a tile) + * Tile model (builder) * * @author MightyPork */ diff --git a/src/mightypork/rogue/world/tile/TileRenderer.java b/src/mightypork/rogue/world/tile/TileRenderer.java index 96c401a..eabd571 100644 --- a/src/mightypork/rogue/world/tile/TileRenderer.java +++ b/src/mightypork/rogue/world/tile/TileRenderer.java @@ -22,20 +22,23 @@ public abstract class TileRenderer implements Updateable { private static TxQuad SH_N, SH_S, SH_E, SH_W, SH_NW, SH_NE, SH_SW, SH_SE; private static TxQuad UFOG_N, UFOG_S, UFOG_E, UFOG_W, UFOG_NW, UFOG_NE, UFOG_SW, UFOG_SE; - + private static boolean inited; // data - + public byte shadows; public boolean shadowsComputed; - + protected final Tile tile; - protected Tile getTile() { + + protected Tile getTile() + { return tile; } + public TileRenderer(Tile tile) { this.tile = tile; @@ -66,7 +69,7 @@ public abstract class TileRenderer implements Updateable { public void renderShadows(TileRenderContext context) - { + { if (!shadowsComputed) { // no shadows computed yet @@ -126,6 +129,7 @@ public abstract class TileRenderer implements Updateable { if ((ufog & Sides.SE_CORNER) == Sides.MASK_SE) Render.quadTextured(rect, UFOG_SE); } + @Override public void update(double delta) { diff --git a/src/mightypork/rogue/world/tile/Tiles.java b/src/mightypork/rogue/world/tile/Tiles.java index cf06a2c..a373cfe 100644 --- a/src/mightypork/rogue/world/tile/Tiles.java +++ b/src/mightypork/rogue/world/tile/Tiles.java @@ -5,10 +5,7 @@ import java.io.IOException; import mightypork.gamecore.util.ion.IonInput; import mightypork.gamecore.util.ion.IonOutput; -import mightypork.rogue.world.tile.renderers.BasicTileRenderer; -import mightypork.rogue.world.tile.renderers.DoorTileRenderer; -import mightypork.rogue.world.tile.renderers.NullTileRenderer; -import mightypork.rogue.world.tile.tiles.*; +import mightypork.rogue.world.tile.tiles.NullTile; import mightypork.rogue.world.tile.tiles.brick.TileBrickDoor; import mightypork.rogue.world.tile.tiles.brick.TileBrickFloor; import mightypork.rogue.world.tile.tiles.brick.TileBrickPassage; @@ -36,9 +33,13 @@ public final class Tiles { public static void register(int id, TileModel model) { - if (id < 0 || id >= tiles.length) { throw new IllegalArgumentException("Tile ID " + id + " is out of range."); } + if (id < 0 || id >= tiles.length) { + throw new IllegalArgumentException("Tile ID " + id + " is out of range."); + } - if (tiles[id] != null) { throw new IllegalArgumentException("Tile ID " + id + " already in use."); } + if (tiles[id] != null) { + throw new IllegalArgumentException("Tile ID " + id + " already in use."); + } tiles[id] = model; } @@ -48,7 +49,9 @@ public final class Tiles { { final TileModel m = tiles[id]; - if (m == null) { throw new IllegalArgumentException("No tile with ID " + id + "."); } + if (m == null) { + throw new IllegalArgumentException("No tile with ID " + id + "."); + } return m; } diff --git a/src/mightypork/rogue/world/tile/renderers/DoorTileRenderer.java b/src/mightypork/rogue/world/tile/renderers/DoorTileRenderer.java index 10ed24b..5babd0e 100644 --- a/src/mightypork/rogue/world/tile/renderers/DoorTileRenderer.java +++ b/src/mightypork/rogue/world/tile/renderers/DoorTileRenderer.java @@ -5,9 +5,7 @@ import mightypork.gamecore.render.Render; import mightypork.gamecore.resources.textures.TxSheet; import mightypork.gamecore.util.math.constraints.rect.Rect; import mightypork.gamecore.util.math.timing.TimedTask; -import mightypork.rogue.Res; import mightypork.rogue.world.level.render.TileRenderContext; -import mightypork.rogue.world.tile.Tile; import mightypork.rogue.world.tile.TileRenderer; import mightypork.rogue.world.tile.tiles.TileBaseDoor; @@ -25,7 +23,6 @@ public class DoorTileRenderer extends TileRenderer { @Override public void run() { - System.out.println("CLOSEDOOR + "+ ((TileBaseDoor) tile).isOpen()); visuallyOpen = ((TileBaseDoor) tile).isOpen(); } }; @@ -49,13 +46,13 @@ public class DoorTileRenderer extends TileRenderer { if (!visuallyOpen && ((TileBaseDoor) tile).isOpen()) visuallyOpen = true; if (visuallyOpen && !((TileBaseDoor) tile).isOpen()) { - if(!closeTask.isRunning()) closeTask.start(0.4); + if (!closeTask.isRunning()) closeTask.start(0.4); } - if (visuallyOpen) { + if (visuallyOpen) { Render.quadTextured(rect, open.getRandomQuad(context.getTileNoise())); } else { - TxSheet sheet = (((TileBaseDoor) tile).isLocked() ? locked : closed); + final TxSheet sheet = (((TileBaseDoor) tile).isLocked() ? locked : closed); Render.quadTextured(rect, sheet.getRandomQuad(context.getTileNoise())); } } diff --git a/src/mightypork/rogue/world/tile/renderers/NullTileRenderer.java b/src/mightypork/rogue/world/tile/renderers/NullTileRenderer.java index f53ed4f..bf7fe60 100644 --- a/src/mightypork/rogue/world/tile/renderers/NullTileRenderer.java +++ b/src/mightypork/rogue/world/tile/renderers/NullTileRenderer.java @@ -2,7 +2,6 @@ package mightypork.rogue.world.tile.renderers; import mightypork.rogue.world.level.render.TileRenderContext; -import mightypork.rogue.world.tile.Tile; import mightypork.rogue.world.tile.TileRenderer; diff --git a/src/mightypork/rogue/world/tile/tiles/NullTile.java b/src/mightypork/rogue/world/tile/tiles/NullTile.java index e1d5678..d17d6e7 100644 --- a/src/mightypork/rogue/world/tile/tiles/NullTile.java +++ b/src/mightypork/rogue/world/tile/tiles/NullTile.java @@ -17,6 +17,7 @@ public class NullTile extends Tile { super(model); } + @Override protected TileRenderer getRenderer() { diff --git a/src/mightypork/rogue/world/tile/tiles/TileBaseFloor.java b/src/mightypork/rogue/world/tile/tiles/TileBaseFloor.java index 73b7dfa..f7d74c4 100644 --- a/src/mightypork/rogue/world/tile/tiles/TileBaseFloor.java +++ b/src/mightypork/rogue/world/tile/tiles/TileBaseFloor.java @@ -10,15 +10,16 @@ import mightypork.rogue.world.tile.renderers.BasicTileRenderer; public abstract class TileBaseFloor extends TileWalkable { - private BasicTileRenderer renderer; - - + private final BasicTileRenderer renderer; + + public TileBaseFloor(TileModel model, TxSheet sheet) { super(model); this.renderer = new BasicTileRenderer(this, sheet); } + @Override protected TileRenderer getRenderer() { diff --git a/src/mightypork/rogue/world/tile/tiles/TileBasePassage.java b/src/mightypork/rogue/world/tile/tiles/TileBasePassage.java index 260df13..04a863e 100644 --- a/src/mightypork/rogue/world/tile/tiles/TileBasePassage.java +++ b/src/mightypork/rogue/world/tile/tiles/TileBasePassage.java @@ -15,7 +15,7 @@ import mightypork.rogue.world.tile.renderers.BasicTileRenderer; */ public abstract class TileBasePassage extends TileSolid { - private BasicTileRenderer renderer; + private final BasicTileRenderer renderer; public TileBasePassage(TileModel model, TxSheet sheet) diff --git a/src/mightypork/rogue/world/tile/tiles/TileBaseSecretDoor.java b/src/mightypork/rogue/world/tile/tiles/TileBaseSecretDoor.java index ac27242..ebfaa4d 100644 --- a/src/mightypork/rogue/world/tile/tiles/TileBaseSecretDoor.java +++ b/src/mightypork/rogue/world/tile/tiles/TileBaseSecretDoor.java @@ -8,12 +8,8 @@ import mightypork.gamecore.util.ion.IonInput; import mightypork.gamecore.util.ion.IonOutput; import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.color.pal.RGB; -import mightypork.gamecore.util.math.timing.TimedTask; -import mightypork.rogue.world.level.Level; import mightypork.rogue.world.tile.TileModel; -import mightypork.rogue.world.tile.TileRenderer; import mightypork.rogue.world.tile.TileType; -import mightypork.rogue.world.tile.renderers.DoorTileRenderer; public abstract class TileBaseSecretDoor extends TileBaseDoor { diff --git a/src/mightypork/rogue/world/tile/tiles/TileBaseWall.java b/src/mightypork/rogue/world/tile/tiles/TileBaseWall.java index 78a9894..46c16b0 100644 --- a/src/mightypork/rogue/world/tile/tiles/TileBaseWall.java +++ b/src/mightypork/rogue/world/tile/tiles/TileBaseWall.java @@ -2,16 +2,14 @@ package mightypork.rogue.world.tile.tiles; import mightypork.gamecore.resources.textures.TxSheet; -import mightypork.rogue.world.level.render.TileRenderContext; import mightypork.rogue.world.tile.TileModel; -import mightypork.rogue.world.tile.TileRenderer; import mightypork.rogue.world.tile.TileType; import mightypork.rogue.world.tile.renderers.BasicTileRenderer; public abstract class TileBaseWall extends TileSolid { - private BasicTileRenderer renderer; + private final BasicTileRenderer renderer; public TileBaseWall(TileModel model, TxSheet sheet) @@ -21,6 +19,7 @@ public abstract class TileBaseWall extends TileSolid { } + @Override public BasicTileRenderer getRenderer() { return renderer; diff --git a/src/mightypork/rogue/world/tile/tiles/TileSolid.java b/src/mightypork/rogue/world/tile/tiles/TileSolid.java index 7c18047..2b543f7 100644 --- a/src/mightypork/rogue/world/tile/tiles/TileSolid.java +++ b/src/mightypork/rogue/world/tile/tiles/TileSolid.java @@ -4,7 +4,6 @@ package mightypork.rogue.world.tile.tiles; import mightypork.rogue.world.item.Item; import mightypork.rogue.world.tile.Tile; import mightypork.rogue.world.tile.TileModel; -import mightypork.rogue.world.tile.TileRenderer; public abstract class TileSolid extends Tile { diff --git a/src/mightypork/rogue/world/tile/tiles/TileWalkable.java b/src/mightypork/rogue/world/tile/tiles/TileWalkable.java index 4488b35..10ca5a6 100644 --- a/src/mightypork/rogue/world/tile/tiles/TileWalkable.java +++ b/src/mightypork/rogue/world/tile/tiles/TileWalkable.java @@ -12,7 +12,6 @@ import mightypork.rogue.world.level.render.TileRenderContext; import mightypork.rogue.world.tile.DroppedItemRenderer; import mightypork.rogue.world.tile.Tile; import mightypork.rogue.world.tile.TileModel; -import mightypork.rogue.world.tile.TileRenderer; public abstract class TileWalkable extends Tile { diff --git a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickDoor.java b/src/mightypork/rogue/world/tile/tiles/brick/TileBrickDoor.java index 0ed365c..7dd6d07 100644 --- a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickDoor.java +++ b/src/mightypork/rogue/world/tile/tiles/brick/TileBrickDoor.java @@ -1,12 +1,13 @@ package mightypork.rogue.world.tile.tiles.brick; + import mightypork.rogue.Res; import mightypork.rogue.world.tile.TileModel; import mightypork.rogue.world.tile.tiles.TileBaseDoor; public class TileBrickDoor extends TileBaseDoor { - + public TileBrickDoor(TileModel model) { //@formatter:off diff --git a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickFloor.java b/src/mightypork/rogue/world/tile/tiles/brick/TileBrickFloor.java index ac42a19..4368f19 100644 --- a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickFloor.java +++ b/src/mightypork/rogue/world/tile/tiles/brick/TileBrickFloor.java @@ -1,13 +1,13 @@ package mightypork.rogue.world.tile.tiles.brick; -import mightypork.gamecore.resources.textures.TxSheet; + import mightypork.rogue.Res; import mightypork.rogue.world.tile.TileModel; import mightypork.rogue.world.tile.tiles.TileBaseFloor; public class TileBrickFloor extends TileBaseFloor { - + public TileBrickFloor(TileModel model) { super(model, Res.sheet("tile.brick.floor")); diff --git a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickPassage.java b/src/mightypork/rogue/world/tile/tiles/brick/TileBrickPassage.java index f7949c5..f0f5029 100644 --- a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickPassage.java +++ b/src/mightypork/rogue/world/tile/tiles/brick/TileBrickPassage.java @@ -3,7 +3,6 @@ package mightypork.rogue.world.tile.tiles.brick; import mightypork.rogue.Res; import mightypork.rogue.world.tile.TileModel; -import mightypork.rogue.world.tile.tiles.TileBaseDoor; import mightypork.rogue.world.tile.tiles.TileBasePassage; diff --git a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickSecretDoor.java b/src/mightypork/rogue/world/tile/tiles/brick/TileBrickSecretDoor.java index 7e33524..ee32310 100644 --- a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickSecretDoor.java +++ b/src/mightypork/rogue/world/tile/tiles/brick/TileBrickSecretDoor.java @@ -1,15 +1,13 @@ package mightypork.rogue.world.tile.tiles.brick; -import mightypork.gamecore.util.math.color.Color; -import mightypork.gamecore.util.math.color.pal.RGB; + import mightypork.rogue.Res; import mightypork.rogue.world.tile.TileModel; -import mightypork.rogue.world.tile.tiles.TileBaseDoor; import mightypork.rogue.world.tile.tiles.TileBaseSecretDoor; public class TileBrickSecretDoor extends TileBaseSecretDoor { - + public TileBrickSecretDoor(TileModel model) { //@formatter:off diff --git a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickWall.java b/src/mightypork/rogue/world/tile/tiles/brick/TileBrickWall.java index d8b9ee5..0c751e0 100644 --- a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickWall.java +++ b/src/mightypork/rogue/world/tile/tiles/brick/TileBrickWall.java @@ -1,13 +1,13 @@ package mightypork.rogue.world.tile.tiles.brick; -import mightypork.gamecore.resources.textures.TxSheet; + import mightypork.rogue.Res; import mightypork.rogue.world.tile.TileModel; import mightypork.rogue.world.tile.tiles.TileBaseWall; public class TileBrickWall extends TileBaseWall { - + public TileBrickWall(TileModel model) { super(model, Res.sheet("tile.brick.wall"));