parent
							
								
									66adc1ffa9
								
							
						
					
					
						commit
						c74869d3b7
					
				| 
		 Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.9 KiB  | 
									
										Binary file not shown.
									
								
							
						@ -0,0 +1,20 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.world.events; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import mightypork.gamecore.eventbus.BusEvent; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * Player wants to go up | 
				
			||||||
 | 
					 *  | 
				
			||||||
 | 
					 * @author MightyPork | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					public class WorldAscendRequest extends BusEvent<WorldAscendRequestListener> { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						protected void handleBy(WorldAscendRequestListener handler) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							handler.onAscendRequest(); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,10 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.world.events; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public interface WorldAscendRequestListener { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						/** | 
				
			||||||
 | 
						 * Player clicked up-stairs | 
				
			||||||
 | 
						 */ | 
				
			||||||
 | 
						void onAscendRequest(); | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,15 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.world.events; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import mightypork.gamecore.eventbus.BusEvent; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class WorldDescendRequest extends BusEvent<WorldDescendRequestListener> { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						protected void handleBy(WorldDescendRequestListener handler) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							handler.onDescendRequest(); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,10 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.world.events; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public interface WorldDescendRequestListener { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						/** | 
				
			||||||
 | 
						 * Player clicked down-stairs | 
				
			||||||
 | 
						 */ | 
				
			||||||
 | 
						void onDescendRequest(); | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,60 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.world.gen.rooms; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.Random; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.algo.Coord; | 
				
			||||||
 | 
					import mightypork.rogue.world.gen.MapTheme; | 
				
			||||||
 | 
					import mightypork.rogue.world.gen.ScratchMap; | 
				
			||||||
 | 
					import mightypork.rogue.world.gen.TileProtectLevel; | 
				
			||||||
 | 
					import mightypork.rogue.world.tile.TileModel; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class EntranceRoom extends AbstractRectRoom { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						protected Coord getInnerSize(Random rand) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							return Coord.make(3 + rand.nextInt(2) * 2, 3 + rand.nextInt(2) * 3); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						protected TileProtectLevel getWallProtectionLevel() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							return TileProtectLevel.WEAK; | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						protected TileModel getDoorType(MapTheme theme, Random rand) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							switch (rand.nextInt(5)) { | 
				
			||||||
 | 
								case 0: | 
				
			||||||
 | 
								case 1: | 
				
			||||||
 | 
									return theme.passage(); | 
				
			||||||
 | 
								case 2: | 
				
			||||||
 | 
									return theme.secretDoor(); | 
				
			||||||
 | 
								default: | 
				
			||||||
 | 
									return theme.door(); | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						protected void buildExtras(ScratchMap map, MapTheme theme, Random rand, Coord min, Coord max) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							final Coord c = Coord.make((max.x + min.x) / 2, (max.y + min.y) / 2); | 
				
			||||||
 | 
							map.set(c, theme.entrance()); | 
				
			||||||
 | 
							map.protect(c, c, TileProtectLevel.STRONG); | 
				
			||||||
 | 
							map.setEntrance(c.add(1, 0)); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						protected int getDoorCount(Random rand) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							return 1 + rand.nextInt(4); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,52 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.world.gen.rooms; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.Random; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.algo.Coord; | 
				
			||||||
 | 
					import mightypork.rogue.world.gen.MapTheme; | 
				
			||||||
 | 
					import mightypork.rogue.world.gen.ScratchMap; | 
				
			||||||
 | 
					import mightypork.rogue.world.gen.TileProtectLevel; | 
				
			||||||
 | 
					import mightypork.rogue.world.tile.TileModel; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class ExitRoom extends AbstractRectRoom { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						protected Coord getInnerSize(Random rand) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							return Coord.make(3, 3); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						protected TileProtectLevel getWallProtectionLevel() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							return TileProtectLevel.NONE; | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						protected TileModel getDoorType(MapTheme theme, Random rand) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							return null; | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						protected void buildExtras(ScratchMap map, MapTheme theme, Random rand, Coord min, Coord max) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							final Coord c = Coord.make((max.x + min.x) / 2, (max.y + min.y) / 2); | 
				
			||||||
 | 
							map.set(c, theme.exit()); | 
				
			||||||
 | 
							map.protect(c, c, TileProtectLevel.STRONG); | 
				
			||||||
 | 
							map.setExit(c.add(-1, 0)); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						protected int getDoorCount(Random rand) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							return 0; | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -1,109 +0,0 @@ | 
				
			|||||||
package mightypork.rogue.world.level; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.eventbus.events.Updateable; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.algo.Coord; | 
					 | 
				
			||||||
import mightypork.rogue.world.World; | 
					 | 
				
			||||||
import mightypork.rogue.world.entity.Entity; | 
					 | 
				
			||||||
import mightypork.rogue.world.tile.Tile; | 
					 | 
				
			||||||
import mightypork.rogue.world.tile.TileModel; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Level full access | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author MightyPork | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public interface LevelAccess extends LevelReadAccess, Updateable { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Mark tile and surrounding area as explored | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param center center the explored tile | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public abstract void explore(Coord center); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Assign a world | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param world new world | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public abstract void setWorld(World world); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Set level entry point | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param pos pos where the player enters | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public abstract void setEnterPoint(Coord pos); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Mark tile as free (entity left) | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param pos tile pos | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public abstract void freeTile(Coord pos); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Mark tile as occupied (entity entered) | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param pos tile pos | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public abstract void occupyTile(Coord pos); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Remove an entity from the level, if present | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param eid entity id | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public abstract void removeEntity(int eid); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Remove an entity from the level, if present | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param entity entity | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public abstract void removeEntity(Entity entity); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Set level seed (used for visuals; the seed used for generation) | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param seed seed | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public abstract void setSeed(long seed); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Set tile at pos | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param pos tile pos | 
					 | 
				
			||||||
	 * @param tile the tile instance to set | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public abstract void setTile(Coord pos, Tile tile); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Fill whole map with tile type | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param model tile model | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public abstract void fill(TileModel model); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Try to add entity at given pos | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param entity the entity | 
					 | 
				
			||||||
	 * @param pos pos | 
					 | 
				
			||||||
	 * @return true if added (false if void, wall etc) | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public abstract boolean addEntity(Entity entity, Coord pos); | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,127 +0,0 @@ | 
				
			|||||||
package mightypork.rogue.world.level; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.util.Collection; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.algo.Coord; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.noise.NoiseGen; | 
					 | 
				
			||||||
import mightypork.rogue.world.World; | 
					 | 
				
			||||||
import mightypork.rogue.world.entity.Entity; | 
					 | 
				
			||||||
import mightypork.rogue.world.entity.EntityType; | 
					 | 
				
			||||||
import mightypork.rogue.world.tile.Tile; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public interface LevelReadAccess { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Ge tile at X,Y | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param pos | 
					 | 
				
			||||||
	 * @return tile | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	Tile getTile(Coord pos); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @return map width in tiles | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	int getWidth(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @return map height in tiles | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	int getHeight(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @return map seed | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	long getSeed(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @return level-specific noise generator | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	NoiseGen getNoiseGen(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Check if entity is in the level | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param entity entity | 
					 | 
				
			||||||
	 * @return is present | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	boolean isEntityPresent(Entity entity); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Check if entity is in the level | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param eid entity ID | 
					 | 
				
			||||||
	 * @return true if present | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	boolean isEntityPresent(int eid); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Get entity of type closest to coord | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param self the querying entity - to provide position, and to be excluded | 
					 | 
				
			||||||
	 *            from the search. | 
					 | 
				
			||||||
	 * @param type wanted entity type | 
					 | 
				
			||||||
	 * @param radius search radius; -1 for unlimited. | 
					 | 
				
			||||||
	 * @return | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	Entity getClosestEntity(Entity self, EntityType type, double radius); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Get the level's world | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @return world | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	World getWorld(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Get location where the player enters the level | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @return pos | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	Coord getEnterPoint(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Check entity on tile | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param pos tile coord | 
					 | 
				
			||||||
	 * @return true if some entity is standing there | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	boolean isOccupied(Coord pos); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Check tile walkability | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param pos tile coord | 
					 | 
				
			||||||
	 * @return true if the tile is walkable by entity | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	boolean isWalkable(Coord pos); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Get entity by ID | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param eid entity ID | 
					 | 
				
			||||||
	 * @return the entity, or null | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	Entity getEntity(int eid); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @return all entities | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	Collection<Entity> getEntities(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -0,0 +1,33 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.world.tile.render; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import mightypork.gamecore.render.Render; | 
				
			||||||
 | 
					import mightypork.gamecore.resources.textures.TxQuad; | 
				
			||||||
 | 
					import mightypork.rogue.world.level.render.TileRenderContext; | 
				
			||||||
 | 
					import mightypork.rogue.world.tile.Tile; | 
				
			||||||
 | 
					import mightypork.rogue.world.tile.TileRenderer; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * Tile that spans across two tiles visually (two-high) | 
				
			||||||
 | 
					 *  | 
				
			||||||
 | 
					 * @author MightyPork | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					public class OneFrameTileRenderer extends TileRenderer { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						private final TxQuad txq; | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public OneFrameTileRenderer(Tile tile, TxQuad txq) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							super(tile); | 
				
			||||||
 | 
							this.txq = txq; | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						public void renderTile(TileRenderContext context) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							Render.quadTextured(context.getRect(), txq); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,35 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.world.tile.render; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import mightypork.gamecore.render.Render; | 
				
			||||||
 | 
					import mightypork.gamecore.resources.textures.TxQuad; | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.constraints.rect.Rect; | 
				
			||||||
 | 
					import mightypork.rogue.world.level.render.TileRenderContext; | 
				
			||||||
 | 
					import mightypork.rogue.world.tile.Tile; | 
				
			||||||
 | 
					import mightypork.rogue.world.tile.TileRenderer; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * Tile that spans across two tiles visually (two-high) | 
				
			||||||
 | 
					 *  | 
				
			||||||
 | 
					 * @author MightyPork | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					public class TwoHighTileRenderer extends TileRenderer { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						private final TxQuad txq; | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public TwoHighTileRenderer(Tile tile, TxQuad txq) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							super(tile); | 
				
			||||||
 | 
							this.txq = txq; | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						public void renderTile(TileRenderContext context) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							final Rect rect = context.getRect(); | 
				
			||||||
 | 
							Render.quadTextured(rect.growUp(rect.height()), txq); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,34 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.world.tile.tiles; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.algo.Coord; | 
				
			||||||
 | 
					import mightypork.rogue.world.events.WorldAscendRequest; | 
				
			||||||
 | 
					import mightypork.rogue.world.tile.TileModel; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public abstract class TileBaseEntrance extends TileBaseStairs { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public TileBaseEntrance(TileModel model) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							super(model); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						public boolean onClick() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							Coord plpos = getWorld().getPlayerEntity().getCoord();		 | 
				
			||||||
 | 
							if(!plpos.equals(getLevel().getEnterPoint())) return false; | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							getEventBus().send(new WorldAscendRequest()); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							return true; | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						public boolean doesCastShadow() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							return false; | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,34 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.world.tile.tiles; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.algo.Coord; | 
				
			||||||
 | 
					import mightypork.rogue.world.events.WorldDescendRequest; | 
				
			||||||
 | 
					import mightypork.rogue.world.tile.TileModel; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public abstract class TileBaseExit extends TileBaseStairs { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public TileBaseExit(TileModel model) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							super(model); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						public boolean onClick() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							Coord plpos = getWorld().getPlayerEntity().getCoord();		 | 
				
			||||||
 | 
							if(!plpos.equals(getLevel().getExitPoint())) return false; | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							getEventBus().send(new WorldDescendRequest()); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							return true; | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						public boolean doesCastShadow() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							return false; | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,22 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.world.tile.tiles; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import mightypork.rogue.world.tile.TileModel; | 
				
			||||||
 | 
					import mightypork.rogue.world.tile.TileType; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public abstract class TileBaseStairs extends TileSolid { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public TileBaseStairs(TileModel model) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							super(model); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						public TileType getType() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							return TileType.STAIRS; | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,25 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.world.tile.tiles.brick; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import mightypork.rogue.Res; | 
				
			||||||
 | 
					import mightypork.rogue.world.tile.TileModel; | 
				
			||||||
 | 
					import mightypork.rogue.world.tile.TileRenderer; | 
				
			||||||
 | 
					import mightypork.rogue.world.tile.render.OneFrameTileRenderer; | 
				
			||||||
 | 
					import mightypork.rogue.world.tile.tiles.TileBaseEntrance; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class TileBrickEntrance extends TileBaseEntrance { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public TileBrickEntrance(TileModel model) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							super(model); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						protected TileRenderer makeRenderer() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							return new OneFrameTileRenderer(this, Res.txq("tile.brick.stairs.up")); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,25 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.world.tile.tiles.brick; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import mightypork.rogue.Res; | 
				
			||||||
 | 
					import mightypork.rogue.world.tile.TileModel; | 
				
			||||||
 | 
					import mightypork.rogue.world.tile.TileRenderer; | 
				
			||||||
 | 
					import mightypork.rogue.world.tile.render.OneFrameTileRenderer; | 
				
			||||||
 | 
					import mightypork.rogue.world.tile.tiles.TileBaseExit; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class TileBrickExit extends TileBaseExit { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public TileBrickExit(TileModel model) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							super(model); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						protected TileRenderer makeRenderer() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							return new OneFrameTileRenderer(this, Res.txq("tile.brick.stairs.down")); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
					} | 
				
			||||||
					Loading…
					
					
				
		Reference in new issue