diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-03 18:22:31 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-03 18:22:31 +1000 |
commit | 1742b04eec86a581707fcf622a8e91e7fddbd091 (patch) | |
tree | d87e6e6c4dfd15ff10933cc086846380e4963814 /source/game/StarPlant.cpp | |
parent | 7f659137622d01326924ec06e50feaf0411fce9e (diff) |
Cache plant piece asset paths
Diffstat (limited to 'source/game/StarPlant.cpp')
-rw-r--r-- | source/game/StarPlant.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/source/game/StarPlant.cpp b/source/game/StarPlant.cpp index 4ba8ada..4690722 100644 --- a/source/game/StarPlant.cpp +++ b/source/game/StarPlant.cpp @@ -24,6 +24,7 @@ EnumMap<Plant::RotationType> const Plant::RotationTypeNames{ Plant::PlantPiece::PlantPiece() { image = ""; + imagePath = AssetPath(); offset = {}; segmentIdx = 0; structuralSegment = 0; @@ -746,7 +747,7 @@ void Plant::render(RenderCallback* renderCallback) { if ((m_ceiling && offset[1] <= m_tileDamageY) || (!m_ceiling && offset[1] + size[1] >= m_tileDamageY)) offset[0] += damageXOffset; - auto drawable = Drawable::makeImage(plantPiece.image, 1.0f / TilePixels, false, offset); + auto drawable = Drawable::makeImage(plantPiece.imagePath, 1.0f / TilePixels, false, offset); if (plantPiece.flip) drawable.scale(Vec2F(-1, 1)); @@ -864,6 +865,8 @@ Json Plant::writePiecesToJson() const { } void Plant::validatePieces() { + for (auto& piece : m_pieces) + piece.imagePath = piece.image; if (!m_piecesScanned) { scanSpacesAndRoots(); calcBoundBox(); |