v1.4.4
This commit is contained in:
commit
9c94d113d3
10260 changed files with 1237388 additions and 0 deletions
50
source/game/StarFallingBlocksAgent.hpp
Normal file
50
source/game/StarFallingBlocksAgent.hpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
#ifndef STAR_FALLING_BLOCKS_AGENT_HPP
|
||||
#define STAR_FALLING_BLOCKS_AGENT_HPP
|
||||
|
||||
#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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue