2024-02-25 14:46:47 +00:00
|
|
|
#pragma once
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
#include "StarVector.hpp"
|
|
|
|
#include "StarSet.hpp"
|
|
|
|
#include "StarMap.hpp"
|
|
|
|
#include "StarRandom.hpp"
|
|
|
|
#include "StarGameTypes.hpp"
|
|
|
|
#include "StarWorldTiles.hpp"
|
|
|
|
|
|
|
|
namespace Star {
|
|
|
|
|
|
|
|
STAR_CLASS(MaterialDatabase);
|
|
|
|
STAR_CLASS(FallingBlocksFacade);
|
|
|
|
STAR_CLASS(FallingBlocksAgent);
|
|
|
|
|
|
|
|
enum class FallingBlockType {
|
|
|
|
Immovable,
|
|
|
|
Falling,
|
|
|
|
Cascading,
|
|
|
|
Open
|
|
|
|
};
|
|
|
|
|
|
|
|
class FallingBlocksFacade {
|
|
|
|
public:
|
|
|
|
virtual ~FallingBlocksFacade() = default;
|
|
|
|
|
|
|
|
virtual FallingBlockType blockType(Vec2I const& pos) = 0;
|
|
|
|
virtual void moveBlock(Vec2I const& from, Vec2I const& to) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FallingBlocksAgent {
|
|
|
|
public:
|
|
|
|
FallingBlocksAgent(FallingBlocksFacadePtr worldFacade);
|
|
|
|
|
|
|
|
void update();
|
|
|
|
|
|
|
|
void visitLocation(Vec2I const& location);
|
|
|
|
void visitRegion(RectI const& region);
|
|
|
|
|
|
|
|
private:
|
|
|
|
FallingBlocksFacadePtr m_facade;
|
|
|
|
float m_immediateUpwardPropagateProbability;
|
|
|
|
HashSet<Vec2I> m_pending;
|
|
|
|
RandomSource m_random;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|