Cache plant piece asset paths
This commit is contained in:
parent
7f65913762
commit
1742b04eec
@ -24,6 +24,7 @@ EnumMap<Plant::RotationType> const Plant::RotationTypeNames{
|
|||||||
|
|
||||||
Plant::PlantPiece::PlantPiece() {
|
Plant::PlantPiece::PlantPiece() {
|
||||||
image = "";
|
image = "";
|
||||||
|
imagePath = AssetPath();
|
||||||
offset = {};
|
offset = {};
|
||||||
segmentIdx = 0;
|
segmentIdx = 0;
|
||||||
structuralSegment = 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))
|
if ((m_ceiling && offset[1] <= m_tileDamageY) || (!m_ceiling && offset[1] + size[1] >= m_tileDamageY))
|
||||||
offset[0] += damageXOffset;
|
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)
|
if (plantPiece.flip)
|
||||||
drawable.scale(Vec2F(-1, 1));
|
drawable.scale(Vec2F(-1, 1));
|
||||||
|
|
||||||
@ -864,6 +865,8 @@ Json Plant::writePiecesToJson() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Plant::validatePieces() {
|
void Plant::validatePieces() {
|
||||||
|
for (auto& piece : m_pieces)
|
||||||
|
piece.imagePath = piece.image;
|
||||||
if (!m_piecesScanned) {
|
if (!m_piecesScanned) {
|
||||||
scanSpacesAndRoots();
|
scanSpacesAndRoots();
|
||||||
calcBoundBox();
|
calcBoundBox();
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "StarTileEntity.hpp"
|
#include "StarTileEntity.hpp"
|
||||||
#include "StarPlantDatabase.hpp"
|
#include "StarPlantDatabase.hpp"
|
||||||
#include "StarInspectableEntity.hpp"
|
#include "StarInspectableEntity.hpp"
|
||||||
|
#include "StarAssetPath.hpp"
|
||||||
|
|
||||||
namespace Star {
|
namespace Star {
|
||||||
|
|
||||||
@ -38,6 +39,7 @@ public:
|
|||||||
|
|
||||||
struct PlantPiece {
|
struct PlantPiece {
|
||||||
PlantPiece();
|
PlantPiece();
|
||||||
|
AssetPath imagePath;
|
||||||
String image;
|
String image;
|
||||||
Vec2U imageSize;
|
Vec2U imageSize;
|
||||||
Vec2F offset;
|
Vec2F offset;
|
||||||
|
Loading…
Reference in New Issue
Block a user