36 lines
1.1 KiB
C++
36 lines
1.1 KiB
C++
#pragma once
|
|
#include "Entity.h"
|
|
#include <array>
|
|
|
|
class Waterline : public Entity {
|
|
private:
|
|
static constexpr int WATERLINE_Y = 5;
|
|
static constexpr char WATERLINE_COLOR = 'c';
|
|
static constexpr size_t NUM_WAVE_LAYERS = 4;
|
|
|
|
// Use arrays instead of vectors for fixed-size data
|
|
std::array<std::string, NUM_WAVE_LAYERS> shape;
|
|
std::array<std::string, NUM_WAVE_LAYERS> colorLines;
|
|
|
|
// Pre-compute shift operations
|
|
void shiftStringLeft(std::string &str);
|
|
void shiftStringRight(std::string &str);
|
|
|
|
public:
|
|
Waterline();
|
|
|
|
void update() noexcept override;
|
|
const std::vector<std::string> &getImage() const override;
|
|
const std::vector<std::string> &getMask() const override;
|
|
char getDefaultColor() const noexcept override { return WATERLINE_COLOR; }
|
|
|
|
bool shouldBeRemoved() const noexcept override { return false; }
|
|
std::unique_ptr<Entity> createReplacement() const override { return nullptr; }
|
|
int getPreferredLayer() const noexcept override { return 0; }
|
|
|
|
private:
|
|
// Cache vectors to avoid allocation each frame
|
|
mutable std::vector<std::string> cached_image;
|
|
mutable std::vector<std::string> cached_mask;
|
|
};
|