|
stmm-games-doc
0.32.0
|
Base class for run-time Blocks. More...

Public Types | |
| enum | MGMT_TYPE { MGMT_TYPE_INVALID = -1, MGMT_TYPE_NORMAL = 0, MGMT_TYPE_AUTO_SCROLL = 1, MGMT_TYPE_AUTO_OWNER = 2, MGMT_TYPE_AUTO_STRICT_OWNER = 3 } |
| enum | QUERY_ATTACK_TYPE { QUERY_ATTACK_TYPE_NOTHING = 0, QUERY_ATTACK_TYPE_FUSE_TO_ATTACKER = 1, QUERY_ATTACK_TYPE_FREEZE_ATTACKED = 2, QUERY_ATTACK_TYPE_ATTACK_FREES_POSITION = 3, QUERY_ATTACK_TYPE_OTHER = 99 } |
Public Member Functions | |
| NPoint | blockPos () const noexcept |
| The origin position of the block in the board. More... | |
| const std::vector< int32_t > & | blockBrickIds () const noexcept |
| The current brick ids of the block. More... | |
| const Tile & | blockBrickTile (int32_t nBrickId) const noexcept |
| The tile of a brick. More... | |
| NPoint | blockBrickPos (int32_t nBrickId) const noexcept |
| The position of the brick relative to the block's origin in the current shape. More... | |
| bool | blockBrickVisible (int32_t nBrickId) const noexcept |
| The visibility of the brick in the current shape. More... | |
| int32_t | blockBricksTot () const noexcept |
| The total number of bricks in the block. More... | |
| int32_t | blockBricksTotVisible () const noexcept |
| The total number of visible bricks in the current shape. More... | |
| const std::vector< Block::Contact > & | blockContacts (Direction::VALUE eDir) noexcept |
| The contact bricks in the current shape in a given direction. More... | |
| NSize | blockSize () const noexcept |
| The size of the current shape. More... | |
| NPoint | blockBricksMinPos () const noexcept |
| The minimum position (relative to blockPos) of the visible bricks of the current shape. More... | |
| NPoint | blockBricksMaxPos () const noexcept |
| The maximum position (relative to blockPos) of the visible bricks of the current shape. More... | |
| virtual int32_t | blockPosZ () const noexcept=0 |
| The z position. More... | |
| virtual const std::vector< int32_t > & | blockVTBrickIds (int32_t nViewTick, int32_t nTotViewTicks) const noexcept |
| The brick ids at a certain view tick. More... | |
| virtual FPoint | blockVTPos (int32_t nViewTick, int32_t nTotViewTicks) const noexcept |
| The origin position of the block in the board at a certain view tick. More... | |
| virtual const Tile & | blockVTBrickTile (int32_t nViewTick, int32_t nTotViewTicks, int32_t nBrickId) const noexcept |
| The tile of a brick at a certain view tick. More... | |
| virtual NPoint | blockVTBrickPos (int32_t nViewTick, int32_t nTotViewTicks, int32_t nBrickId) const noexcept |
| The position of the brick relative to the block's origin in the current shape at a certain view tick. More... | |
| virtual bool | blockVTBrickVisible (int32_t nViewTick, int32_t nTotViewTicks, int32_t nBrickId) const noexcept |
| The visibility of the brick in the current shape at a certain view tick. More... | |
| virtual int32_t | blockVTPosZ (int32_t nViewTick, int32_t nTotViewTicks) const noexcept |
| The z position at a certain view tick. More... | |
| double | blockGetTileAniElapsed (int32_t nBrickId, int32_t nIdxTileAni, int32_t nViewTick, int32_t nTotViewTicks) const noexcept |
| The tile animation unary elapsed time. More... | |
| void | blockSetTileAnimator (int32_t nBrickId, int32_t nIdxTileAni, TileAnimator *p0TileAnimator, int32_t nHash) noexcept |
| Set the tile animator for a certain tile animation and brick. More... | |
| const TileAnimator * | blockGetTileAnimator (int32_t nBrickId, int32_t nIdxTileAni) const noexcept |
| Get the current tile animator for the given tile animation and brick. More... | |
| virtual bool | remove () noexcept |
| Removes this block from the level. More... | |
| virtual bool | destroy () noexcept |
| Destroy this block. More... | |
| virtual bool | freeze () noexcept |
| Freeze this block. More... | |
| virtual bool | fuseTo (LevelBlock &oLevelBlock) noexcept |
| Fuse to another block and get removed. More... | |
| virtual bool | canFuseWith (LevelBlock &oLevelBlock) const noexcept |
| Whether it can fuse with another block. More... | |
| virtual bool | removeBrick (int32_t nBrickId) noexcept |
| Try to remove a brick from the block. More... | |
| virtual bool | destroyBrick (int32_t nBrickId) noexcept |
| Try to destroy a brick from the block. More... | |
| MGMT_TYPE | blockGetMgmtType () noexcept |
| int32_t | blockGetId () const noexcept |
| The LevelBlock unique identifier. More... | |
| bool | isPlayerControllable () const noexcept |
| Whether players can control this level block. More... | |
| int32_t | getControllerTeam () const noexcept |
| Potential team allowed to control this instance. More... | |
| int32_t | getTeam () const noexcept |
| The level team of the player that currently controls this instance. More... | |
| int32_t | getTeammate () const noexcept |
| The teammate of the player that currently controls this instance. More... | |
| int32_t | getPlayer () const noexcept |
| The level player that currently controls this instance. More... | |
| virtual QUERY_ATTACK_TYPE | queryAttack (LevelBlock &oAttacker, int32_t nBoardX, int32_t nBoardY, const Tile &oTile) const noexcept=0 |
| Whether another block can attack this block and the outcome. More... | |
| virtual bool | attack (LevelBlock &oAttacker, int32_t nBoardX, int32_t nBoardY, const Tile &oTile) noexcept=0 |
| Another block attacks this block. More... | |
Static Public Member Functions | |
| static Coords | getCoords (const LevelBlock &oLevelBlock) noexcept |
| Returns coords of visible bricks (of current shape). More... | |
Protected Member Functions | |
| LevelBlock (bool bRemoveEmptyShapes) noexcept | |
| Constructor. More... | |
| void | blockInitialSet (const Block &oBlock, int32_t nShapeId, NPoint oPos, bool bControllable, int32_t nControllerTeam) noexcept |
| Initialization function. More... | |
| bool | blockIsAutoScrolled () noexcept |
| Whether the block is automatically scrolled by the level. More... | |
| bool | blockIsAutoOwner () noexcept |
| Whether the cell owner is automatically set by the level. More... | |
| virtual void | handleInput (const shared_ptr< stmi::Event > &refEvent) noexcept |
| Input event handler. More... | |
| virtual void | handleKeyActionInput (const shared_ptr< KeyActionEvent > &refEvent) noexcept |
| KeyActionevent handler. More... | |
| virtual void | handleTimer () noexcept=0 |
| Function called each game tick. More... | |
| virtual void | fall () noexcept=0 |
| Function called when block supposed to fall. More... | |
| const Block & | blockGet () const noexcept |
| The underlying block. More... | |
| int32_t | blockGetShapeId () const noexcept |
| The current shape of the underlying block. More... | |
| void | blockMove (int32_t nDeltaX, int32_t nDeltaY) noexcept |
| Move the block. More... | |
| void | blockMoveRotate (int32_t nShapeId, int32_t nDeltaX, int32_t nDeltaY) noexcept |
| Set shape and move level block. More... | |
| void | blockModify (int32_t nDeltaX, int32_t nDeltaY, const std::vector< int32_t > &aRemoveBrickId, const std::vector< int32_t > &aDestroyBrickId, const std::vector< std::tuple< int32_t, int32_t, int32_t, bool > > &aModifyPosBrick, const std::vector< std::pair< int32_t, Tile > > &aModifyTileBrick, const std::vector< std::tuple< Tile, int32_t, int32_t, bool > > &aAddBrick) noexcept |
| Modifies the level block. More... | |
| virtual void | onAdded () noexcept |
| Called when block added to level. More... | |
| virtual void | onUnfreezed () noexcept |
| Called when block is added to level by unfreezing. More... | |
| virtual void | onFusedWith (const LevelBlock &oLevelBlock) noexcept |
| Called when block has fused with another (by now removed) block. More... | |
| virtual void | onScrolled (Direction::VALUE eDir) noexcept |
| Called when the block was scrolled. More... | |
| virtual void | onPlayerChanged () noexcept |
| Called when controlling player was changed by level. More... | |
| virtual void | onControllabilityChanged () noexcept |
| Called when controllability has changed. More... | |
Base class for run-time Blocks.
| Enumerator | |
|---|---|
| MGMT_TYPE_INVALID | |
| MGMT_TYPE_NORMAL | LevelBlock is not automatically scrolled. |
| MGMT_TYPE_AUTO_SCROLL | LevelBlock is scrolled automatically (ex. SwapperEvent). |
| MGMT_TYPE_AUTO_OWNER | MGMT_TYPE_AUTO_SCROLL + Board-cell owner is set/reset for each visible brick. |
| MGMT_TYPE_AUTO_STRICT_OWNER | MGMT_TYPE_AUTO_OWNER + owned Board-cell's tile is enforced to be empty (ex. BlockEvent) |
|
explicitprotectednoexcept |
Constructor.
| bRemoveEmptyShapes | Whether empty shapes are automatically removed. |
|
pure virtualnoexcept |
Another block attacks this block.
Returns true if the position was freed by either:
| oAttacker | The attacker block. |
| nBoardX | The board x position where the attack takes place. |
| nBoardY | The board y position where the attack takes place. |
| oTile | The attacker's tile. TODO not sure. |
Implemented in stmg::SquarsorEvent, and stmg::DumbBlockEvent.
|
noexcept |
The current brick ids of the block.
The returned vector might be invalidated by operations such as removeBrick(), fuseTo(), remove(), etc.
|
inlinenoexcept |
The position of the brick relative to the block's origin in the current shape.
blockPos() + blockBrickPos(nBrickId) is the position within the board.
| nBrickId | The brick id. Must be valid. |
|
inlinenoexcept |
The maximum position (relative to blockPos) of the visible bricks of the current shape.
|
inlinenoexcept |
The minimum position (relative to blockPos) of the visible bricks of the current shape.
|
inlinenoexcept |
The total number of bricks in the block.
|
inlinenoexcept |
The total number of visible bricks in the current shape.
|
inlinenoexcept |
The tile of a brick.
The returned tile might be invalidated by operations such as removeBrick(), fuseTo(), remove(), etc.
| nBrickId | The brick id. Must be valid. |
|
inlinenoexcept |
The visibility of the brick in the current shape.
| nBrickId | The brick id. Must be valid. |
|
noexcept |
The contact bricks in the current shape in a given direction.
The position of the contacts is relative to the block's origin.
Example: O is a brick, x is a contact
xx xOO OO
There are only three contacts in the UP direction for the four bricks block shape.
| eDir | The direction. |
|
inlineprotectednoexcept |
The underlying block.
|
inlinenoexcept |
The LevelBlock unique identifier.
|
inlinenoexcept |
|
inlineprotectednoexcept |
The current shape of the underlying block.
|
noexcept |
The tile animation unary elapsed time.
| nBrickId | The brick id. Must be valid. |
| nIdxTileAni | The tile ani index into Named::tileAnis(). |
| nViewTick | The view tick. Must be >= 0 and < nTotViewTicks. |
| nTotViewTicks | The total number of view ticks in the game interval. Must be > 0. |
|
noexcept |
Get the current tile animator for the given tile animation and brick.
| nBrickId | The brick id. Must be valid. |
| nIdxTileAni | The tile ani index into Named::tileAnis(). |
|
protectednoexcept |
Initialization function.
Use this function before LevelBlock instance is added to Level.
| oBlock | The block. |
| nShapeId | The current shape. |
| oPos | The position on the level's board. |
| bControllable | Whether the level block is controllable by players. |
| nControllerTeam | The level team who's players are allowed to control the block or -1 if all teams. |
|
inlineprotectednoexcept |
Whether the cell owner is automatically set by the level.
|
inlineprotectednoexcept |
Whether the block is automatically scrolled by the level.
|
protectednoexcept |
Modifies the level block.
| nDeltaX | The number of cells the block should move in the x direction. |
| nDeltaY | The number of cells the block should move in the y direction. |
| aRemoveBrickId | The bricks that should be removed. Value: nBrickId. |
| aDestroyBrickId | The bricks that should be destroyed. Value: nBrickId. |
| aModifyPosBrick | The position and visibility change of bricks. Value: tuple<nBrickId, nRelX, nRelY, bVisible>. |
| aModifyTileBrick | The brick tiles to be modified. Value: tuple<nBrickId, oTile>. |
| aAddBrick | The bricks to be added. Value: tuple<oTile, nRelX, nRelY, bVisible>. |
|
protectednoexcept |
Move the block.
| nDeltaX | The number of cells the block should move in the x direction. |
| nDeltaY | The number of cells the block should move in the y direction. |
|
protectednoexcept |
Set shape and move level block.
| nShapeId | The (possibly new) current shape id. |
| nDeltaX | The number of cells the block should move in the x direction. |
| nDeltaY | The number of cells the block should move in the y direction. |
|
inlinenoexcept |
The origin position of the block in the board.
|
pure virtualnoexcept |
The z position.
Implemented in stmg::SquarsorEvent, and stmg::DumbBlockEvent.
|
noexcept |
Set the tile animator for a certain tile animation and brick.
The callback function is getElapsed01().
The caller must ensure that the tile animator doesn't get deleted while active.
If a tile animator is already installed it is overwritten.
| nBrickId | The brick id. Must be valid. |
| nIdxTileAni | The tile ani index into Named::tileAnis(). |
| p0TileAnimator | The tile animator. Cannot be null. |
| nHash | A custom value that will be passed to the callback. |
|
inlinenoexcept |
The size of the current shape.
If at least one brick is visible returns {blockBricksMaxX() - blockBricksMinX() + 1, blockBricksMaxY() - blockBricksMinY() + 1}.
|
virtualnoexcept |
The brick ids at a certain view tick.
The default calls blockBrickIds().
| nViewTick | The view tick. Must be >= 0 and < nTotViewTicks. |
| nTotViewTicks | The total number of view ticks in the game interval. Must be > 0. |
|
virtualnoexcept |
The position of the brick relative to the block's origin in the current shape at a certain view tick.
| nViewTick | The view tick. Must be >= 0 and < nTotViewTicks. |
| nTotViewTicks | The total number of view ticks in the game interval. Must be > 0. |
| nBrickId | The brick id. Must be valid. |
|
virtualnoexcept |
The tile of a brick at a certain view tick.
The default calls blockBrickTile().
The returned tile might be invalidated by operations such as removeBrick(), fuseTo(), remove(), etc.
| nViewTick | The view tick. Must be >= 0 and < nTotViewTicks. |
| nTotViewTicks | The total number of view ticks in the game interval. Must be > 0. |
| nBrickId | The brick id. Must be valid. |
|
virtualnoexcept |
The visibility of the brick in the current shape at a certain view tick.
| nViewTick | The view tick. Must be >= 0 and < nTotViewTicks. |
| nTotViewTicks | The total number of view ticks in the game interval. Must be > 0. |
| nBrickId | The brick id. Must be valid. |
|
virtualnoexcept |
The origin position of the block in the board at a certain view tick.
The default calls blockPos().
| nViewTick | The view tick. Must be >= 0 and < nTotViewTicks. |
| nTotViewTicks | The total number of view ticks in the game interval. Must be > 0. |
|
virtualnoexcept |
The z position at a certain view tick.
| nViewTick | The view tick. Must be >= 0 and < nTotViewTicks. |
| nTotViewTicks | The total number of view ticks in the game interval. Must be > 0. |
|
virtualnoexcept |
Whether it can fuse with another block.
| oLevelBlock | The other (slave) block. |
Reimplemented in stmg::SquarsorEvent.
|
virtualnoexcept |
Destroy this block.
Reimplemented in stmg::DumbBlockEvent, and stmg::SquarsorEvent.
|
virtualnoexcept |
Try to destroy a brick from the block.
| nBrickId | The brick id. |
Reimplemented in stmg::SquarsorEvent, and stmg::DumbBlockEvent.
|
protectedpure virtualnoexcept |
Function called when block supposed to fall.
Called each Level::getFallEachTicks() game ticks. It is called after LevelBlock::handleTimer().
Implemented in stmg::SquarsorEvent, and stmg::DumbBlockEvent.
|
virtualnoexcept |
Freeze this block.
Reimplemented in stmg::DumbBlockEvent, and stmg::SquarsorEvent.
|
virtualnoexcept |
Fuse to another block and get removed.
| oLevelBlock | The master block. |
Reimplemented in stmg::DumbBlockEvent, and stmg::SquarsorEvent.
|
inlinenoexcept |
Potential team allowed to control this instance.
Only call this function if isPlayerControllable() returns true.
|
staticnoexcept |
Returns coords of visible bricks (of current shape).
| oLevelBlock | Level block. |
|
inlinenoexcept |
The level player that currently controls this instance.
|
inlinenoexcept |
The level team of the player that currently controls this instance.
|
inlinenoexcept |
The teammate of the player that currently controls this instance.
|
protectedvirtualnoexcept |
Input event handler.
Function handleKeyActionInput for events of type KeyActionEvent. The base implementation does nothing.
| refEvent | The received event. Cannot be null. |
Reimplemented in stmg::DumbBlockEvent, and stmg::SquarsorEvent.
|
protectedvirtualnoexcept |
KeyActionevent handler.
The base implementation does nothing.
| refEvent | The key action event. Cannot be null. |
Reimplemented in stmg::SquarsorEvent.
|
protectedpure virtualnoexcept |
Function called each game tick.
This function is called before LevelBlock::fall() if the block is falling on a specific game tick.
Implemented in stmg::DumbBlockEvent, and stmg::SquarsorEvent.
|
inlinenoexcept |
Whether players can control this level block.
|
protectedvirtualnoexcept |
Called when block added to level.
Reimplemented in stmg::DumbBlockEvent.
|
protectedvirtualnoexcept |
Called when controllability has changed.
|
protectedvirtualnoexcept |
Called when block has fused with another (by now removed) block.
|
protectedvirtualnoexcept |
Called when controlling player was changed by level.
Reimplemented in stmg::SquarsorEvent.
|
protectedvirtualnoexcept |
Called when the block was scrolled.
| eDir | The direction of the scroll. |
Reimplemented in stmg::SquarsorEvent.
|
protectedvirtualnoexcept |
Called when block is added to level by unfreezing.
|
pure virtualnoexcept |
Whether another block can attack this block and the outcome.
| oAttacker | The attacker block. |
| nBoardX | The board x position where the attack takes place. |
| nBoardY | The board y position where the attack takes place. |
| oTile | The attacker's tile. TODO not sure. |
Implemented in stmg::SquarsorEvent, and stmg::DumbBlockEvent.
|
virtualnoexcept |
Removes this block from the level.
Reimplemented in stmg::DumbBlockEvent, and stmg::SquarsorEvent.
|
virtualnoexcept |
Try to remove a brick from the block.
| nBrickId | The brick id. |
Reimplemented in stmg::SquarsorEvent, and stmg::DumbBlockEvent.
1.8.13