Legger til triple lasere

This commit is contained in:
2020-04-27 14:10:52 +02:00
parent 2f7e9cf1fb
commit efb1e4c03f
7 changed files with 48 additions and 8 deletions

View File

@@ -150,7 +150,7 @@ public final class IOUtil {
direction = tile.getDirection();
} else if (element.getClass().isAssignableFrom(Wall.class)) {
Wall wall = (Wall) element;
hasRotatedTexture = true;
hasRotatedTexture = TextureConverterUtil.hasRotatedTexture(wall);
direction = wall.getDirection();
} else if (element.getClass().isAssignableFrom(Particle.class)) {
Particle particle = (Particle) element;

View File

@@ -34,6 +34,7 @@ public final class TextureConverterUtil {
private static Map<ParticleType, TextureConverterContainer> tileSheetParticleTextureMappings;
private static Map<ParticleType, Boolean> tileSheetParticleHasRotatedTextureMappings;
private static Map<WallType, TextureConverterContainer> tileSheetWallTextureMappings;
private static Map<WallType, Boolean> tileSheetWallHasRotatedTextureMappings;
private TextureConverterUtil() {
}
@@ -186,6 +187,25 @@ public final class TextureConverterUtil {
return tileSheetTileHasRotatedTextureMappings.get(tile.getTileType());
}
/**
* Checks whether a wall has textures for different rotations
*
* <p>For a wall without a rotated texture, the texture needs to be rotated when rendering.</p>
*
* @param wall The wall to check
* @return True if rotated versions of the texture exists. False otherwise
*/
public static boolean hasRotatedTexture(Wall wall) {
if (tileSheetWallTextureMappings == null) {
try {
loadTileMappings();
} catch (IOException e) {
e.printStackTrace();
}
}
return tileSheetWallHasRotatedTextureMappings.get(wall.getWallType());
}
/**
* Checks whether a particle has textures for different rotations
*
@@ -256,6 +276,7 @@ public final class TextureConverterUtil {
*/
private static synchronized void loadWallMappings() throws IOException {
tileSheetWallTextureMappings = new HashMap<>();
tileSheetWallHasRotatedTextureMappings = new HashMap<>();
InputStream fileStream = ResourceUtil.getResourceAsInputStream("texture_sheet_wall_mapping.txt");
BufferedReader reader = new BufferedReader(new InputStreamReader(fileStream));
String line;
@@ -263,7 +284,7 @@ public final class TextureConverterUtil {
String[] parameters = line.split(" ");
WallType type = WallType.valueOf(parameters[0]);
storeTextMappingInMap(parameters, type, tileSheetWallTextureMappings,
null);
tileSheetWallHasRotatedTextureMappings);
}
}