From fa1d2b577bbc788186bb159fd828c83f270987b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Mon, 12 May 2014 20:28:18 +0200 Subject: [PATCH] Refactored some things in world --- .../gamecore/eventbus/EventBus.java | 2 +- .../gamecore/eventbus/EventChannel.java | 6 +- .../eventbus/clients/DelegatingClient.java | 2 +- .../util/math/algo/floodfill/FillContext.java | 31 -- .../util/math/algo/floodfill/FloodFill.java | 38 +- .../rogue/screens/game/InvLayer.java | 4 +- .../rogue/screens/game/InvSlot.java | 2 +- .../rogue/screens/game/ScreenGame.java | 2 +- src/mightypork/rogue/world/PlayerControl.java | 1 - .../{PlayerInfo.java => PlayerData.java} | 21 +- src/mightypork/rogue/world/PlayerFacade.java | 369 ++++++++++++++ src/mightypork/rogue/world/World.java | 453 +----------------- src/mightypork/rogue/world/WorldConsole.java | 80 ++++ src/mightypork/rogue/world/WorldProvider.java | 12 +- .../rogue/world/entity/Entities.java | 8 +- src/mightypork/rogue/world/entity/Entity.java | 23 +- .../rogue/world/entity/EntityModule.java | 2 +- .../entity/{entities => impl}/BossRatAi.java | 2 +- .../entity/{entities => impl}/BrownRatAi.java | 2 +- .../{entities => impl}/EntityBossRat.java | 2 +- .../{entities => impl}/EntityBrownRat.java | 2 +- .../{entities => impl}/EntityGrayRat.java | 2 +- .../entity/{entities => impl}/GrayRatAi.java | 2 +- .../entity/{entities => impl}/MonsterAi.java | 2 +- .../{entities => impl}/PlayerEntity.java | 4 +- .../world/events/PlayerStepEndEvent.java | 2 +- .../world/events/PlayerStepEndListener.java | 2 +- .../rogue/world/gen/LevelGenerator.java | 2 +- .../rogue/world/gen/ScratchMap.java | 4 + .../rogue/world/{ => gen}/WorldCreator.java | 4 +- src/mightypork/rogue/world/gui/Minimap.java | 2 +- .../world/gui/interaction/MIPKeyboard.java | 2 +- .../rogue/world/gui/interaction/MIPMouse.java | 2 +- .../gui/interaction/MapInteractionPlugin.java | 2 +- src/mightypork/rogue/world/item/Item.java | 2 +- src/mightypork/rogue/world/item/Items.java | 18 +- .../item/{items => impl}/ItemBaseFood.java | 2 +- .../item/{items => impl}/ItemBaseWeapon.java | 2 +- .../active/ItemHeartPiece.java | 6 +- .../item/{items => impl}/food/ItemCheese.java | 4 +- .../item/{items => impl}/food/ItemMeat.java | 4 +- .../{items => impl}/food/ItemSandwich.java | 4 +- .../{items => impl}/weapons/ItemBone.java | 4 +- .../{items => impl}/weapons/ItemClub.java | 4 +- .../{items => impl}/weapons/ItemHammer.java | 4 +- .../{items => impl}/weapons/ItemStone.java | 4 +- .../{items => impl}/weapons/ItemSword.java | 4 +- src/mightypork/rogue/world/level/Level.java | 85 ++-- src/mightypork/rogue/world/tile/Tiles.java | 4 +- .../world/tile/{tiles => impl}/NullTile.java | 2 +- .../tile/{tiles => impl}/TileBaseDoor.java | 2 +- .../{tiles => impl}/TileBaseEntrance.java | 2 +- .../tile/{tiles => impl}/TileBaseExit.java | 2 +- .../tile/{tiles => impl}/TileBaseFloor.java | 2 +- .../tile/{tiles => impl}/TileBasePassage.java | 2 +- .../{tiles => impl}/TileBaseSecretDoor.java | 4 +- .../tile/{tiles => impl}/TileBaseStairs.java | 2 +- .../tile/{tiles => impl}/TileBaseWall.java | 2 +- .../world/tile/{tiles => impl}/TileSolid.java | 2 +- .../tile/{tiles => impl}/TileWithItems.java | 2 +- .../{tiles => impl}/brick/TileBrickDoor.java | 4 +- .../brick/TileBrickEntrance.java | 4 +- .../{tiles => impl}/brick/TileBrickExit.java | 4 +- .../{tiles => impl}/brick/TileBrickFloor.java | 4 +- .../brick/TileBrickPassage.java | 4 +- .../brick/TileBrickSecretDoor.java | 4 +- .../{tiles => impl}/brick/TileBrickWall.java | 4 +- .../world/tile/render/DoorTileRenderer.java | 2 +- 68 files changed, 676 insertions(+), 625 deletions(-) delete mode 100644 src/mightypork/gamecore/util/math/algo/floodfill/FillContext.java rename src/mightypork/rogue/world/{PlayerInfo.java => PlayerData.java} (83%) create mode 100644 src/mightypork/rogue/world/PlayerFacade.java rename src/mightypork/rogue/world/entity/{entities => impl}/BossRatAi.java (93%) rename src/mightypork/rogue/world/entity/{entities => impl}/BrownRatAi.java (91%) rename src/mightypork/rogue/world/entity/{entities => impl}/EntityBossRat.java (97%) rename src/mightypork/rogue/world/entity/{entities => impl}/EntityBrownRat.java (97%) rename src/mightypork/rogue/world/entity/{entities => impl}/EntityGrayRat.java (97%) rename src/mightypork/rogue/world/entity/{entities => impl}/GrayRatAi.java (94%) rename src/mightypork/rogue/world/entity/{entities => impl}/MonsterAi.java (99%) rename src/mightypork/rogue/world/entity/{entities => impl}/PlayerEntity.java (96%) rename src/mightypork/rogue/world/{ => gen}/WorldCreator.java (86%) rename src/mightypork/rogue/world/item/{items => impl}/ItemBaseFood.java (93%) rename src/mightypork/rogue/world/item/{items => impl}/ItemBaseWeapon.java (92%) rename src/mightypork/rogue/world/item/{items => impl}/active/ItemHeartPiece.java (89%) rename src/mightypork/rogue/world/item/{items => impl}/food/ItemCheese.java (84%) rename src/mightypork/rogue/world/item/{items => impl}/food/ItemMeat.java (84%) rename src/mightypork/rogue/world/item/{items => impl}/food/ItemSandwich.java (84%) rename src/mightypork/rogue/world/item/{items => impl}/weapons/ItemBone.java (84%) rename src/mightypork/rogue/world/item/{items => impl}/weapons/ItemClub.java (85%) rename src/mightypork/rogue/world/item/{items => impl}/weapons/ItemHammer.java (85%) rename src/mightypork/rogue/world/item/{items => impl}/weapons/ItemStone.java (84%) rename src/mightypork/rogue/world/item/{items => impl}/weapons/ItemSword.java (84%) rename src/mightypork/rogue/world/tile/{tiles => impl}/NullTile.java (96%) rename src/mightypork/rogue/world/tile/{tiles => impl}/TileBaseDoor.java (96%) rename src/mightypork/rogue/world/tile/{tiles => impl}/TileBaseEntrance.java (93%) rename src/mightypork/rogue/world/tile/{tiles => impl}/TileBaseExit.java (93%) rename src/mightypork/rogue/world/tile/{tiles => impl}/TileBaseFloor.java (93%) rename src/mightypork/rogue/world/tile/{tiles => impl}/TileBasePassage.java (94%) rename src/mightypork/rogue/world/tile/{tiles => impl}/TileBaseSecretDoor.java (92%) rename src/mightypork/rogue/world/tile/{tiles => impl}/TileBaseStairs.java (87%) rename src/mightypork/rogue/world/tile/{tiles => impl}/TileBaseWall.java (93%) rename src/mightypork/rogue/world/tile/{tiles => impl}/TileSolid.java (92%) rename src/mightypork/rogue/world/tile/{tiles => impl}/TileWithItems.java (97%) rename src/mightypork/rogue/world/tile/{tiles => impl}/brick/TileBrickDoor.java (77%) rename src/mightypork/rogue/world/tile/{tiles => impl}/brick/TileBrickEntrance.java (80%) rename src/mightypork/rogue/world/tile/{tiles => impl}/brick/TileBrickExit.java (81%) rename src/mightypork/rogue/world/tile/{tiles => impl}/brick/TileBrickFloor.java (68%) rename src/mightypork/rogue/world/tile/{tiles => impl}/brick/TileBrickPassage.java (68%) rename src/mightypork/rogue/world/tile/{tiles => impl}/brick/TileBrickSecretDoor.java (78%) rename src/mightypork/rogue/world/tile/{tiles => impl}/brick/TileBrickWall.java (68%) diff --git a/src/mightypork/gamecore/eventbus/EventBus.java b/src/mightypork/gamecore/eventbus/EventBus.java index d18b696..dbbcbdf 100644 --- a/src/mightypork/gamecore/eventbus/EventBus.java +++ b/src/mightypork/gamecore/eventbus/EventBus.java @@ -356,7 +356,7 @@ final public class EventBus implements Destroyable, BusAccess { * @param clients clients * @param event event */ - private synchronized void doDispatch(Collection clients, BusEvent event) + private synchronized void doDispatch(Collection clients, BusEvent event) { boolean accepted = false; diff --git a/src/mightypork/gamecore/eventbus/EventChannel.java b/src/mightypork/gamecore/eventbus/EventChannel.java index 31c1200..e999766 100644 --- a/src/mightypork/gamecore/eventbus/EventChannel.java +++ b/src/mightypork/gamecore/eventbus/EventChannel.java @@ -47,7 +47,7 @@ class EventChannel, CLIENT> { * @param event a event to be sent * @param clients collection of clients */ - public void broadcast(BusEvent event, Collection clients) + public void broadcast(BusEvent event, Collection clients) { if (!canBroadcast(event)) return; @@ -62,7 +62,7 @@ class EventChannel, CLIENT> { * @param clients subscribing clients * @param processed clients already processed */ - private void doBroadcast(final EVENT event, final Collection clients, final Collection processed) + private void doBroadcast(final EVENT event, final Collection clients, final Collection processed) { for (final Object client : clients) { @@ -91,7 +91,7 @@ class EventChannel, CLIENT> { if (client instanceof DelegatingClient) { if (((DelegatingClient) client).doesDelegate()) { - final Collection children = ((DelegatingClient) client).getChildClients(); + final Collection children = ((DelegatingClient) client).getChildClients(); if (children != null && children.size() > 0) { doBroadcast(event, children, processed); diff --git a/src/mightypork/gamecore/eventbus/clients/DelegatingClient.java b/src/mightypork/gamecore/eventbus/clients/DelegatingClient.java index 76fe5ab..2f352b8 100644 --- a/src/mightypork/gamecore/eventbus/clients/DelegatingClient.java +++ b/src/mightypork/gamecore/eventbus/clients/DelegatingClient.java @@ -16,7 +16,7 @@ public interface DelegatingClient { /** * @return collection of child clients. Can not be null. */ - public Collection getChildClients(); + public Collection getChildClients(); /** diff --git a/src/mightypork/gamecore/util/math/algo/floodfill/FillContext.java b/src/mightypork/gamecore/util/math/algo/floodfill/FillContext.java deleted file mode 100644 index 9df70d3..0000000 --- a/src/mightypork/gamecore/util/math/algo/floodfill/FillContext.java +++ /dev/null @@ -1,31 +0,0 @@ -package mightypork.gamecore.util.math.algo.floodfill; - - -import mightypork.gamecore.util.math.algo.Coord; -import mightypork.gamecore.util.math.algo.Step; - - -public interface FillContext { - - boolean canEnter(Coord pos); - - - boolean canSpreadFrom(Coord pos); - - - Step[] getSpreadSides(); - - - /** - * Get the max distance filled form start point. Use -1 for unlimited range. - * - * @return max distance - */ - double getMaxDistance(); - - - /** - * @return true if start should be spread no matter what - */ - boolean forceSpreadStart(); -} diff --git a/src/mightypork/gamecore/util/math/algo/floodfill/FloodFill.java b/src/mightypork/gamecore/util/math/algo/floodfill/FloodFill.java index a57f3f9..4539354 100644 --- a/src/mightypork/gamecore/util/math/algo/floodfill/FloodFill.java +++ b/src/mightypork/gamecore/util/math/algo/floodfill/FloodFill.java @@ -9,26 +9,48 @@ import mightypork.gamecore.util.math.algo.Coord; import mightypork.gamecore.util.math.algo.Step; -public class FloodFill { +public abstract class FloodFill { + + public abstract boolean canEnter(Coord pos); + + + public abstract boolean canSpreadFrom(Coord pos); + + + public abstract Step[] getSpreadSides(); + + + /** + * Get the max distance filled form start point. Use -1 for unlimited range. + * + * @return max distance + */ + public abstract double getMaxDistance(); + + + /** + * @return true if start should be spread no matter what + */ + public abstract boolean forceSpreadStart(); + /** * Fill an area * * @param start start point - * @param context filling context * @param foundNodes collection to put filled coords in * @return true if fill was successful; false if max range was reached. */ - public static final boolean fill(Coord start, FillContext context, Collection foundNodes) + public final boolean fill(Coord start, Collection foundNodes) { final Queue activeNodes = new LinkedList<>(); - final double maxDist = context.getMaxDistance(); + final double maxDist = getMaxDistance(); activeNodes.add(start); - final Step[] sides = context.getSpreadSides(); - boolean forceSpreadNext = context.forceSpreadStart(); + final Step[] sides = getSpreadSides(); + boolean forceSpreadNext = forceSpreadStart(); boolean limitReached = false; @@ -36,7 +58,7 @@ public class FloodFill { final Coord current = activeNodes.poll(); foundNodes.add(current); - if (!context.canSpreadFrom(current) && !forceSpreadNext) continue; + if (!canSpreadFrom(current) && !forceSpreadNext) continue; forceSpreadNext = false; @@ -49,7 +71,7 @@ public class FloodFill { continue; } - if (context.canEnter(next)) { + if (canEnter(next)) { activeNodes.add(next); } else { foundNodes.add(next); diff --git a/src/mightypork/rogue/screens/game/InvLayer.java b/src/mightypork/rogue/screens/game/InvLayer.java index f75fd74..554284c 100644 --- a/src/mightypork/rogue/screens/game/InvLayer.java +++ b/src/mightypork/rogue/screens/game/InvLayer.java @@ -15,8 +15,8 @@ import mightypork.gamecore.util.math.constraints.num.Num; import mightypork.gamecore.util.math.constraints.rect.Rect; import mightypork.gamecore.util.strings.StringProvider; import mightypork.rogue.Res; +import mightypork.rogue.world.PlayerFacade; import mightypork.rogue.world.World; -import mightypork.rogue.world.World.PlayerFacade; import mightypork.rogue.world.WorldProvider; import mightypork.rogue.world.item.Item; import mightypork.rogue.world.item.ItemType; @@ -175,7 +175,7 @@ public class InvLayer extends ScreenLayer { } else { pl.selectWeapon(selected); } - world.msgEquipWeapon(pl.getSelectedWeapon()); + world.getConsole().msgEquipWeapon(pl.getSelectedWeapon()); } } diff --git a/src/mightypork/rogue/screens/game/InvSlot.java b/src/mightypork/rogue/screens/game/InvSlot.java index f2fd71a..8ae5fe2 100644 --- a/src/mightypork/rogue/screens/game/InvSlot.java +++ b/src/mightypork/rogue/screens/game/InvSlot.java @@ -14,7 +14,7 @@ import mightypork.gamecore.util.math.constraints.num.Num; import mightypork.gamecore.util.math.constraints.rect.Rect; import mightypork.gamecore.util.math.constraints.rect.caching.RectCache; import mightypork.rogue.Res; -import mightypork.rogue.world.World.PlayerFacade; +import mightypork.rogue.world.PlayerFacade; import mightypork.rogue.world.WorldProvider; import mightypork.rogue.world.item.Item; import mightypork.rogue.world.item.ItemType; diff --git a/src/mightypork/rogue/screens/game/ScreenGame.java b/src/mightypork/rogue/screens/game/ScreenGame.java index 69829ef..d89cf9e 100644 --- a/src/mightypork/rogue/screens/game/ScreenGame.java +++ b/src/mightypork/rogue/screens/game/ScreenGame.java @@ -10,7 +10,7 @@ import mightypork.gamecore.gui.screens.LayeredScreen; import mightypork.gamecore.input.KeyStroke; import mightypork.gamecore.input.Keys; import mightypork.rogue.Config; -import mightypork.rogue.world.World.PlayerFacade; +import mightypork.rogue.world.PlayerFacade; import mightypork.rogue.world.WorldProvider; import mightypork.rogue.world.events.WorldPauseRequest; import mightypork.rogue.world.events.WorldPauseRequest.PauseAction; diff --git a/src/mightypork/rogue/world/PlayerControl.java b/src/mightypork/rogue/world/PlayerControl.java index ace0d74..8aae2ec 100644 --- a/src/mightypork/rogue/world/PlayerControl.java +++ b/src/mightypork/rogue/world/PlayerControl.java @@ -7,7 +7,6 @@ import java.util.Set; import mightypork.gamecore.util.math.algo.Coord; import mightypork.gamecore.util.math.algo.Step; import mightypork.gamecore.util.math.constraints.vect.Vect; -import mightypork.rogue.world.World.PlayerFacade; import mightypork.rogue.world.entity.Entity; import mightypork.rogue.world.entity.EntityType; import mightypork.rogue.world.entity.modules.EntityMoveListener; diff --git a/src/mightypork/rogue/world/PlayerInfo.java b/src/mightypork/rogue/world/PlayerData.java similarity index 83% rename from src/mightypork/rogue/world/PlayerInfo.java rename to src/mightypork/rogue/world/PlayerData.java index b113ecc..48b5115 100644 --- a/src/mightypork/rogue/world/PlayerInfo.java +++ b/src/mightypork/rogue/world/PlayerData.java @@ -13,14 +13,11 @@ import mightypork.rogue.world.item.Item; * * @author MightyPork */ -public class PlayerInfo implements IonObjBundled { +public class PlayerData implements IonObjBundled { /** Player inventory size */ private static final int INV_SIZE = 8; - /** Constant indicating that no weapon is selected. */ - public static final int NO_WEAPON = -1; - /** Attack str with bare hands */ public static final int BARE_ATTACK = 1; @@ -30,7 +27,7 @@ public class PlayerInfo implements IonObjBundled { private Inventory inventory = new Inventory(INV_SIZE); - private int selectedWeapon = NO_WEAPON; + private int selectedWeapon = -1; @Override @@ -97,20 +94,24 @@ public class PlayerInfo implements IonObjBundled { } + public boolean hasWeaponSelected() + { + return !(selectedWeapon < 0 || selectedWeapon >= getInventory().getSize()); + } + + public Item getSelectedWeapon() { - if (selectedWeapon == NO_WEAPON) return null; + if (!hasWeaponSelected()) return null; return inventory.getItem(selectedWeapon); } public void selectWeapon(int selectedWeapon) { - if (selectedWeapon < 0 || selectedWeapon >= getInventory().getSize()) { - selectedWeapon = NO_WEAPON; - } - this.selectedWeapon = selectedWeapon; + + if (!hasWeaponSelected()) selectedWeapon = -1; // normalize } } diff --git a/src/mightypork/rogue/world/PlayerFacade.java b/src/mightypork/rogue/world/PlayerFacade.java new file mode 100644 index 0000000..03e8018 --- /dev/null +++ b/src/mightypork/rogue/world/PlayerFacade.java @@ -0,0 +1,369 @@ +package mightypork.rogue.world; + + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +import mightypork.gamecore.util.math.algo.Coord; +import mightypork.gamecore.util.math.algo.Step; +import mightypork.gamecore.util.math.constraints.vect.Vect; +import mightypork.rogue.world.entity.Entity; +import mightypork.rogue.world.item.Item; +import mightypork.rogue.world.item.ItemType; +import mightypork.rogue.world.level.Level; + + +/** + * Convenient access to player-related methods and data in world. + * + * @author MightyPork + */ +public class PlayerFacade { + + /** */ + private final World world; + + + /** + * @param world + */ + PlayerFacade(World world) + { + this.world = world; + } + + + public boolean canAscend() + { + return world.playerData.getLevelNumber() > 0; + } + + + public void descend() + { + if (!canDescend()) return; + + final int lvl_num = getLevelNumber(); + getLevel().removeEntity(world.playerEntity); + + world.playerData.setLevelNumber(lvl_num + 1); + + getLevel().forceFreeTile(getLevel().getEnterPoint()); + getLevel().addEntity(world.playerEntity, getLevel().getEnterPoint()); + getLevel().explore(getCoord()); + + world.console.msgEnterFloor(getLevelNumber()); + } + + + public boolean canDescend() + { + return world.playerData.getLevelNumber() < world.levels.size() - 1; + } + + + public void ascend() + { + if (!canAscend()) return; + + final int lvl_num = getLevelNumber(); + getLevel().removeEntity(world.playerEntity); + + world.playerData.setLevelNumber(lvl_num - 1); + + getLevel().forceFreeTile(getLevel().getExitPoint()); + getLevel().addEntity(world.playerEntity, getLevel().getExitPoint()); + getLevel().explore(getCoord()); + + world.console.msgEnterFloor(getLevelNumber()); + } + + + /** + * @return current level number, zero based. + */ + public int getLevelNumber() + { + return world.playerData.getLevelNumber(); + } + + + public Level getLevel() + { + return world.levels.get(world.playerData.getLevelNumber()); + } + + + public int getEID() + { + return world.playerData.getEID(); + } + + + public Coord getCoord() + { + return world.playerEntity.getCoord(); + } + + + public Vect getVisualPos() + { + return world.playerEntity.pos.getVisualPos(); + } + + + public void navigateTo(Coord pos) + { + world.playerEntity.pos.navigateTo(pos); + } + + + public void cancelPath() + { + world.playerEntity.pos.cancelPath(); + } + + + public void addPathStep(Step step) + { + world.playerEntity.pos.addStep(step); + } + + + public boolean isMoving() + { + return world.playerEntity.pos.isMoving(); + } + + + public double getMoveProgress() + { + return world.playerEntity.pos.getProgress(); + } + + + public boolean isDead() + { + return world.playerEntity.isDead(); + } + + + public int getHealth() + { + return world.playerEntity.health.getHealth(); + } + + + public int getHealthMax() + { + return world.playerEntity.health.getHealthMax(); + } + + + public Inventory getInventory() + { + return world.playerData.getInventory(); + } + + + public Entity getEntity() + { + return world.playerEntity; + } + + + public int getAttackStrength() + { + final Item weapon = world.playerData.getSelectedWeapon(); + + if (weapon == null) return PlayerData.BARE_ATTACK; + + return PlayerData.BARE_ATTACK + weapon.getAttackPoints(); + } + + + /** + * Eat food. + * + * @param itm food item + * @return if something was eaten + */ + public boolean eatFood(Item itm) + { + if (itm == null || itm.isEmpty() || itm.getType() != ItemType.FOOD) return false; + + if (getHealth() < getHealthMax()) { + + world.playerEntity.health.addHealth(itm.getFoodPoints()); + itm.consume(); + + world.console.msgEat(itm); + + return true; + } + + return false; + } + + + public void selectWeapon(int selected) + { + world.playerData.selectWeapon(selected); + } + + + public Item getSelectedWeapon() + { + return world.playerData.getSelectedWeapon(); + } + + + public int getSelectedWeaponIndex() + { + return world.playerData.getSelectedWeaponIndex(); + } + + + public void tryToEatSomeFood() + { + final List foods = new ArrayList<>(); + for (int i = 0; i < getInventory().getSize(); i++) { + final Item itm = getInventory().getItem(i); + if (itm != null && itm.getType() == ItemType.FOOD) { + foods.add(itm); + } + } + + // sort from smallest to biggest foods + Collections.sort(foods, new Comparator() { + + @Override + public int compare(Item o1, Item o2) + { + return (o1.getFoodPoints() - o2.getFoodPoints()); + } + }); + + for (final Item itm : foods) { + if (eatFood(itm)) { + getInventory().clean(); + return; + } + } + + if (getHealth() < getHealthMax()) { + world.console.msgNoMoreFood(); + } else { + world.console.msgNotHungry(); + } + } + + + public void attack(Entity prey) + { + final int attackPoints = getAttackStrength(); + + prey.receiveAttack(world.getPlayer().getEntity(), attackPoints); + + if (prey.isDead()) { + world.console.msgKill(prey); + } + + final Item wpn = getSelectedWeapon(); + + if (wpn != null) { + wpn.use(); + if (wpn.isEmpty()) { + world.console.msgWeaponBreak(wpn); + + getInventory().clean(); + selectWeapon(-1); + + pickBestWeaponIfNoneSelected(); + } + } + + } + + + private void pickBestWeaponIfNoneSelected() + { + if (getSelectedWeapon() != null) return; + + final List wpns = new ArrayList<>(); + for (int i = 0; i < getInventory().getSize(); i++) { + final Item itm = getInventory().getItem(i); + if (itm != null && itm.getType() == ItemType.WEAPON) { + wpns.add(itm); + } + } + + // sort from smallest to biggest foods + Collections.sort(wpns, new Comparator() { + + @Override + public int compare(Item o1, Item o2) + { + return (o2.getAttackPoints() - o1.getAttackPoints()); + } + }); + + for (final Item itm : wpns) { + for (int i = 0; i < getInventory().getSize(); i++) { + final Item itm2 = getInventory().getItem(i); + if (itm2 == itm) { + selectWeapon(i); + break; + } + } + break; // just one cycle + } + + world.console.msgEquipWeapon(getSelectedWeapon()); + } + + + public boolean addItem(Item item) + { + if (!getInventory().addItem(item)) { + + world.console.msgCannotPick(); + + return false; + } + + world.console.msgPick(item); + + if (item.getType() == ItemType.WEAPON) { + if (getSelectedWeapon() != null) { + if (item.getAttackPoints() > getSelectedWeapon().getAttackPoints()) { + selectWeapon(-1); // unselect to grab the best one + } + } + + pickBestWeaponIfNoneSelected(); + } + + return true; + } + + + public void setHealth(int health) + { + world.playerEntity.health.setHealth(health); + } + + + public void setHealthMax(int health) + { + world.playerEntity.health.setHealthMax(health); + } + + + public World getWorld() + { + return world; + } +} diff --git a/src/mightypork/rogue/world/World.java b/src/mightypork/rogue/world/World.java index 4e1914f..6355e90 100644 --- a/src/mightypork/rogue/world/World.java +++ b/src/mightypork/rogue/world/World.java @@ -2,7 +2,9 @@ package mightypork.rogue.world; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Random; import mightypork.gamecore.eventbus.BusAccess; import mightypork.gamecore.eventbus.EventBus; @@ -11,13 +13,9 @@ import mightypork.gamecore.eventbus.events.Updateable; import mightypork.gamecore.util.ion.IonBundle; import mightypork.gamecore.util.ion.IonObjBundled; import mightypork.gamecore.util.math.algo.Coord; -import mightypork.gamecore.util.math.algo.Step; -import mightypork.gamecore.util.math.constraints.vect.Vect; import mightypork.gamecore.util.math.timing.Pauseable; import mightypork.rogue.world.entity.Entities; import mightypork.rogue.world.entity.Entity; -import mightypork.rogue.world.item.Item; -import mightypork.rogue.world.item.ItemType; import mightypork.rogue.world.level.Level; @@ -28,356 +26,19 @@ import mightypork.rogue.world.level.Level; */ public class World implements DelegatingClient, BusAccess, IonObjBundled, Pauseable, Updateable { - /** - * Convenient access to player-related methods and data - * - * @author MightyPork - */ - public class PlayerFacade { - - public boolean canAscend() - { - return playerInfo.getLevelNumber() > 0; - } - - - public void descend() - { - if (!canDescend()) return; - - final int lvl_num = getLevelNumber(); - getLevel().removeEntity(playerEntity); - - playerInfo.setLevelNumber(lvl_num + 1); - - getLevel().forceFreeTile(getLevel().getEnterPoint()); - getLevel().addEntity(playerEntity, getLevel().getEnterPoint()); - getLevel().explore(getCoord()); - - msgEnterFloor(getLevelNumber()); - } - - - public boolean canDescend() - { - return playerInfo.getLevelNumber() < levels.size() - 1; - } - - - public void ascend() - { - if (!canAscend()) return; - - final int lvl_num = getLevelNumber(); - getLevel().removeEntity(playerEntity); - - playerInfo.setLevelNumber(lvl_num - 1); - - getLevel().forceFreeTile(getLevel().getExitPoint()); - getLevel().addEntity(playerEntity, getLevel().getExitPoint()); - getLevel().explore(getCoord()); - - msgEnterFloor(getLevelNumber()); - } - - - /** - * @return current level number, zero based. - */ - public int getLevelNumber() - { - return playerInfo.getLevelNumber(); - } - - - public Level getLevel() - { - return levels.get(playerInfo.getLevelNumber()); - } - - - public int getEID() - { - return playerInfo.getEID(); - } - - - public Coord getCoord() - { - return playerEntity.getCoord(); - } - - - public Vect getVisualPos() - { - return playerEntity.pos.getVisualPos(); - } - - - public void navigateTo(Coord pos) - { - playerEntity.pos.navigateTo(pos); - } - - - public void cancelPath() - { - playerEntity.pos.cancelPath(); - } - - - public void addPathStep(Step step) - { - playerEntity.pos.addStep(step); - } - - - public boolean isMoving() - { - return playerEntity.pos.isMoving(); - } - - - public double getMoveProgress() - { - return playerEntity.pos.getProgress(); - } - - - public boolean isDead() - { - return playerEntity.isDead(); - } - - - public int getHealth() - { - return playerEntity.health.getHealth(); - } - - - public int getHealthMax() - { - return playerEntity.health.getHealthMax(); - } - - - public Inventory getInventory() - { - return playerInfo.getInventory(); - } - - - public Entity getEntity() - { - return playerEntity; - } - - - public int getAttackStrength() - { - final Item weapon = playerInfo.getSelectedWeapon(); - - if (weapon == null) return PlayerInfo.BARE_ATTACK; - - return PlayerInfo.BARE_ATTACK + weapon.getAttackPoints(); - } - - - /** - * Eat food. - * - * @param itm food item - * @return if something was eaten - */ - public boolean eatFood(Item itm) - { - if (itm == null || itm.isEmpty() || itm.getType() != ItemType.FOOD) return false; - - if (getHealth() < getHealthMax()) { - - playerEntity.health.addHealth(itm.getFoodPoints()); - itm.consume(); - - msgEat(itm); - - return true; - } - - return false; - } - - - public void selectWeapon(int selected) - { - playerInfo.selectWeapon(selected); - } - - - public Item getSelectedWeapon() - { - return playerInfo.getSelectedWeapon(); - } - - - public int getSelectedWeaponIndex() - { - return playerInfo.getSelectedWeaponIndex(); - } - - - public void tryToEatSomeFood() - { - final List foods = new ArrayList<>(); - for (int i = 0; i < getInventory().getSize(); i++) { - final Item itm = getInventory().getItem(i); - if (itm != null && itm.getType() == ItemType.FOOD) { - foods.add(itm); - } - } - - // sort from smallest to biggest foods - Collections.sort(foods, new Comparator() { - - @Override - public int compare(Item o1, Item o2) - { - return (o1.getFoodPoints() - o2.getFoodPoints()); - } - }); - - for (final Item itm : foods) { - if (eatFood(itm)) { - getInventory().clean(); - return; - } - } - - if (getHealth() < getHealthMax()) { - msgNoMoreFood(); - } else { - msgNotHungry(); - } - } - - - public void attack(Entity prey) - { - final int attackPoints = getAttackStrength(); - - prey.receiveAttack(getPlayer().getEntity(), attackPoints); - - if (prey.isDead()) { - msgKill(prey); - } - - final Item wpn = getSelectedWeapon(); - - if (wpn != null) { - wpn.use(); - if (wpn.isEmpty()) { - msgWeaponBreak(wpn); - - getInventory().clean(); - selectWeapon(-1); - - pickBestWeaponIfNoneSelected(); - } - } - - } - - - private void pickBestWeaponIfNoneSelected() - { - if (getSelectedWeapon() != null) return; - - final List wpns = new ArrayList<>(); - for (int i = 0; i < getInventory().getSize(); i++) { - final Item itm = getInventory().getItem(i); - if (itm != null && itm.getType() == ItemType.WEAPON) { - wpns.add(itm); - } - } - - // sort from smallest to biggest foods - Collections.sort(wpns, new Comparator() { - - @Override - public int compare(Item o1, Item o2) - { - return (o2.getAttackPoints() - o1.getAttackPoints()); - } - }); - - for (final Item itm : wpns) { - for (int i = 0; i < getInventory().getSize(); i++) { - final Item itm2 = getInventory().getItem(i); - if (itm2 == itm) { - selectWeapon(i); - break; - } - } - break; // just one cycle - } - - msgEquipWeapon(getSelectedWeapon()); - } - - - public boolean addItem(Item item) - { - if (!getInventory().addItem(item)) { - - msgCannotPick(); - - return false; - } - - msgPick(item); - - if (item.getType() == ItemType.WEAPON) { - if (getSelectedWeapon() != null) { - if (item.getAttackPoints() > getSelectedWeapon().getAttackPoints()) { - selectWeapon(-1); // unselect to grab the best one - } - } - - pickBestWeaponIfNoneSelected(); - } - - return true; - } - - - public void setHealth(int health) - { - playerEntity.health.setHealth(health); - } - - - public void setHealthMax(int health) - { - playerEntity.health.setHealthMax(health); - } - - - public World getWorld() - { - return World.this; - } - } - // not saved stuffs - private final PlayerFacade player = new PlayerFacade(); - private Entity playerEntity; + private final PlayerFacade playerFacade = new PlayerFacade(this); + + final WorldConsole console = new WorldConsole(); + Entity playerEntity; private BusAccess bus; private int pauseDepth = 0; - private final ArrayList levels = new ArrayList<>(); - private final PlayerInfo playerInfo = new PlayerInfo(); + /** List of world's levels */ + final ArrayList levels = new ArrayList<>(); - private final WorldConsole console = new WorldConsole(); + /** Player data saved together with world */ + final PlayerData playerData = new PlayerData(); /** World seed */ private long seed; @@ -413,9 +74,9 @@ public class World implements DelegatingClient, BusAccess, IonObjBundled, Pausea lvl.setWorld(this); } - in.loadBundled("player", playerInfo); + in.loadBundled("player", playerData); - playerEntity = levels.get(playerInfo.getLevelNumber()).getEntity(playerInfo.getEID()); + playerEntity = levels.get(playerData.getLevelNumber()).getEntity(playerData.getEID()); if (playerEntity == null) { throw new RuntimeException("Player entity not found in the world."); } @@ -428,7 +89,7 @@ public class World implements DelegatingClient, BusAccess, IonObjBundled, Pausea out.put("seed", seed); out.put("next_eid", eid); out.putSequence("levels", levels); - out.putBundled("player", playerInfo); + out.putBundled("player", playerData); } @@ -462,7 +123,7 @@ public class World implements DelegatingClient, BusAccess, IonObjBundled, Pausea public void createPlayer() { - if (playerInfo.isInitialized()) { + if (playerData.isInitialized()) { throw new RuntimeException("Player already created."); } @@ -485,10 +146,10 @@ public class World implements DelegatingClient, BusAccess, IonObjBundled, Pausea floor.explore(spawn); - playerInfo.setLevelNumber(0); - playerInfo.setEID(playerEid); + playerData.setLevelNumber(0); + playerData.setEID(playerEid); - msgEnterFloor(0); + console.msgEnterFloor(0); } @@ -534,7 +195,7 @@ public class World implements DelegatingClient, BusAccess, IonObjBundled, Pausea public PlayerFacade getPlayer() { - return player; + return playerFacade; } @@ -543,7 +204,7 @@ public class World implements DelegatingClient, BusAccess, IonObjBundled, Pausea { if (isPaused()) return; - // update console timing + // update console timing - not as child client console.update(delta); } @@ -552,78 +213,4 @@ public class World implements DelegatingClient, BusAccess, IonObjBundled, Pausea { return console; } - - - public void msgPick(Item item) - { - console.addMessage("You've picked up a " + item.getVisualName() + "."); - console.lastPickupItem = item; - console.timeSinceLastPickup = 0; - } - - - public void msgWeaponBreak(Item item) - { - console.addMessage("Your " + item.getVisualName() + " has broken!"); - } - - - public void msgEquipWeapon(Item item) - { - console.addMessage("You're now wielding " + (item == null ? "NOTHING" : "a " + item.getVisualName()) + "."); - } - - - public void msgEat(Item item) - { - console.addMessage("You've eaten a " + item.getVisualName() + "."); - } - - - public void msgKill(Entity prey) - { - console.addMessage("You've killed a " + prey.getVisualName() + "."); - } - - - public void msgDie(Entity attacker) - { - console.addMessage("You've been defeated by a " + attacker.getVisualName() + "!"); - } - - - public void msgDiscoverSecretDoor() - { - console.addMessage("You've discovered a secret door."); - } - - - public void msgNoMoreFood() - { - console.addMessage("You don't have any food!"); - } - - - public void msgNotHungry() - { - console.addMessage("You are not hungry."); - } - - - public void msgCannotPick() - { - console.addMessage("Can't collect items, inventory is full."); - } - - - public void msgEnterFloor(int floor) - { - console.addMessage("~ Welcome to floor " + (1+floor) + "! ~"); - } - - - public void msgHeartPiece() - { - console.addMessage("Your health capacity has been increased."); - } } diff --git a/src/mightypork/rogue/world/WorldConsole.java b/src/mightypork/rogue/world/WorldConsole.java index 04e3cef..6091d90 100644 --- a/src/mightypork/rogue/world/WorldConsole.java +++ b/src/mightypork/rogue/world/WorldConsole.java @@ -9,9 +9,15 @@ import java.util.concurrent.LinkedBlockingDeque; import mightypork.gamecore.eventbus.events.Updateable; import mightypork.gamecore.util.math.Easing; import mightypork.gamecore.util.math.constraints.num.mutable.NumAnimated; +import mightypork.rogue.world.entity.Entity; import mightypork.rogue.world.item.Item; +/** + * Message log in world view + * + * @author MightyPork + */ public class WorldConsole implements Updateable { /** Used only for display */ @@ -113,4 +119,78 @@ public class WorldConsole implements Updateable { { entries.clear(); } + + + public void msgCannotPick() + { + addMessage("Can't collect items, inventory is full."); + } + + + public void msgDie(Entity attacker) + { + addMessage("You've been defeated by a " + attacker.getVisualName() + "!"); + } + + + public void msgDiscoverSecretDoor() + { + addMessage("You've discovered a secret door."); + } + + + public void msgEat(Item item) + { + addMessage("You've eaten a " + item.getVisualName() + "."); + } + + + public void msgEnterFloor(int floor) + { + addMessage("~ Floor " + (1 + floor) + " ~"); + } + + + public void msgEquipWeapon(Item item) + { + addMessage("You're now wielding " + (item == null ? "NOTHING" : "a " + item.getVisualName()) + "."); + } + + + public void msgHeartPiece() + { + addMessage("Your health capacity has been increased."); + } + + + public void msgKill(Entity prey) + { + addMessage("You've killed a " + prey.getVisualName() + "."); + } + + + public void msgNoMoreFood() + { + addMessage("You don't have any food!"); + } + + + public void msgNotHungry() + { + addMessage("You are not hungry."); + } + + + public void msgPick(Item item) + { + addMessage("You've picked up a " + item.getVisualName() + "."); + lastPickupItem = item; + timeSinceLastPickup = 0; + } + + + public void msgWeaponBreak(Item item) + { + addMessage("Your " + item.getVisualName() + " has broken!"); + } } diff --git a/src/mightypork/rogue/world/WorldProvider.java b/src/mightypork/rogue/world/WorldProvider.java index da889b3..6c6a06f 100644 --- a/src/mightypork/rogue/world/WorldProvider.java +++ b/src/mightypork/rogue/world/WorldProvider.java @@ -7,7 +7,7 @@ import java.io.IOException; import mightypork.gamecore.eventbus.BusAccess; import mightypork.gamecore.eventbus.clients.RootBusNode; import mightypork.gamecore.util.ion.Ion; -import mightypork.rogue.world.World.PlayerFacade; +import mightypork.rogue.world.gen.WorldCreator; import mightypork.rogue.world.level.Level; @@ -56,6 +56,12 @@ public class WorldProvider extends RootBusNode { } + public void destroyWorld() + { + setWorld(null); + } + + public World getWorld() { return world; @@ -64,9 +70,11 @@ public class WorldProvider extends RootBusNode { private void setWorld(World newWorld) { - if (world != null) removeChildClient(world); world = newWorld; + + if (newWorld == null) return; + world.assignBus(this); // connect to bus (for event dispatching) addChildClient(world); } diff --git a/src/mightypork/rogue/world/entity/Entities.java b/src/mightypork/rogue/world/entity/Entities.java index ff9c624..feccfc1 100644 --- a/src/mightypork/rogue/world/entity/Entities.java +++ b/src/mightypork/rogue/world/entity/Entities.java @@ -6,10 +6,10 @@ import java.util.Collection; import mightypork.gamecore.util.ion.IonInput; import mightypork.gamecore.util.ion.IonOutput; -import mightypork.rogue.world.entity.entities.EntityBossRat; -import mightypork.rogue.world.entity.entities.EntityBrownRat; -import mightypork.rogue.world.entity.entities.EntityGrayRat; -import mightypork.rogue.world.entity.entities.PlayerEntity; +import mightypork.rogue.world.entity.impl.EntityBossRat; +import mightypork.rogue.world.entity.impl.EntityBrownRat; +import mightypork.rogue.world.entity.impl.EntityGrayRat; +import mightypork.rogue.world.entity.impl.PlayerEntity; /** diff --git a/src/mightypork/rogue/world/entity/Entity.java b/src/mightypork/rogue/world/entity/Entity.java index 7c46e1c..5a6bc5b 100644 --- a/src/mightypork/rogue/world/entity/Entity.java +++ b/src/mightypork/rogue/world/entity/Entity.java @@ -2,11 +2,13 @@ package mightypork.rogue.world.entity; import java.io.IOException; +import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Random; +import mightypork.gamecore.eventbus.clients.DelegatingClient; import mightypork.gamecore.eventbus.events.Updateable; import mightypork.gamecore.util.annot.DefaultImpl; import mightypork.gamecore.util.error.IllegalValueException; @@ -27,7 +29,7 @@ import mightypork.rogue.world.level.render.MapRenderContext; * * @author MightyPork */ -public abstract class Entity implements IonObjBundled, Updateable { +public abstract class Entity implements IonObjBundled, Updateable, DelegatingClient { private Level level; private final EntityModel model; @@ -176,10 +178,6 @@ public abstract class Entity implements IonObjBundled, Updateable { getLevel().freeTile(getCoord()); freed = true; } - - for (final Entry entry : modules.entrySet()) { - entry.getValue().update(delta); - } } @@ -278,4 +276,19 @@ public abstract class Entity implements IonObjBundled, Updateable { public abstract String getVisualName(); + + + @Override + public boolean doesDelegate() + { + return true; + } + + + @Override + public Collection getChildClients() + { + return modules.values(); + } + } diff --git a/src/mightypork/rogue/world/entity/EntityModule.java b/src/mightypork/rogue/world/entity/EntityModule.java index db8c3ed..aa3e523 100644 --- a/src/mightypork/rogue/world/entity/EntityModule.java +++ b/src/mightypork/rogue/world/entity/EntityModule.java @@ -11,7 +11,7 @@ import mightypork.gamecore.util.ion.IonObjBundled; /** - * Abstract entity module + * Abstract entity module; Modules make up an entity AI and behavior. * * @author MightyPork */ diff --git a/src/mightypork/rogue/world/entity/entities/BossRatAi.java b/src/mightypork/rogue/world/entity/impl/BossRatAi.java similarity index 93% rename from src/mightypork/rogue/world/entity/entities/BossRatAi.java rename to src/mightypork/rogue/world/entity/impl/BossRatAi.java index 4135af2..3618f07 100644 --- a/src/mightypork/rogue/world/entity/entities/BossRatAi.java +++ b/src/mightypork/rogue/world/entity/impl/BossRatAi.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.entity.entities; +package mightypork.rogue.world.entity.impl; import mightypork.rogue.world.entity.AiTimer; diff --git a/src/mightypork/rogue/world/entity/entities/BrownRatAi.java b/src/mightypork/rogue/world/entity/impl/BrownRatAi.java similarity index 91% rename from src/mightypork/rogue/world/entity/entities/BrownRatAi.java rename to src/mightypork/rogue/world/entity/impl/BrownRatAi.java index 238389e..ebc0bea 100644 --- a/src/mightypork/rogue/world/entity/entities/BrownRatAi.java +++ b/src/mightypork/rogue/world/entity/impl/BrownRatAi.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.entity.entities; +package mightypork.rogue.world.entity.impl; import mightypork.rogue.world.entity.Entity; diff --git a/src/mightypork/rogue/world/entity/entities/EntityBossRat.java b/src/mightypork/rogue/world/entity/impl/EntityBossRat.java similarity index 97% rename from src/mightypork/rogue/world/entity/entities/EntityBossRat.java rename to src/mightypork/rogue/world/entity/impl/EntityBossRat.java index 24b19e5..33b3e33 100644 --- a/src/mightypork/rogue/world/entity/entities/EntityBossRat.java +++ b/src/mightypork/rogue/world/entity/impl/EntityBossRat.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.entity.entities; +package mightypork.rogue.world.entity.impl; import mightypork.gamecore.util.math.algo.pathfinding.PathFinder; diff --git a/src/mightypork/rogue/world/entity/entities/EntityBrownRat.java b/src/mightypork/rogue/world/entity/impl/EntityBrownRat.java similarity index 97% rename from src/mightypork/rogue/world/entity/entities/EntityBrownRat.java rename to src/mightypork/rogue/world/entity/impl/EntityBrownRat.java index cf242d2..5b2e3b7 100644 --- a/src/mightypork/rogue/world/entity/entities/EntityBrownRat.java +++ b/src/mightypork/rogue/world/entity/impl/EntityBrownRat.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.entity.entities; +package mightypork.rogue.world.entity.impl; import mightypork.gamecore.util.math.Calc; diff --git a/src/mightypork/rogue/world/entity/entities/EntityGrayRat.java b/src/mightypork/rogue/world/entity/impl/EntityGrayRat.java similarity index 97% rename from src/mightypork/rogue/world/entity/entities/EntityGrayRat.java rename to src/mightypork/rogue/world/entity/impl/EntityGrayRat.java index 02f26aa..1181391 100644 --- a/src/mightypork/rogue/world/entity/entities/EntityGrayRat.java +++ b/src/mightypork/rogue/world/entity/impl/EntityGrayRat.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.entity.entities; +package mightypork.rogue.world.entity.impl; import mightypork.gamecore.util.math.Calc; diff --git a/src/mightypork/rogue/world/entity/entities/GrayRatAi.java b/src/mightypork/rogue/world/entity/impl/GrayRatAi.java similarity index 94% rename from src/mightypork/rogue/world/entity/entities/GrayRatAi.java rename to src/mightypork/rogue/world/entity/impl/GrayRatAi.java index ec78a9f..30d43b6 100644 --- a/src/mightypork/rogue/world/entity/entities/GrayRatAi.java +++ b/src/mightypork/rogue/world/entity/impl/GrayRatAi.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.entity.entities; +package mightypork.rogue.world.entity.impl; import mightypork.rogue.world.entity.Entity; diff --git a/src/mightypork/rogue/world/entity/entities/MonsterAi.java b/src/mightypork/rogue/world/entity/impl/MonsterAi.java similarity index 99% rename from src/mightypork/rogue/world/entity/entities/MonsterAi.java rename to src/mightypork/rogue/world/entity/impl/MonsterAi.java index fb9791a..f31caf6 100644 --- a/src/mightypork/rogue/world/entity/entities/MonsterAi.java +++ b/src/mightypork/rogue/world/entity/impl/MonsterAi.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.entity.entities; +package mightypork.rogue.world.entity.impl; import java.io.IOException; diff --git a/src/mightypork/rogue/world/entity/entities/PlayerEntity.java b/src/mightypork/rogue/world/entity/impl/PlayerEntity.java similarity index 96% rename from src/mightypork/rogue/world/entity/entities/PlayerEntity.java rename to src/mightypork/rogue/world/entity/impl/PlayerEntity.java index 3abf010..b1740b7 100644 --- a/src/mightypork/rogue/world/entity/entities/PlayerEntity.java +++ b/src/mightypork/rogue/world/entity/impl/PlayerEntity.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.entity.entities; +package mightypork.rogue.world.entity.impl; import mightypork.gamecore.util.math.algo.Coord; @@ -138,7 +138,7 @@ public class PlayerEntity extends Entity { // send kill event to listeners, after the entity has despawned (disappeared) getWorld().getEventBus().sendDelayed(new PlayerKilledEvent(), getDespawnDelay()); - getWorld().msgDie(lastAttacker); + getWorld().getConsole().msgDie(lastAttacker); } diff --git a/src/mightypork/rogue/world/events/PlayerStepEndEvent.java b/src/mightypork/rogue/world/events/PlayerStepEndEvent.java index f07f5c5..cf7c9d5 100644 --- a/src/mightypork/rogue/world/events/PlayerStepEndEvent.java +++ b/src/mightypork/rogue/world/events/PlayerStepEndEvent.java @@ -3,7 +3,7 @@ package mightypork.rogue.world.events; import mightypork.gamecore.eventbus.BusEvent; import mightypork.gamecore.eventbus.event_flags.UnloggedEvent; -import mightypork.rogue.world.entity.entities.PlayerEntity; +import mightypork.rogue.world.entity.impl.PlayerEntity; @UnloggedEvent diff --git a/src/mightypork/rogue/world/events/PlayerStepEndListener.java b/src/mightypork/rogue/world/events/PlayerStepEndListener.java index 9ff97c3..898dd21 100644 --- a/src/mightypork/rogue/world/events/PlayerStepEndListener.java +++ b/src/mightypork/rogue/world/events/PlayerStepEndListener.java @@ -1,7 +1,7 @@ package mightypork.rogue.world.events; -import mightypork.rogue.world.entity.entities.PlayerEntity; +import mightypork.rogue.world.entity.impl.PlayerEntity; public interface PlayerStepEndListener { diff --git a/src/mightypork/rogue/world/gen/LevelGenerator.java b/src/mightypork/rogue/world/gen/LevelGenerator.java index d1deff2..cdd6961 100644 --- a/src/mightypork/rogue/world/gen/LevelGenerator.java +++ b/src/mightypork/rogue/world/gen/LevelGenerator.java @@ -92,7 +92,7 @@ public class LevelGenerator { // entities - random rats - for (int i = 0; i < Calc.randInt(rand, (int) (3 + level * 1.5), (int) (3 + level * 2.5)); i++) { + for (int i = 0; i < Calc.randInt(rand, (int) (3 + level * 1.5), 3 + level * 3); i++) { Entity e; if (level > 2 && rand.nextInt(level - 2 + 1) != 0) { diff --git a/src/mightypork/rogue/world/gen/ScratchMap.java b/src/mightypork/rogue/world/gen/ScratchMap.java index e424e4d..e3fb033 100644 --- a/src/mightypork/rogue/world/gen/ScratchMap.java +++ b/src/mightypork/rogue/world/gen/ScratchMap.java @@ -454,6 +454,10 @@ public class ScratchMap { public void writeToLevel(Level level) { + if (level.getWorld() == null) { + throw new WorldGenError("Level has no world assigned."); // need for entities + } + // make sure no walkable are at edges. final Coord c = Coord.make(0, 0); final Coord c1 = Coord.make(0, 0); diff --git a/src/mightypork/rogue/world/WorldCreator.java b/src/mightypork/rogue/world/gen/WorldCreator.java similarity index 86% rename from src/mightypork/rogue/world/WorldCreator.java rename to src/mightypork/rogue/world/gen/WorldCreator.java index 9c867a4..3f0c9fd 100644 --- a/src/mightypork/rogue/world/WorldCreator.java +++ b/src/mightypork/rogue/world/gen/WorldCreator.java @@ -1,9 +1,9 @@ -package mightypork.rogue.world; +package mightypork.rogue.world.gen; import java.util.Random; -import mightypork.rogue.world.gen.LevelGenerator; +import mightypork.rogue.world.World; public class WorldCreator { diff --git a/src/mightypork/rogue/world/gui/Minimap.java b/src/mightypork/rogue/world/gui/Minimap.java index 4f0c1ab..ffb7149 100644 --- a/src/mightypork/rogue/world/gui/Minimap.java +++ b/src/mightypork/rogue/world/gui/Minimap.java @@ -12,7 +12,7 @@ import mightypork.gamecore.util.math.constraints.num.Num; import mightypork.gamecore.util.math.constraints.rect.Rect; import mightypork.gamecore.util.math.constraints.rect.mutable.RectMutable; import mightypork.gamecore.util.math.constraints.vect.Vect; -import mightypork.rogue.world.World.PlayerFacade; +import mightypork.rogue.world.PlayerFacade; import mightypork.rogue.world.WorldProvider; import mightypork.rogue.world.level.Level; import mightypork.rogue.world.tile.Tile; diff --git a/src/mightypork/rogue/world/gui/interaction/MIPKeyboard.java b/src/mightypork/rogue/world/gui/interaction/MIPKeyboard.java index d8b0d6b..7404aee 100644 --- a/src/mightypork/rogue/world/gui/interaction/MIPKeyboard.java +++ b/src/mightypork/rogue/world/gui/interaction/MIPKeyboard.java @@ -9,7 +9,7 @@ import mightypork.gamecore.input.events.KeyListener; import mightypork.gamecore.util.math.algo.Sides; import mightypork.gamecore.util.math.algo.Step; import mightypork.gamecore.util.math.constraints.vect.Vect; -import mightypork.rogue.world.entity.entities.PlayerEntity; +import mightypork.rogue.world.entity.impl.PlayerEntity; import mightypork.rogue.world.events.PlayerStepEndListener; import mightypork.rogue.world.gui.MapView; diff --git a/src/mightypork/rogue/world/gui/interaction/MIPMouse.java b/src/mightypork/rogue/world/gui/interaction/MIPMouse.java index 09b3ee5..72084c3 100644 --- a/src/mightypork/rogue/world/gui/interaction/MIPMouse.java +++ b/src/mightypork/rogue/world/gui/interaction/MIPMouse.java @@ -8,7 +8,7 @@ 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.entity.entities.PlayerEntity; +import mightypork.rogue.world.entity.impl.PlayerEntity; import mightypork.rogue.world.events.PlayerStepEndListener; import mightypork.rogue.world.gui.MapView; import mightypork.rogue.world.tile.Tile; diff --git a/src/mightypork/rogue/world/gui/interaction/MapInteractionPlugin.java b/src/mightypork/rogue/world/gui/interaction/MapInteractionPlugin.java index 888f58c..8b9b9d3 100644 --- a/src/mightypork/rogue/world/gui/interaction/MapInteractionPlugin.java +++ b/src/mightypork/rogue/world/gui/interaction/MapInteractionPlugin.java @@ -2,8 +2,8 @@ package mightypork.rogue.world.gui.interaction; import mightypork.gamecore.util.math.constraints.vect.Vect; +import mightypork.rogue.world.PlayerFacade; import mightypork.rogue.world.World; -import mightypork.rogue.world.World.PlayerFacade; import mightypork.rogue.world.WorldProvider; import mightypork.rogue.world.gui.MapView; diff --git a/src/mightypork/rogue/world/item/Item.java b/src/mightypork/rogue/world/item/Item.java index 42e13d8..e3dc59b 100644 --- a/src/mightypork/rogue/world/item/Item.java +++ b/src/mightypork/rogue/world/item/Item.java @@ -11,7 +11,7 @@ import mightypork.gamecore.util.ion.IonObjBlob; import mightypork.gamecore.util.ion.IonOutput; import mightypork.gamecore.util.math.Calc; import mightypork.gamecore.util.math.constraints.rect.Rect; -import mightypork.rogue.world.World.PlayerFacade; +import mightypork.rogue.world.PlayerFacade; public abstract class Item implements IonObjBlob { diff --git a/src/mightypork/rogue/world/item/Items.java b/src/mightypork/rogue/world/item/Items.java index 1ac74c6..cade8e7 100644 --- a/src/mightypork/rogue/world/item/Items.java +++ b/src/mightypork/rogue/world/item/Items.java @@ -6,15 +6,15 @@ import java.util.Collection; import mightypork.gamecore.util.ion.IonInput; import mightypork.gamecore.util.ion.IonOutput; -import mightypork.rogue.world.item.items.active.ItemHeartPiece; -import mightypork.rogue.world.item.items.food.ItemCheese; -import mightypork.rogue.world.item.items.food.ItemMeat; -import mightypork.rogue.world.item.items.food.ItemSandwich; -import mightypork.rogue.world.item.items.weapons.ItemBone; -import mightypork.rogue.world.item.items.weapons.ItemClub; -import mightypork.rogue.world.item.items.weapons.ItemHammer; -import mightypork.rogue.world.item.items.weapons.ItemStone; -import mightypork.rogue.world.item.items.weapons.ItemSword; +import mightypork.rogue.world.item.impl.active.ItemHeartPiece; +import mightypork.rogue.world.item.impl.food.ItemCheese; +import mightypork.rogue.world.item.impl.food.ItemMeat; +import mightypork.rogue.world.item.impl.food.ItemSandwich; +import mightypork.rogue.world.item.impl.weapons.ItemBone; +import mightypork.rogue.world.item.impl.weapons.ItemClub; +import mightypork.rogue.world.item.impl.weapons.ItemHammer; +import mightypork.rogue.world.item.impl.weapons.ItemStone; +import mightypork.rogue.world.item.impl.weapons.ItemSword; /** diff --git a/src/mightypork/rogue/world/item/items/ItemBaseFood.java b/src/mightypork/rogue/world/item/impl/ItemBaseFood.java similarity index 93% rename from src/mightypork/rogue/world/item/items/ItemBaseFood.java rename to src/mightypork/rogue/world/item/impl/ItemBaseFood.java index 7e1114c..e03b624 100644 --- a/src/mightypork/rogue/world/item/items/ItemBaseFood.java +++ b/src/mightypork/rogue/world/item/impl/ItemBaseFood.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.item.items; +package mightypork.rogue.world.item.impl; import mightypork.rogue.world.item.Item; diff --git a/src/mightypork/rogue/world/item/items/ItemBaseWeapon.java b/src/mightypork/rogue/world/item/impl/ItemBaseWeapon.java similarity index 92% rename from src/mightypork/rogue/world/item/items/ItemBaseWeapon.java rename to src/mightypork/rogue/world/item/impl/ItemBaseWeapon.java index da11a78..869fcaa 100644 --- a/src/mightypork/rogue/world/item/items/ItemBaseWeapon.java +++ b/src/mightypork/rogue/world/item/impl/ItemBaseWeapon.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.item.items; +package mightypork.rogue.world.item.impl; import mightypork.rogue.world.item.Item; diff --git a/src/mightypork/rogue/world/item/items/active/ItemHeartPiece.java b/src/mightypork/rogue/world/item/impl/active/ItemHeartPiece.java similarity index 89% rename from src/mightypork/rogue/world/item/items/active/ItemHeartPiece.java rename to src/mightypork/rogue/world/item/impl/active/ItemHeartPiece.java index 715447b..243e161 100644 --- a/src/mightypork/rogue/world/item/items/active/ItemHeartPiece.java +++ b/src/mightypork/rogue/world/item/impl/active/ItemHeartPiece.java @@ -1,8 +1,8 @@ -package mightypork.rogue.world.item.items.active; +package mightypork.rogue.world.item.impl.active; import mightypork.rogue.Res; -import mightypork.rogue.world.World.PlayerFacade; +import mightypork.rogue.world.PlayerFacade; import mightypork.rogue.world.item.Item; import mightypork.rogue.world.item.ItemModel; import mightypork.rogue.world.item.ItemRenderer; @@ -80,7 +80,7 @@ public class ItemHeartPiece extends Item { pl.setHealthMax(pl.getHealthMax() + 2); // two points / heart pl.setHealth(pl.getHealthMax()); - pl.getWorld().msgHeartPiece(); + pl.getWorld().getConsole().msgHeartPiece(); return true; } diff --git a/src/mightypork/rogue/world/item/items/food/ItemCheese.java b/src/mightypork/rogue/world/item/impl/food/ItemCheese.java similarity index 84% rename from src/mightypork/rogue/world/item/items/food/ItemCheese.java rename to src/mightypork/rogue/world/item/impl/food/ItemCheese.java index 0b57645..b93cb92 100644 --- a/src/mightypork/rogue/world/item/items/food/ItemCheese.java +++ b/src/mightypork/rogue/world/item/impl/food/ItemCheese.java @@ -1,10 +1,10 @@ -package mightypork.rogue.world.item.items.food; +package mightypork.rogue.world.item.impl.food; import mightypork.rogue.Res; import mightypork.rogue.world.item.ItemModel; import mightypork.rogue.world.item.ItemRenderer; -import mightypork.rogue.world.item.items.ItemBaseFood; +import mightypork.rogue.world.item.impl.ItemBaseFood; import mightypork.rogue.world.item.render.QuadItemRenderer; diff --git a/src/mightypork/rogue/world/item/items/food/ItemMeat.java b/src/mightypork/rogue/world/item/impl/food/ItemMeat.java similarity index 84% rename from src/mightypork/rogue/world/item/items/food/ItemMeat.java rename to src/mightypork/rogue/world/item/impl/food/ItemMeat.java index e57344d..9e85eec 100644 --- a/src/mightypork/rogue/world/item/items/food/ItemMeat.java +++ b/src/mightypork/rogue/world/item/impl/food/ItemMeat.java @@ -1,10 +1,10 @@ -package mightypork.rogue.world.item.items.food; +package mightypork.rogue.world.item.impl.food; import mightypork.rogue.Res; import mightypork.rogue.world.item.ItemModel; import mightypork.rogue.world.item.ItemRenderer; -import mightypork.rogue.world.item.items.ItemBaseFood; +import mightypork.rogue.world.item.impl.ItemBaseFood; import mightypork.rogue.world.item.render.QuadItemRenderer; diff --git a/src/mightypork/rogue/world/item/items/food/ItemSandwich.java b/src/mightypork/rogue/world/item/impl/food/ItemSandwich.java similarity index 84% rename from src/mightypork/rogue/world/item/items/food/ItemSandwich.java rename to src/mightypork/rogue/world/item/impl/food/ItemSandwich.java index 4355a40..a7927c2 100644 --- a/src/mightypork/rogue/world/item/items/food/ItemSandwich.java +++ b/src/mightypork/rogue/world/item/impl/food/ItemSandwich.java @@ -1,10 +1,10 @@ -package mightypork.rogue.world.item.items.food; +package mightypork.rogue.world.item.impl.food; import mightypork.rogue.Res; import mightypork.rogue.world.item.ItemModel; import mightypork.rogue.world.item.ItemRenderer; -import mightypork.rogue.world.item.items.ItemBaseFood; +import mightypork.rogue.world.item.impl.ItemBaseFood; import mightypork.rogue.world.item.render.QuadItemRenderer; diff --git a/src/mightypork/rogue/world/item/items/weapons/ItemBone.java b/src/mightypork/rogue/world/item/impl/weapons/ItemBone.java similarity index 84% rename from src/mightypork/rogue/world/item/items/weapons/ItemBone.java rename to src/mightypork/rogue/world/item/impl/weapons/ItemBone.java index 8613ad8..566e3e9 100644 --- a/src/mightypork/rogue/world/item/items/weapons/ItemBone.java +++ b/src/mightypork/rogue/world/item/impl/weapons/ItemBone.java @@ -1,10 +1,10 @@ -package mightypork.rogue.world.item.items.weapons; +package mightypork.rogue.world.item.impl.weapons; import mightypork.rogue.Res; import mightypork.rogue.world.item.ItemModel; import mightypork.rogue.world.item.ItemRenderer; -import mightypork.rogue.world.item.items.ItemBaseWeapon; +import mightypork.rogue.world.item.impl.ItemBaseWeapon; import mightypork.rogue.world.item.render.QuadItemRenderer; diff --git a/src/mightypork/rogue/world/item/items/weapons/ItemClub.java b/src/mightypork/rogue/world/item/impl/weapons/ItemClub.java similarity index 85% rename from src/mightypork/rogue/world/item/items/weapons/ItemClub.java rename to src/mightypork/rogue/world/item/impl/weapons/ItemClub.java index 7c3cb25..088867f 100644 --- a/src/mightypork/rogue/world/item/items/weapons/ItemClub.java +++ b/src/mightypork/rogue/world/item/impl/weapons/ItemClub.java @@ -1,10 +1,10 @@ -package mightypork.rogue.world.item.items.weapons; +package mightypork.rogue.world.item.impl.weapons; import mightypork.rogue.Res; import mightypork.rogue.world.item.ItemModel; import mightypork.rogue.world.item.ItemRenderer; -import mightypork.rogue.world.item.items.ItemBaseWeapon; +import mightypork.rogue.world.item.impl.ItemBaseWeapon; import mightypork.rogue.world.item.render.QuadItemRenderer; diff --git a/src/mightypork/rogue/world/item/items/weapons/ItemHammer.java b/src/mightypork/rogue/world/item/impl/weapons/ItemHammer.java similarity index 85% rename from src/mightypork/rogue/world/item/items/weapons/ItemHammer.java rename to src/mightypork/rogue/world/item/impl/weapons/ItemHammer.java index 907aff5..680c28b 100644 --- a/src/mightypork/rogue/world/item/items/weapons/ItemHammer.java +++ b/src/mightypork/rogue/world/item/impl/weapons/ItemHammer.java @@ -1,10 +1,10 @@ -package mightypork.rogue.world.item.items.weapons; +package mightypork.rogue.world.item.impl.weapons; import mightypork.rogue.Res; import mightypork.rogue.world.item.ItemModel; import mightypork.rogue.world.item.ItemRenderer; -import mightypork.rogue.world.item.items.ItemBaseWeapon; +import mightypork.rogue.world.item.impl.ItemBaseWeapon; import mightypork.rogue.world.item.render.QuadItemRenderer; diff --git a/src/mightypork/rogue/world/item/items/weapons/ItemStone.java b/src/mightypork/rogue/world/item/impl/weapons/ItemStone.java similarity index 84% rename from src/mightypork/rogue/world/item/items/weapons/ItemStone.java rename to src/mightypork/rogue/world/item/impl/weapons/ItemStone.java index fb4b275..05ddabf 100644 --- a/src/mightypork/rogue/world/item/items/weapons/ItemStone.java +++ b/src/mightypork/rogue/world/item/impl/weapons/ItemStone.java @@ -1,10 +1,10 @@ -package mightypork.rogue.world.item.items.weapons; +package mightypork.rogue.world.item.impl.weapons; import mightypork.rogue.Res; import mightypork.rogue.world.item.ItemModel; import mightypork.rogue.world.item.ItemRenderer; -import mightypork.rogue.world.item.items.ItemBaseWeapon; +import mightypork.rogue.world.item.impl.ItemBaseWeapon; import mightypork.rogue.world.item.render.QuadItemRenderer; diff --git a/src/mightypork/rogue/world/item/items/weapons/ItemSword.java b/src/mightypork/rogue/world/item/impl/weapons/ItemSword.java similarity index 84% rename from src/mightypork/rogue/world/item/items/weapons/ItemSword.java rename to src/mightypork/rogue/world/item/impl/weapons/ItemSword.java index 33f1e6c..629c0cb 100644 --- a/src/mightypork/rogue/world/item/items/weapons/ItemSword.java +++ b/src/mightypork/rogue/world/item/impl/weapons/ItemSword.java @@ -1,10 +1,10 @@ -package mightypork.rogue.world.item.items.weapons; +package mightypork.rogue.world.item.impl.weapons; import mightypork.rogue.Res; import mightypork.rogue.world.item.ItemModel; import mightypork.rogue.world.item.ItemRenderer; -import mightypork.rogue.world.item.items.ItemBaseWeapon; +import mightypork.rogue.world.item.impl.ItemBaseWeapon; import mightypork.rogue.world.item.render.QuadItemRenderer; diff --git a/src/mightypork/rogue/world/level/Level.java b/src/mightypork/rogue/world/level/Level.java index 1c16aa8..17a15cd 100644 --- a/src/mightypork/rogue/world/level/Level.java +++ b/src/mightypork/rogue/world/level/Level.java @@ -17,7 +17,6 @@ import mightypork.gamecore.util.ion.IonOutput; import mightypork.gamecore.util.math.algo.Coord; import mightypork.gamecore.util.math.algo.Sides; import mightypork.gamecore.util.math.algo.Step; -import mightypork.gamecore.util.math.algo.floodfill.FillContext; import mightypork.gamecore.util.math.algo.floodfill.FloodFill; import mightypork.gamecore.util.math.constraints.vect.Vect; import mightypork.gamecore.util.math.noise.NoiseGen; @@ -25,7 +24,7 @@ import mightypork.rogue.world.World; import mightypork.rogue.world.entity.Entities; import mightypork.rogue.world.entity.Entity; import mightypork.rogue.world.entity.EntityType; -import mightypork.rogue.world.entity.entities.PlayerEntity; +import mightypork.rogue.world.entity.impl.PlayerEntity; import mightypork.rogue.world.item.Item; import mightypork.rogue.world.tile.Tile; import mightypork.rogue.world.tile.TileModel; @@ -60,6 +59,45 @@ public class Level implements BusAccess, Updateable, DelegatingClient, Toggleabl } + private final FloodFill exploreFiller = new FloodFill() { + + @Override + public Step[] getSpreadSides() + { + return Sides.ALL_SIDES; + } + + + @Override + public double getMaxDistance() + { + return 5.4; + } + + + @Override + public boolean canSpreadFrom(Coord pos) + { + final Tile t = getTile(pos); + return t.isWalkable() && !t.isDoor(); + } + + + @Override + public boolean canEnter(Coord pos) + { + final Tile t = getTile(pos); + return !t.isNull(); + } + + + @Override + public boolean forceSpreadStart() + { + return true; + } + }; + private static final Random rand = new Random(); public static final int ION_MARK = 53; @@ -524,52 +562,13 @@ public class Level implements BusAccess, Updateable, DelegatingClient, Toggleabl { final Collection filled = new HashSet<>(); - FloodFill.fill(center, exploreFc, filled); + exploreFiller.fill(center, filled); for (final Coord c : filled) { getTile(c).setExplored(); } } - private final FillContext exploreFc = new FillContext() { - - @Override - public Step[] getSpreadSides() - { - return Sides.ALL_SIDES; - } - - - @Override - public double getMaxDistance() - { - return 5.4; - } - - - @Override - public boolean canSpreadFrom(Coord pos) - { - final Tile t = getTile(pos); - return t.isWalkable() && !t.isDoor(); - } - - - @Override - public boolean canEnter(Coord pos) - { - final Tile t = getTile(pos); - return !t.isNull(); - } - - - @Override - public boolean forceSpreadStart() - { - return true; - } - }; - /** * Get entity of type closest to coord @@ -676,7 +675,7 @@ public class Level implements BusAccess, Updateable, DelegatingClient, Toggleabl @Override public boolean isListening() { - return playerCount > 0; + return playerCount > 0; // listen only when player is in this level } diff --git a/src/mightypork/rogue/world/tile/Tiles.java b/src/mightypork/rogue/world/tile/Tiles.java index 33bf083..2e92ea8 100644 --- a/src/mightypork/rogue/world/tile/Tiles.java +++ b/src/mightypork/rogue/world/tile/Tiles.java @@ -5,8 +5,8 @@ import java.io.IOException; import mightypork.gamecore.util.ion.IonInput; import mightypork.gamecore.util.ion.IonOutput; -import mightypork.rogue.world.tile.tiles.NullTile; -import mightypork.rogue.world.tile.tiles.brick.*; +import mightypork.rogue.world.tile.impl.NullTile; +import mightypork.rogue.world.tile.impl.brick.*; /** diff --git a/src/mightypork/rogue/world/tile/tiles/NullTile.java b/src/mightypork/rogue/world/tile/impl/NullTile.java similarity index 96% rename from src/mightypork/rogue/world/tile/tiles/NullTile.java rename to src/mightypork/rogue/world/tile/impl/NullTile.java index 353004e..a785cb6 100644 --- a/src/mightypork/rogue/world/tile/tiles/NullTile.java +++ b/src/mightypork/rogue/world/tile/impl/NullTile.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.tile.tiles; +package mightypork.rogue.world.tile.impl; import mightypork.rogue.world.item.Item; diff --git a/src/mightypork/rogue/world/tile/tiles/TileBaseDoor.java b/src/mightypork/rogue/world/tile/impl/TileBaseDoor.java similarity index 96% rename from src/mightypork/rogue/world/tile/tiles/TileBaseDoor.java rename to src/mightypork/rogue/world/tile/impl/TileBaseDoor.java index dc22eda..98eb8e6 100644 --- a/src/mightypork/rogue/world/tile/tiles/TileBaseDoor.java +++ b/src/mightypork/rogue/world/tile/impl/TileBaseDoor.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.tile.tiles; +package mightypork.rogue.world.tile.impl; import java.io.IOException; diff --git a/src/mightypork/rogue/world/tile/tiles/TileBaseEntrance.java b/src/mightypork/rogue/world/tile/impl/TileBaseEntrance.java similarity index 93% rename from src/mightypork/rogue/world/tile/tiles/TileBaseEntrance.java rename to src/mightypork/rogue/world/tile/impl/TileBaseEntrance.java index 48611e8..c232d5d 100644 --- a/src/mightypork/rogue/world/tile/tiles/TileBaseEntrance.java +++ b/src/mightypork/rogue/world/tile/impl/TileBaseEntrance.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.tile.tiles; +package mightypork.rogue.world.tile.impl; import mightypork.gamecore.util.math.algo.Coord; diff --git a/src/mightypork/rogue/world/tile/tiles/TileBaseExit.java b/src/mightypork/rogue/world/tile/impl/TileBaseExit.java similarity index 93% rename from src/mightypork/rogue/world/tile/tiles/TileBaseExit.java rename to src/mightypork/rogue/world/tile/impl/TileBaseExit.java index 283d8f9..32432ae 100644 --- a/src/mightypork/rogue/world/tile/tiles/TileBaseExit.java +++ b/src/mightypork/rogue/world/tile/impl/TileBaseExit.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.tile.tiles; +package mightypork.rogue.world.tile.impl; import mightypork.gamecore.util.math.algo.Coord; diff --git a/src/mightypork/rogue/world/tile/tiles/TileBaseFloor.java b/src/mightypork/rogue/world/tile/impl/TileBaseFloor.java similarity index 93% rename from src/mightypork/rogue/world/tile/tiles/TileBaseFloor.java rename to src/mightypork/rogue/world/tile/impl/TileBaseFloor.java index c8bb699..9532ed5 100644 --- a/src/mightypork/rogue/world/tile/tiles/TileBaseFloor.java +++ b/src/mightypork/rogue/world/tile/impl/TileBaseFloor.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.tile.tiles; +package mightypork.rogue.world.tile.impl; import mightypork.gamecore.resources.textures.TxSheet; diff --git a/src/mightypork/rogue/world/tile/tiles/TileBasePassage.java b/src/mightypork/rogue/world/tile/impl/TileBasePassage.java similarity index 94% rename from src/mightypork/rogue/world/tile/tiles/TileBasePassage.java rename to src/mightypork/rogue/world/tile/impl/TileBasePassage.java index 103ca2e..23f38b4 100644 --- a/src/mightypork/rogue/world/tile/tiles/TileBasePassage.java +++ b/src/mightypork/rogue/world/tile/impl/TileBasePassage.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.tile.tiles; +package mightypork.rogue.world.tile.impl; import mightypork.gamecore.resources.textures.TxSheet; diff --git a/src/mightypork/rogue/world/tile/tiles/TileBaseSecretDoor.java b/src/mightypork/rogue/world/tile/impl/TileBaseSecretDoor.java similarity index 92% rename from src/mightypork/rogue/world/tile/tiles/TileBaseSecretDoor.java rename to src/mightypork/rogue/world/tile/impl/TileBaseSecretDoor.java index aa67b49..d85cc41 100644 --- a/src/mightypork/rogue/world/tile/tiles/TileBaseSecretDoor.java +++ b/src/mightypork/rogue/world/tile/impl/TileBaseSecretDoor.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.tile.tiles; +package mightypork.rogue.world.tile.impl; import java.io.IOException; @@ -32,7 +32,7 @@ public abstract class TileBaseSecretDoor extends TileBaseDoor { if (clicks == 0) { locked = false; - getWorld().msgDiscoverSecretDoor(); + getWorld().getConsole().msgDiscoverSecretDoor(); } return true; diff --git a/src/mightypork/rogue/world/tile/tiles/TileBaseStairs.java b/src/mightypork/rogue/world/tile/impl/TileBaseStairs.java similarity index 87% rename from src/mightypork/rogue/world/tile/tiles/TileBaseStairs.java rename to src/mightypork/rogue/world/tile/impl/TileBaseStairs.java index 22e7196..27ebcaf 100644 --- a/src/mightypork/rogue/world/tile/tiles/TileBaseStairs.java +++ b/src/mightypork/rogue/world/tile/impl/TileBaseStairs.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.tile.tiles; +package mightypork.rogue.world.tile.impl; import mightypork.rogue.world.tile.TileModel; diff --git a/src/mightypork/rogue/world/tile/tiles/TileBaseWall.java b/src/mightypork/rogue/world/tile/impl/TileBaseWall.java similarity index 93% rename from src/mightypork/rogue/world/tile/tiles/TileBaseWall.java rename to src/mightypork/rogue/world/tile/impl/TileBaseWall.java index 6d4e61b..61eb70a 100644 --- a/src/mightypork/rogue/world/tile/tiles/TileBaseWall.java +++ b/src/mightypork/rogue/world/tile/impl/TileBaseWall.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.tile.tiles; +package mightypork.rogue.world.tile.impl; import mightypork.gamecore.resources.textures.TxSheet; diff --git a/src/mightypork/rogue/world/tile/tiles/TileSolid.java b/src/mightypork/rogue/world/tile/impl/TileSolid.java similarity index 92% rename from src/mightypork/rogue/world/tile/tiles/TileSolid.java rename to src/mightypork/rogue/world/tile/impl/TileSolid.java index 2b543f7..c7cc1f6 100644 --- a/src/mightypork/rogue/world/tile/tiles/TileSolid.java +++ b/src/mightypork/rogue/world/tile/impl/TileSolid.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.tile.tiles; +package mightypork.rogue.world.tile.impl; import mightypork.rogue.world.item.Item; diff --git a/src/mightypork/rogue/world/tile/tiles/TileWithItems.java b/src/mightypork/rogue/world/tile/impl/TileWithItems.java similarity index 97% rename from src/mightypork/rogue/world/tile/tiles/TileWithItems.java rename to src/mightypork/rogue/world/tile/impl/TileWithItems.java index aacd6fb..f756ac1 100644 --- a/src/mightypork/rogue/world/tile/tiles/TileWithItems.java +++ b/src/mightypork/rogue/world/tile/impl/TileWithItems.java @@ -1,4 +1,4 @@ -package mightypork.rogue.world.tile.tiles; +package mightypork.rogue.world.tile.impl; import java.io.IOException; diff --git a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickDoor.java b/src/mightypork/rogue/world/tile/impl/brick/TileBrickDoor.java similarity index 77% rename from src/mightypork/rogue/world/tile/tiles/brick/TileBrickDoor.java rename to src/mightypork/rogue/world/tile/impl/brick/TileBrickDoor.java index 7a22b17..49a9920 100644 --- a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickDoor.java +++ b/src/mightypork/rogue/world/tile/impl/brick/TileBrickDoor.java @@ -1,9 +1,9 @@ -package mightypork.rogue.world.tile.tiles.brick; +package mightypork.rogue.world.tile.impl.brick; import mightypork.rogue.Res; import mightypork.rogue.world.tile.TileModel; -import mightypork.rogue.world.tile.tiles.TileBaseDoor; +import mightypork.rogue.world.tile.impl.TileBaseDoor; public class TileBrickDoor extends TileBaseDoor { diff --git a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickEntrance.java b/src/mightypork/rogue/world/tile/impl/brick/TileBrickEntrance.java similarity index 80% rename from src/mightypork/rogue/world/tile/tiles/brick/TileBrickEntrance.java rename to src/mightypork/rogue/world/tile/impl/brick/TileBrickEntrance.java index 0c8a74b..fbe673d 100644 --- a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickEntrance.java +++ b/src/mightypork/rogue/world/tile/impl/brick/TileBrickEntrance.java @@ -1,11 +1,11 @@ -package mightypork.rogue.world.tile.tiles.brick; +package mightypork.rogue.world.tile.impl.brick; import mightypork.rogue.Res; import mightypork.rogue.world.tile.TileModel; import mightypork.rogue.world.tile.TileRenderer; +import mightypork.rogue.world.tile.impl.TileBaseEntrance; import mightypork.rogue.world.tile.render.OneFrameTileRenderer; -import mightypork.rogue.world.tile.tiles.TileBaseEntrance; public class TileBrickEntrance extends TileBaseEntrance { diff --git a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickExit.java b/src/mightypork/rogue/world/tile/impl/brick/TileBrickExit.java similarity index 81% rename from src/mightypork/rogue/world/tile/tiles/brick/TileBrickExit.java rename to src/mightypork/rogue/world/tile/impl/brick/TileBrickExit.java index 7e19882..a4c4bdd 100644 --- a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickExit.java +++ b/src/mightypork/rogue/world/tile/impl/brick/TileBrickExit.java @@ -1,11 +1,11 @@ -package mightypork.rogue.world.tile.tiles.brick; +package mightypork.rogue.world.tile.impl.brick; import mightypork.rogue.Res; import mightypork.rogue.world.tile.TileModel; import mightypork.rogue.world.tile.TileRenderer; +import mightypork.rogue.world.tile.impl.TileBaseExit; import mightypork.rogue.world.tile.render.OneFrameTileRenderer; -import mightypork.rogue.world.tile.tiles.TileBaseExit; public class TileBrickExit extends TileBaseExit { diff --git a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickFloor.java b/src/mightypork/rogue/world/tile/impl/brick/TileBrickFloor.java similarity index 68% rename from src/mightypork/rogue/world/tile/tiles/brick/TileBrickFloor.java rename to src/mightypork/rogue/world/tile/impl/brick/TileBrickFloor.java index 3722f4d..a4768fd 100644 --- a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickFloor.java +++ b/src/mightypork/rogue/world/tile/impl/brick/TileBrickFloor.java @@ -1,9 +1,9 @@ -package mightypork.rogue.world.tile.tiles.brick; +package mightypork.rogue.world.tile.impl.brick; import mightypork.rogue.Res; import mightypork.rogue.world.tile.TileModel; -import mightypork.rogue.world.tile.tiles.TileBaseFloor; +import mightypork.rogue.world.tile.impl.TileBaseFloor; public class TileBrickFloor extends TileBaseFloor { diff --git a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickPassage.java b/src/mightypork/rogue/world/tile/impl/brick/TileBrickPassage.java similarity index 68% rename from src/mightypork/rogue/world/tile/tiles/brick/TileBrickPassage.java rename to src/mightypork/rogue/world/tile/impl/brick/TileBrickPassage.java index 2f255b9..53e6b55 100644 --- a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickPassage.java +++ b/src/mightypork/rogue/world/tile/impl/brick/TileBrickPassage.java @@ -1,9 +1,9 @@ -package mightypork.rogue.world.tile.tiles.brick; +package mightypork.rogue.world.tile.impl.brick; import mightypork.rogue.Res; import mightypork.rogue.world.tile.TileModel; -import mightypork.rogue.world.tile.tiles.TileBasePassage; +import mightypork.rogue.world.tile.impl.TileBasePassage; public class TileBrickPassage extends TileBasePassage { diff --git a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickSecretDoor.java b/src/mightypork/rogue/world/tile/impl/brick/TileBrickSecretDoor.java similarity index 78% rename from src/mightypork/rogue/world/tile/tiles/brick/TileBrickSecretDoor.java rename to src/mightypork/rogue/world/tile/impl/brick/TileBrickSecretDoor.java index ba599be..ee0ed66 100644 --- a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickSecretDoor.java +++ b/src/mightypork/rogue/world/tile/impl/brick/TileBrickSecretDoor.java @@ -1,9 +1,9 @@ -package mightypork.rogue.world.tile.tiles.brick; +package mightypork.rogue.world.tile.impl.brick; import mightypork.rogue.Res; import mightypork.rogue.world.tile.TileModel; -import mightypork.rogue.world.tile.tiles.TileBaseSecretDoor; +import mightypork.rogue.world.tile.impl.TileBaseSecretDoor; public class TileBrickSecretDoor extends TileBaseSecretDoor { diff --git a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickWall.java b/src/mightypork/rogue/world/tile/impl/brick/TileBrickWall.java similarity index 68% rename from src/mightypork/rogue/world/tile/tiles/brick/TileBrickWall.java rename to src/mightypork/rogue/world/tile/impl/brick/TileBrickWall.java index d5cdb3a..16ee744 100644 --- a/src/mightypork/rogue/world/tile/tiles/brick/TileBrickWall.java +++ b/src/mightypork/rogue/world/tile/impl/brick/TileBrickWall.java @@ -1,9 +1,9 @@ -package mightypork.rogue.world.tile.tiles.brick; +package mightypork.rogue.world.tile.impl.brick; import mightypork.rogue.Res; import mightypork.rogue.world.tile.TileModel; -import mightypork.rogue.world.tile.tiles.TileBaseWall; +import mightypork.rogue.world.tile.impl.TileBaseWall; public class TileBrickWall extends TileBaseWall { diff --git a/src/mightypork/rogue/world/tile/render/DoorTileRenderer.java b/src/mightypork/rogue/world/tile/render/DoorTileRenderer.java index c61d480..ce2c737 100644 --- a/src/mightypork/rogue/world/tile/render/DoorTileRenderer.java +++ b/src/mightypork/rogue/world/tile/render/DoorTileRenderer.java @@ -7,7 +7,7 @@ import mightypork.gamecore.util.math.constraints.rect.Rect; import mightypork.gamecore.util.math.timing.TimedTask; import mightypork.rogue.world.level.render.TileRenderContext; import mightypork.rogue.world.tile.TileRenderer; -import mightypork.rogue.world.tile.tiles.TileBaseDoor; +import mightypork.rogue.world.tile.impl.TileBaseDoor; public class DoorTileRenderer extends TileRenderer {