mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-07-31 04:05:26 +02:00
Legger til triple lasere
This commit is contained in:
@@ -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;
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user