Skip to content

Commit

Permalink
Added default exterior tiling for backyard entities.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jantoom committed Nov 3, 2021
1 parent d431cde commit 49c220a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
5 changes: 3 additions & 2 deletions source/core/assets/maps/_floor_plans/floor_plan_43x43_0.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
defaultTile: [tile_wood_0, 0]
defaultInteriorTile: [tile_wood_0, 0]
defaultExteriorTile: [tile_grass_0, 0]
defaultWall: [object_wall_0, 0]
tileMap: {
_: [tile_grass_0, 0] // Grass
Expand Down Expand Up @@ -33,7 +34,7 @@
[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _],
[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _],
[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _],
[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, A, A, A, A, A, A, A, A, A, ., _, _, _, _, _, _, _, _, _, _, _, _, _, _],
[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, A, A, A, A, A, A, A, A, A, ., _, _, _, -, |, _, _, _, _, _, _, _, _, _],
[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, A, A, A, A, A, A, A, A, A, ., _, _, _, _, _, _, _, _, _, _, _, _, _, _],
[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, A, A, A, A, A, A, A, A, A, ., _, _, _, _, _, _, _, _, _, _, _, _, _, _],
[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, A, A, A, A, A, A, A, A, A, ., _, _, _, _, _, _, _, _, _, _, _, _, _, _],
Expand Down
3 changes: 2 additions & 1 deletion source/core/assets/maps/_floor_plans/floor_plan_43x43_1.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
defaultTile: [tile_wood_0, 0]
defaultInteriorTile: [tile_wood_0, 0]
defaultExteriorTile: [tile_grass_0, 0]
defaultWall: [object_wall_0, 0]
tileMap: {
_: [tile_grass_0, 0] // Grass
Expand Down
26 changes: 14 additions & 12 deletions source/core/src/main/com/deco2800/game/maps/Floor.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
*/
public class Floor extends RetroactiveArea implements Json.Serializable {
// Defined on deserialization
private ObjectDescription defaultTile;
private ObjectDescription defaultInteriorTile;
private ObjectDescription defaultExteriorTile;
private ObjectDescription defaultWall;
private ObjectMap<Character, ObjectDescription> tileMap;
private ObjectMap<Character, ObjectDescription> entityMap;
Expand Down Expand Up @@ -59,7 +60,7 @@ public void create() {
*/
private void createAllTiles() {
TextureRegion textureRegion = new TextureRegion(
ServiceLocator.getResourceService().getAsset(defaultTile.getData().getAssets()[0], Texture.class));
ServiceLocator.getResourceService().getAsset(defaultInteriorTile.getData().getAssets()[0], Texture.class));

TiledMapTileLayer layer = new TiledMapTileLayer(
dimensions.x, dimensions.y,
Expand All @@ -81,7 +82,7 @@ private void createAllTiles() {
}
ObjectDescription entityDesc = entityMap.get(symbol);
if (entityDesc != null && layer.getCell(x, y) == null) {
createGridTile(defaultTile, new GridPoint2(x, y), layer);
createGridTile(defaultExteriorTile, new GridPoint2(x, y), layer);
}
}
}
Expand Down Expand Up @@ -133,7 +134,7 @@ private void createAllEntities() {
*/
public void createGridTile(ObjectDescription tileDesc, GridPoint2 worldPos, TiledMapTileLayer layer) {
if (tileDesc == null) {
tileDesc = defaultTile;
tileDesc = defaultInteriorTile;
}
try {
TerrainTile tile = (TerrainTile) tileDesc.getData().getMethod().invoke(null, tileDesc, worldPos);
Expand Down Expand Up @@ -230,10 +231,6 @@ private void createBeds() {
bedPositions.add(playerBedPosition);
}

public ObjectDescription getDefaultTile() {
return defaultTile;
}

public ObjectDescription getDefaultWall() {
return defaultWall;
}
Expand Down Expand Up @@ -276,9 +273,14 @@ public void write(Json json) {
public void read(Json json, JsonValue jsonData) {
try {
JsonValue iterator = jsonData.child();
FileLoader.assertJsonValueName(iterator, "defaultTile");
FileLoader.assertJsonValueName(iterator, "defaultInteriorTile");
String[] desc = iterator.asStringArray();
defaultTile = new ObjectDescription(Home.getObject(desc[0]), Integer.parseInt(desc[1]));
defaultInteriorTile = new ObjectDescription(Home.getObject(desc[0]), Integer.parseInt(desc[1]));

iterator = iterator.next();
FileLoader.assertJsonValueName(iterator, "defaultExteriorTile");
desc = iterator.asStringArray();
defaultExteriorTile = new ObjectDescription(Home.getObject(desc[0]), Integer.parseInt(desc[1]));

iterator = iterator.next();
FileLoader.assertJsonValueName(iterator, "defaultWall");
Expand Down Expand Up @@ -332,7 +334,7 @@ public boolean equals(Object o) {
return false;
}
Floor floor = (Floor) o;
return Objects.equals(defaultTile, floor.defaultTile) &&
return Objects.equals(defaultInteriorTile, floor.defaultInteriorTile) &&
Objects.equals(defaultWall, floor.defaultWall) &&
Objects.equals(tileMap, floor.tileMap) &&
Objects.equals(entityMap, floor.entityMap) &&
Expand All @@ -343,7 +345,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
int result = Objects.hash(defaultTile, defaultWall, tileMap, entityMap, roomMap, dimensions);
int result = Objects.hash(defaultInteriorTile, defaultWall, tileMap, entityMap, roomMap, dimensions);
result = 31 * result + Arrays.deepHashCode(floorGrid);
return result;
}
Expand Down

0 comments on commit 49c220a

Please sign in to comment.