cleanup & format

v5stable
Ondřej Hruška 11 years ago
parent 9206396c8e
commit 7d3695d0a9
  1. 1
      src/mightypork/gamecore/app/BaseApp.java
  2. 1
      src/mightypork/gamecore/gui/Action.java
  3. 2
      src/mightypork/gamecore/gui/events/CrossfadeRequest.java
  4. 3
      src/mightypork/gamecore/gui/screens/Screen.java
  5. 3
      src/mightypork/gamecore/gui/screens/impl/CrossfadeOverlay.java
  6. 2
      src/mightypork/gamecore/gui/screens/impl/LayerColor.java
  7. 1
      src/mightypork/gamecore/logging/SlickLogRedirector.java
  8. 16
      src/mightypork/gamecore/util/ion/Ion.java
  9. 2
      src/mightypork/gamecore/util/ion/IonBundle.java
  10. 11
      src/mightypork/gamecore/util/math/algo/Coord.java
  11. 10
      src/mightypork/gamecore/util/math/algo/Step.java
  12. 5
      src/mightypork/gamecore/util/math/algo/pathfinding/PathFindingContextProxy.java
  13. 1
      src/mightypork/gamecore/util/math/color/pal/CGA.java
  14. 1
      src/mightypork/gamecore/util/math/color/pal/COMMODORE.java
  15. 1
      src/mightypork/gamecore/util/math/color/pal/PAL16.java
  16. 1
      src/mightypork/gamecore/util/math/color/pal/RGB.java
  17. 1
      src/mightypork/gamecore/util/math/color/pal/ZX.java
  18. 24
      src/mightypork/gamecore/util/math/timing/Animator.java
  19. 7
      src/mightypork/gamecore/util/math/timing/TaskRepeater.java
  20. 1
      src/mightypork/gamecore/util/strings/StringWrapper.java
  21. 2
      src/mightypork/rogue/screens/game/ScreenGame.java
  22. 3
      src/mightypork/rogue/screens/menu/MenuButton.java
  23. 5
      src/mightypork/rogue/screens/menu/MenuLayer.java
  24. 3
      src/mightypork/rogue/screens/test_bouncyboxes/ScreenTestBouncy.java
  25. 6
      src/mightypork/rogue/world/entity/AiTimer.java
  26. 15
      src/mightypork/rogue/world/entity/Entity.java
  27. 4
      src/mightypork/rogue/world/entity/EntityModule.java
  28. 25
      src/mightypork/rogue/world/entity/entities/MonsterAi.java
  29. 11
      src/mightypork/rogue/world/entity/entities/PlayerEntity.java
  30. 7
      src/mightypork/rogue/world/entity/entities/SimpleMonster.java
  31. 3
      src/mightypork/rogue/world/entity/modules/EntityModuleHealth.java
  32. 1
      src/mightypork/rogue/world/entity/modules/EntityModulePosition.java
  33. 2
      src/mightypork/rogue/world/entity/modules/EntityMoveListener.java
  34. 1
      src/mightypork/rogue/world/gen/MapTheme.java
  35. 7
      src/mightypork/rogue/world/gen/rooms/DeadEndRoom.java
  36. 4
      src/mightypork/rogue/world/gen/rooms/SimpleRectRoom.java
  37. 24
      src/mightypork/rogue/world/level/Level.java
  38. 1
      src/mightypork/rogue/world/tile/renderers/DoorTileRenderer.java
  39. 6
      src/mightypork/rogue/world/tile/tiles/WallPassageTile.java

@ -148,6 +148,7 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler {
Log.i("=== Initialized sequence completed ==="); Log.i("=== Initialized sequence completed ===");
} }
@DefaultImpl @DefaultImpl
protected void registerIonizables() protected void registerIonizables()
{ {

@ -1,7 +1,6 @@
package mightypork.gamecore.gui; package mightypork.gamecore.gui;
/** /**
* Triggered action * Triggered action
* *

@ -13,6 +13,7 @@ public class CrossfadeRequest extends BusEvent<CrossfadeOverlay> {
private final String screen; private final String screen;
private final boolean fromDark; private final boolean fromDark;
/** /**
* @param screen screen key to show. Null = exit the app. * @param screen screen key to show. Null = exit the app.
* @param fromDark true to fade from full black (ie. start of the game) * @param fromDark true to fade from full black (ie. start of the game)
@ -24,6 +25,7 @@ public class CrossfadeRequest extends BusEvent<CrossfadeOverlay> {
this.fromDark = fromDark; this.fromDark = fromDark;
} }
/** /**
* @param screen screen key to show. Null = exit the app. * @param screen screen key to show. Null = exit the app.
*/ */

@ -32,7 +32,8 @@ public abstract class Screen extends AppSubModule implements Renderable, RectBou
/** /**
* @param app app access * @param app app access
*/ */
public Screen(AppAccess app) { public Screen(AppAccess app)
{
super(app); super(app);
// disable events initially // disable events initially

@ -39,7 +39,8 @@ public class CrossfadeOverlay extends Overlay {
}; };
public CrossfadeOverlay(AppAccess app) { public CrossfadeOverlay(AppAccess app)
{
super(app); super(app);
final QuadPainter qp = new QuadPainter(color); final QuadPainter qp = new QuadPainter(color);

@ -9,7 +9,7 @@ import mightypork.gamecore.util.math.color.Color;
public class LayerColor extends ScreenLayer { public class LayerColor extends ScreenLayer {
private int zIndex; private final int zIndex;
public LayerColor(Screen screen, Color color, int zIndex) public LayerColor(Screen screen, Color color, int zIndex)

@ -5,6 +5,7 @@ import java.util.logging.Level;
import mightypork.gamecore.logging.writers.LogWriter; import mightypork.gamecore.logging.writers.LogWriter;
/** /**
* Used to redirect slick log into main logger. * Used to redirect slick log into main logger.
* *

@ -93,13 +93,9 @@ public class Ion {
if (mark > 255) throw new IllegalArgumentException("Mark must be < 256."); if (mark > 255) throw new IllegalArgumentException("Mark must be < 256.");
if (mark < 0) throw new IllegalArgumentException("Mark must be positive."); if (mark < 0) throw new IllegalArgumentException("Mark must be positive.");
if (reservedMarkChecking && mark < 50) { if (reservedMarkChecking && mark < 50) { throw new IllegalArgumentException("Marks 0..49 are reserved."); }
throw new IllegalArgumentException("Marks 0..49 are reserved.");
}
if (registered[mark] != null) { if (registered[mark] != null) { throw new IllegalArgumentException("Mark " + mark + " is already in use."); }
throw new IllegalArgumentException("Mark " + mark + " is already in use.");
}
try { try {
objClass.getConstructor(); objClass.getConstructor();
@ -282,13 +278,9 @@ public class Ion {
final Class<? extends IonObjBinary> clz = Ion.getClassForMark(mark); final Class<? extends IonObjBinary> clz = Ion.getClassForMark(mark);
if (clz == null) { if (clz == null) { throw new IOException("Not registered - mark: " + mark + ", class: " + Log.str(obj.getClass())); }
throw new IOException("Not registered - mark: " + mark + ", class: " + Log.str(obj.getClass()));
}
if (clz != obj.getClass()) { if (clz != obj.getClass()) { throw new IOException("Class mismatch - mark: " + mark + ", class: " + Log.str(obj.getClass())); }
throw new IOException("Class mismatch - mark: " + mark + ", class: " + Log.str(obj.getClass()));
}
} }
} }

@ -138,11 +138,13 @@ public class IonBundle implements IonObjBinary {
backingMap.put(key, value); backingMap.put(key, value);
} }
public void put(String key, byte value) public void put(String key, byte value)
{ {
backingMap.put(key, value); backingMap.put(key, value);
} }
public void put(String key, char value) public void put(String key, char value)
{ {
backingMap.put(key, value); backingMap.put(key, value);

@ -47,18 +47,23 @@ public class Coord implements IonObjBundled, IonObjBinary {
return make(0, 0); return make(0, 0);
} }
public Coord() {
public Coord()
{
// for ion // for ion
} }
public Coord(int x, int y) {
public Coord(int x, int y)
{
super(); super();
this.x = x; this.x = x;
this.y = y; this.y = y;
} }
public Coord(Coord other) { public Coord(Coord other)
{
this.x = other.x; this.x = other.x;
this.y = other.y; this.y = other.y;
} }

@ -44,11 +44,15 @@ public class Step implements IonObjBinary, IonObjBundled {
private byte x; private byte x;
private byte y; private byte y;
public Step() {
public Step()
{
// for ion // for ion
} }
public Step(int x, int y) {
public Step(int x, int y)
{
this.x = (byte) (x < 0 ? -1 : x > 0 ? 1 : 0); this.x = (byte) (x < 0 ? -1 : x > 0 ? 1 : 0);
this.y = (byte) (y < 0 ? -1 : y > 0 ? 1 : 0); this.y = (byte) (y < 0 ? -1 : y > 0 ? 1 : 0);
} }
@ -66,7 +70,6 @@ public class Step implements IonObjBinary, IonObjBundled {
} }
public Coord toCoord() public Coord toCoord()
{ {
return Coord.make(x, y); return Coord.make(x, y);
@ -102,6 +105,7 @@ public class Step implements IonObjBinary, IonObjBundled {
out.writeByte(y); out.writeByte(y);
} }
@Override @Override
public void load(IonBundle bundle) throws IOException public void load(IonBundle bundle) throws IOException
{ {

@ -13,10 +13,11 @@ import mightypork.gamecore.util.math.algo.Step;
*/ */
public class PathFindingContextProxy implements PathFindingContext { public class PathFindingContextProxy implements PathFindingContext {
private PathFindingContext source; private final PathFindingContext source;
public PathFindingContextProxy(PathFindingContext other) { public PathFindingContextProxy(PathFindingContext other)
{
this.source = other; this.source = other;
} }

@ -1,5 +1,6 @@
package mightypork.gamecore.util.math.color.pal; package mightypork.gamecore.util.math.color.pal;
import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.color.Color;

@ -1,5 +1,6 @@
package mightypork.gamecore.util.math.color.pal; package mightypork.gamecore.util.math.color.pal;
import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.color.Color;

@ -1,5 +1,6 @@
package mightypork.gamecore.util.math.color.pal; package mightypork.gamecore.util.math.color.pal;
import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.color.Color;

@ -1,5 +1,6 @@
package mightypork.gamecore.util.math.color.pal; package mightypork.gamecore.util.math.color.pal;
import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.color.Color;

@ -1,5 +1,6 @@
package mightypork.gamecore.util.math.color.pal; package mightypork.gamecore.util.math.color.pal;
import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.color.Color;

@ -54,7 +54,8 @@ public abstract class Animator extends Num implements Updateable, Pauseable {
} }
public void start() { public void start()
{
resume(); resume();
} }
@ -78,17 +79,22 @@ public abstract class Animator extends Num implements Updateable, Pauseable {
numAnim.reset(); numAnim.reset();
} }
public void restart() {
public void restart()
{
reset(); reset();
nextCycle(numAnim); nextCycle(numAnim);
} }
public void setDuration(double secs) { public void setDuration(double secs)
{
numAnim.setDefaultDuration(secs); numAnim.setDefaultDuration(secs);
} }
public double getDuration() {
public double getDuration()
{
return numAnim.getDefaultDuration(); return numAnim.getDefaultDuration();
} }
@ -111,13 +117,17 @@ public abstract class Animator extends Num implements Updateable, Pauseable {
return num.value(); return num.value();
} }
public void setProgress(double value) {
double target = numAnim.getEnd(); public void setProgress(double value)
{
final double target = numAnim.getEnd();
numAnim.setTo(Calc.clamp(value, lowValue, highValue)); numAnim.setTo(Calc.clamp(value, lowValue, highValue));
numAnim.animate(target, numAnim.getDefaultDuration()); numAnim.animate(target, numAnim.getDefaultDuration());
} }
public double getProgress() {
public double getProgress()
{
return numAnim.value(); return numAnim.value();
} }
} }

@ -9,7 +9,9 @@ public abstract class TaskRepeater extends AnimatorRewind implements Runnable, E
private boolean enabled = true; private boolean enabled = true;
public TaskRepeater(double period) {
public TaskRepeater(double period)
{
super(period); super(period);
} }
@ -21,18 +23,21 @@ public abstract class TaskRepeater extends AnimatorRewind implements Runnable, E
super.nextCycle(anim); super.nextCycle(anim);
} }
@Override @Override
public void enable(boolean yes) public void enable(boolean yes)
{ {
this.enabled = yes; this.enabled = yes;
} }
@Override @Override
public boolean isEnabled() public boolean isEnabled()
{ {
return enabled; return enabled;
} }
@Override @Override
public void update(double delta) public void update(double delta)
{ {

@ -1,5 +1,6 @@
package mightypork.gamecore.util.strings; package mightypork.gamecore.util.strings;
/** /**
* String provider with constant string * String provider with constant string
* *

@ -13,7 +13,7 @@ import mightypork.rogue.world.WorldProvider;
public class ScreenGame extends LayeredScreen { public class ScreenGame extends LayeredScreen {
private Random rand = new Random(); private final Random rand = new Random();
public ScreenGame(AppAccess app) public ScreenGame(AppAccess app)

@ -24,7 +24,8 @@ class MenuButton extends ClickableComponent {
private final Color color; private final Color color;
public MenuButton(String text, Color color) { public MenuButton(String text, Color color)
{
this.color = color; this.color = color;
this.painter = new TextPainter(font, AlignX.CENTER, this.color, text); this.painter = new TextPainter(font, AlignX.CENTER, this.color, text);

@ -18,7 +18,8 @@ import mightypork.rogue.Res;
class MenuLayer extends ScreenLayer { class MenuLayer extends ScreenLayer {
public MenuLayer(Screen screen) { public MenuLayer(Screen screen)
{
super(screen); super(screen);
init(); init();
@ -39,7 +40,7 @@ class MenuLayer extends ScreenLayer {
root.add(layout); root.add(layout);
int r = 0; int r = 0;
TextPainter tp = new TextPainter(Res.getFont("main_menu_title"), AlignX.CENTER, COMMODORE.PURPLE, "Rogue!"); final TextPainter tp = new TextPainter(Res.getFont("main_menu_title"), AlignX.CENTER, COMMODORE.PURPLE, "Rogue!");
layout.put(tp, r, 0, 3, 1); layout.put(tp, r, 0, 3, 1);
r += 5; r += 5;

@ -7,7 +7,8 @@ import mightypork.gamecore.gui.screens.LayeredScreen;
public class ScreenTestBouncy extends LayeredScreen { public class ScreenTestBouncy extends LayeredScreen {
public ScreenTestBouncy(AppAccess app) { public ScreenTestBouncy(AppAccess app)
{
super(app); super(app);
addLayer(new LayerBouncyBoxes(this)); addLayer(new LayerBouncyBoxes(this));

@ -1,5 +1,6 @@
package mightypork.rogue.world.entity; package mightypork.rogue.world.entity;
import java.io.IOException; import java.io.IOException;
import mightypork.gamecore.util.ion.IonBundle; import mightypork.gamecore.util.ion.IonBundle;
@ -9,7 +10,8 @@ import mightypork.gamecore.util.math.timing.TaskRepeater;
public abstract class AiTimer extends TaskRepeater implements IonObjBundled { public abstract class AiTimer extends TaskRepeater implements IonObjBundled {
public AiTimer(double duration) { public AiTimer(double duration)
{
super(duration); super(duration);
} }
@ -21,7 +23,7 @@ public abstract class AiTimer extends TaskRepeater implements IonObjBundled {
@Override @Override
public void load(IonBundle bundle) throws IOException public void load(IonBundle bundle) throws IOException
{ {
boolean wasPaused = bundle.get("paused", isPaused()); final boolean wasPaused = bundle.get("paused", isPaused());
if (wasPaused) { if (wasPaused) {
pause(); pause();
} else { } else {

@ -41,7 +41,8 @@ public abstract class Entity implements IonObjBundled, Updateable {
public final EntityModuleHealth health = new EntityModuleHealth(this); public final EntityModuleHealth health = new EntityModuleHealth(this);
public Entity(EntityModel model, int eid) { public Entity(EntityModel model, int eid)
{
this.entityId = eid; this.entityId = eid;
this.model = model; this.model = model;
@ -57,13 +58,13 @@ public abstract class Entity implements IonObjBundled, Updateable {
{ {
bundle.put("eid", entityId); bundle.put("eid", entityId);
IonBundle modulesBundle = new IonBundle(); final IonBundle modulesBundle = new IonBundle();
for (final Entry<String, EntityModule> entry : modules.entrySet()) { for (final Entry<String, EntityModule> entry : modules.entrySet()) {
modulesBundle.putBundled(entry.getKey(), entry.getValue()); modulesBundle.putBundled(entry.getKey(), entry.getValue());
} }
bundle.put("modules", modulesBundle); bundle.put("modules", modulesBundle);
IonBundle extra = new IonBundle(); final IonBundle extra = new IonBundle();
saveExtra(extra); saveExtra(extra);
bundle.put("extra", extra); bundle.put("extra", extra);
} }
@ -81,13 +82,13 @@ public abstract class Entity implements IonObjBundled, Updateable {
entityId = bundle.get("eid", -1); entityId = bundle.get("eid", -1);
if (entityId < 0) throw new IllegalValueException("Bad entity id: " + entityId); if (entityId < 0) throw new IllegalValueException("Bad entity id: " + entityId);
IonBundle modulesBundle = bundle.get("modules", new IonBundle()); final IonBundle modulesBundle = bundle.get("modules", new IonBundle());
for (final Entry<String, EntityModule> entry : modules.entrySet()) { for (final Entry<String, EntityModule> entry : modules.entrySet()) {
modulesBundle.loadBundled(entry.getKey(), entry.getValue()); modulesBundle.loadBundled(entry.getKey(), entry.getValue());
} }
IonBundle extra = bundle.get("extra", new IonBundle()); final IonBundle extra = bundle.get("extra", new IonBundle());
loadExtra(extra); loadExtra(extra);
} }
@ -100,9 +101,7 @@ public abstract class Entity implements IonObjBundled, Updateable {
protected final void addModule(String key, EntityModule module) protected final void addModule(String key, EntityModule module)
{ {
if (modules.containsKey(key)) { if (modules.containsKey(key)) { throw new RuntimeException("Entity module " + key + " already defined."); }
throw new RuntimeException("Entity module " + key + " already defined.");
}
modules.put(key, module); modules.put(key, module);
} }

@ -21,10 +21,12 @@ public abstract class EntityModule implements IonObjBundled, Updateable {
protected final Random rand = new Random(); protected final Random rand = new Random();
public EntityModule(Entity entity) { public EntityModule(Entity entity)
{
this.entity = entity; this.entity = entity;
} }
public abstract boolean isModuleSaved(); public abstract boolean isModuleSaved();

@ -24,7 +24,7 @@ public class MonsterAi extends EntityModule implements EntityMoveListener {
private boolean sleeping = true; private boolean sleeping = true;
private boolean chasing = false; private boolean chasing = false;
private AiTimer timerFindPrey = new AiTimer(3) { private final AiTimer timerFindPrey = new AiTimer(3) {
@Override @Override
public void run() public void run()
@ -34,7 +34,7 @@ public class MonsterAi extends EntityModule implements EntityMoveListener {
} }
}; };
private AiTimer timerSleepStart = new AiTimer(10) { private final AiTimer timerSleepStart = new AiTimer(10) {
@Override @Override
public void run() public void run()
@ -49,7 +49,8 @@ public class MonsterAi extends EntityModule implements EntityMoveListener {
private int targetId = -1; private int targetId = -1;
public MonsterAi(final Entity entity) { public MonsterAi(final Entity entity)
{
super(entity); super(entity);
pathfcNoDoor = new PathFindingContextProxy(entity.getPathfindingContext()) { pathfcNoDoor = new PathFindingContextProxy(entity.getPathfindingContext()) {
@ -57,7 +58,7 @@ public class MonsterAi extends EntityModule implements EntityMoveListener {
@Override @Override
public boolean isAccessible(Coord pos) public boolean isAccessible(Coord pos)
{ {
Tile t = entity.getLevel().getTile(pos); final Tile t = entity.getLevel().getTile(pos);
if (t.isDoor()) return false; if (t.isDoor()) return false;
return super.isAccessible(pos); return super.isAccessible(pos);
@ -71,14 +72,13 @@ public class MonsterAi extends EntityModule implements EntityMoveListener {
{ {
if (rand.nextInt(3) == 0) return; // not hungry right now if (rand.nextInt(3) == 0) return; // not hungry right now
Entity prey = entity.getLevel().getClosestEntity(entity, EntityType.PLAYER, getScanRadius()); final Entity prey = entity.getLevel().getClosestEntity(entity, EntityType.PLAYER, getScanRadius());
if (prey != null) { if (prey != null) {
// check if reachable without leaving room // check if reachable without leaving room
List<Coord> noDoorPath = PathFinder.findPath(pathfcNoDoor, entity.getCoord(), prey.getCoord()); final List<Coord> noDoorPath = PathFinder.findPath(pathfcNoDoor, entity.getCoord(), prey.getCoord());
if (noDoorPath == null) { if (noDoorPath == null) { return; // cant reach, give up
return; // cant reach, give up
} }
startChasing(prey); startChasing(prey);
@ -136,7 +136,7 @@ public class MonsterAi extends EntityModule implements EntityMoveListener {
public void onStepFinished() public void onStepFinished()
{ {
if (chasing) { if (chasing) {
Entity prey = entity.getLevel().getEntity(targetId); final Entity prey = entity.getLevel().getEntity(targetId);
if (prey == null || prey.isDead()) { if (prey == null || prey.isDead()) {
stopChasing(); stopChasing();
return; return;
@ -153,13 +153,13 @@ public class MonsterAi extends EntityModule implements EntityMoveListener {
private void stepTowardsPrey(Entity prey) private void stepTowardsPrey(Entity prey)
{ {
// if close enough // if close enough
Coord preyPos = prey.getCoord(); final Coord preyPos = prey.getCoord();
if (preyPos.dist(entity.getCoord()) <= 1.5) { if (preyPos.dist(entity.getCoord()) <= 1.5) {
attackPrey(prey); attackPrey(prey);
return; return;
} }
List<Step> preyPath = getPathToPrey(prey); final List<Step> preyPath = getPathToPrey(prey);
if (preyPath.size() > getPreyAbandonDistance()) { if (preyPath.size() > getPreyAbandonDistance()) {
stopChasing(); stopChasing();
@ -176,7 +176,8 @@ public class MonsterAi extends EntityModule implements EntityMoveListener {
} }
protected int getAttackStrength() { protected int getAttackStrength()
{
return 1; // For override return 1; // For override
} }

@ -14,7 +14,8 @@ public class PlayerEntity extends Entity {
class PlayerAi extends EntityModule implements EntityMoveListener { class PlayerAi extends EntityModule implements EntityMoveListener {
public PlayerAi(Entity entity) { public PlayerAi(Entity entity)
{
super(entity); super(entity);
} }
@ -52,7 +53,8 @@ public class PlayerEntity extends Entity {
private final PlayerAi ai = new PlayerAi(this); private final PlayerAi ai = new PlayerAi(this);
public PlayerEntity(EntityModel model, int eid) { public PlayerEntity(EntityModel model, int eid)
{
super(model, eid); super(model, eid);
pos.setStepTime(0.25); pos.setStepTime(0.25);
@ -72,9 +74,7 @@ public class PlayerEntity extends Entity {
public int getCost(Coord from, Coord to) public int getCost(Coord from, Coord to)
{ {
if (!getLevel().getTile(pos.getCoord()).isExplored()) { if (!getLevel().getTile(pos.getCoord()).isExplored()) { return 1000; }
return 1000;
}
return super.getCost(from, to); return super.getCost(from, to);
@ -104,6 +104,7 @@ public class PlayerEntity extends Entity {
return renderer; return renderer;
} }
@Override @Override
public EntityType getType() public EntityType getType()
{ {

@ -10,9 +10,11 @@ public abstract class SimpleMonster extends Entity {
/** Navigation PFC */ /** Navigation PFC */
private EntityPathfindingContext pathfc; private EntityPathfindingContext pathfc;
private EntityModule ai = new MonsterAi(this); private final EntityModule ai = new MonsterAi(this);
public SimpleMonster(EntityModel model, int eid) {
public SimpleMonster(EntityModel model, int eid)
{
super(model, eid); super(model, eid);
addModule("ai", ai); addModule("ai", ai);
@ -29,6 +31,7 @@ public abstract class SimpleMonster extends Entity {
return pathfc; return pathfc;
} }
@Override @Override
public EntityType getType() public EntityType getType()
{ {

@ -12,7 +12,8 @@ import mightypork.rogue.world.entity.EntityModule;
public class EntityModuleHealth extends EntityModule { public class EntityModuleHealth extends EntityModule {
public EntityModuleHealth(Entity entity) { public EntityModuleHealth(Entity entity)
{
super(entity); super(entity);
} }

@ -59,6 +59,7 @@ public class EntityModulePosition extends EntityModule {
stepTime = bundle.get("step_time", stepTime); stepTime = bundle.get("step_time", stepTime);
} }
@Override @Override
public boolean isModuleSaved() public boolean isModuleSaved()
{ {

@ -1,8 +1,6 @@
package mightypork.rogue.world.entity.modules; package mightypork.rogue.world.entity.modules;
public interface EntityMoveListener { public interface EntityMoveListener {
/** /**

@ -19,5 +19,6 @@ public interface MapTheme {
TileModel door(); TileModel door();
TileModel passage(); TileModel passage();
} }

@ -4,11 +4,10 @@ package mightypork.rogue.world.gen.rooms;
import java.util.Random; import java.util.Random;
import mightypork.gamecore.util.math.algo.Coord; import mightypork.gamecore.util.math.algo.Coord;
import mightypork.gamecore.util.math.algo.Sides; import mightypork.rogue.world.gen.MapTheme;
import mightypork.rogue.world.gen.RoomBuilder; import mightypork.rogue.world.gen.RoomBuilder;
import mightypork.rogue.world.gen.RoomDesc; import mightypork.rogue.world.gen.RoomDesc;
import mightypork.rogue.world.gen.ScratchMap; import mightypork.rogue.world.gen.ScratchMap;
import mightypork.rogue.world.gen.MapTheme;
public class DeadEndRoom implements RoomBuilder { public class DeadEndRoom implements RoomBuilder {
@ -16,8 +15,8 @@ public class DeadEndRoom implements RoomBuilder {
@Override @Override
public RoomDesc buildToFit(ScratchMap map, MapTheme theme, Random rand, Coord center) public RoomDesc buildToFit(ScratchMap map, MapTheme theme, Random rand, Coord center)
{ {
Coord low = center.add(-1, -1); final Coord low = center.add(-1, -1);
Coord high = center; final Coord high = center;
if (!map.isClear(low, high)) return null; if (!map.isClear(low, high)) return null;
map.set(center, theme.floor()); map.set(center, theme.floor());

@ -5,10 +5,10 @@ import java.util.Random;
import mightypork.gamecore.util.math.algo.Coord; import mightypork.gamecore.util.math.algo.Coord;
import mightypork.gamecore.util.math.algo.Sides; import mightypork.gamecore.util.math.algo.Sides;
import mightypork.rogue.world.gen.MapTheme;
import mightypork.rogue.world.gen.RoomBuilder; import mightypork.rogue.world.gen.RoomBuilder;
import mightypork.rogue.world.gen.RoomDesc; import mightypork.rogue.world.gen.RoomDesc;
import mightypork.rogue.world.gen.ScratchMap; import mightypork.rogue.world.gen.ScratchMap;
import mightypork.rogue.world.gen.MapTheme;
import mightypork.rogue.world.tile.TileModel; import mightypork.rogue.world.tile.TileModel;
@ -30,7 +30,7 @@ public class SimpleRectRoom implements RoomBuilder {
map.border(min, max, theme.wall()); map.border(min, max, theme.wall());
map.protect(min, max); map.protect(min, max);
boolean holes = rand.nextInt(4) == 0; final boolean holes = rand.nextInt(4) == 0;
for (int i = 0; i <= 2 + rand.nextInt(6); i++) { for (int i = 0; i <= 2 + rand.nextInt(6); i++) {
final Coord door = min.copy(); final Coord door = min.copy();

@ -2,7 +2,11 @@ package mightypork.rogue.world.level;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import mightypork.gamecore.logging.Log; import mightypork.gamecore.logging.Log;
import mightypork.gamecore.util.ion.IonBundle; import mightypork.gamecore.util.ion.IonBundle;
@ -21,7 +25,6 @@ import mightypork.rogue.world.entity.Entity;
import mightypork.rogue.world.entity.EntityType; import mightypork.rogue.world.entity.EntityType;
import mightypork.rogue.world.tile.Tile; import mightypork.rogue.world.tile.Tile;
import mightypork.rogue.world.tile.TileModel; import mightypork.rogue.world.tile.TileModel;
import mightypork.rogue.world.tile.TileType;
import mightypork.rogue.world.tile.Tiles; import mightypork.rogue.world.tile.Tiles;
@ -51,11 +54,13 @@ public class Level implements MapAccess, IonObjBinary {
private transient NoiseGen noiseGen; private transient NoiseGen noiseGen;
public Level() { public Level()
{
} }
public Level(int width, int height) { public Level(int width, int height)
{
size.setTo(width, height); size.setTo(width, height);
buildArray(); buildArray();
} }
@ -290,10 +295,10 @@ public class Level implements MapAccess, IonObjBinary {
getTile(pos).setOccupied(false); getTile(pos).setOccupied(false);
} }
public void cleanCorpses() {
for(Iterator<Entity> i = entitySet.iterator(); i.hasNext();) {
Entity e = i.next();
public void cleanCorpses()
{
for (final Entity e : entitySet) {
if (e.isDead() && e.canRemoveCorpse()) { if (e.isDead() && e.canRemoveCorpse()) {
e.onCorpseRemoved(); e.onCorpseRemoved();
removeEntity(e); removeEntity(e);
@ -301,6 +306,7 @@ public class Level implements MapAccess, IonObjBinary {
} }
} }
public Collection<Entity> getEntities() public Collection<Entity> getEntities()
{ {
return entitySet; return entitySet;
@ -387,12 +393,12 @@ public class Level implements MapAccess, IonObjBinary {
Entity closest = null; Entity closest = null;
double minDist = Double.MAX_VALUE; double minDist = Double.MAX_VALUE;
for (Entity e : entitySet) { for (final Entity e : entitySet) {
if (e == self) continue; if (e == self) continue;
if (e.isDead()) continue; if (e.isDead()) continue;
if (e.getType() == type) { if (e.getType() == type) {
double dist = e.getCoord().dist(self.getCoord()); final double dist = e.getCoord().dist(self.getCoord());
if (dist <= radius && dist < minDist) { if (dist <= radius && dist < minDist) {
minDist = dist; minDist = dist;

@ -2,7 +2,6 @@ package mightypork.rogue.world.tile.renderers;
import mightypork.gamecore.render.Render; import mightypork.gamecore.render.Render;
import mightypork.gamecore.resources.textures.TxQuad;
import mightypork.gamecore.resources.textures.TxSheet; import mightypork.gamecore.resources.textures.TxSheet;
import mightypork.gamecore.util.math.constraints.rect.Rect; import mightypork.gamecore.util.math.constraints.rect.Rect;
import mightypork.rogue.Res; import mightypork.rogue.Res;

@ -1,5 +1,6 @@
package mightypork.rogue.world.tile.tiles; package mightypork.rogue.world.tile.tiles;
import mightypork.rogue.world.tile.TileModel; import mightypork.rogue.world.tile.TileModel;
import mightypork.rogue.world.tile.TileRenderer; import mightypork.rogue.world.tile.TileRenderer;
import mightypork.rogue.world.tile.TileType; import mightypork.rogue.world.tile.TileType;
@ -12,16 +13,19 @@ import mightypork.rogue.world.tile.TileType;
*/ */
public class WallPassageTile extends SolidTile { public class WallPassageTile extends SolidTile {
public WallPassageTile(TileModel model, TileRenderer renderer) { public WallPassageTile(TileModel model, TileRenderer renderer)
{
super(model, renderer); super(model, renderer);
} }
@Override @Override
public TileType getType() public TileType getType()
{ {
return TileType.PASSAGE; return TileType.PASSAGE;
} }
@Override @Override
public boolean isWalkable() public boolean isWalkable()
{ {

Loading…
Cancel
Save