stmm-games-doc  0.32.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
stmg::LevelBlock Class Referenceabstract

Base class for run-time Blocks. More...

Inheritance diagram for stmg::LevelBlock:
Inheritance graph
[legend]

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 TileblockBrickTile (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 TileblockVTBrickTile (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 TileAnimatorblockGetTileAnimator (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 BlockblockGet () 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...
 

Detailed Description

Base class for run-time Blocks.

Member Enumeration Documentation

◆ MGMT_TYPE

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)

◆ QUERY_ATTACK_TYPE

Enumerator
QUERY_ATTACK_TYPE_NOTHING 

Nothing happens.

QUERY_ATTACK_TYPE_FUSE_TO_ATTACKER 

The aatacked fuses to the attacker.

QUERY_ATTACK_TYPE_FREEZE_ATTACKED 

The attacked freezes.

QUERY_ATTACK_TYPE_ATTACK_FREES_POSITION 

The attacked frees the attack position on the board.

QUERY_ATTACK_TYPE_OTHER 

Who knows.

Constructor & Destructor Documentation

◆ LevelBlock()

stmg::LevelBlock::LevelBlock ( bool  bRemoveEmptyShapes)
explicitprotectednoexcept

Constructor.

Parameters
bRemoveEmptyShapesWhether empty shapes are automatically removed.

Member Function Documentation

◆ attack()

virtual bool stmg::LevelBlock::attack ( LevelBlock oAttacker,
int32_t  nBoardX,
int32_t  nBoardY,
const Tile oTile 
)
pure virtualnoexcept

Another block attacks this block.

Returns true if the position was freed by either:

  • removing or freezing the attacked LB's brick,
  • removing or freezing the attacker LB's brick,
  • fusing attacked to attacker LBs
    Parameters
    oAttackerThe attacker block.
    nBoardXThe board x position where the attack takes place.
    nBoardYThe board y position where the attack takes place.
    oTileThe attacker's tile. TODO not sure.
    Returns
    Whether it succeeded.

Implemented in stmg::SquarsorEvent, and stmg::DumbBlockEvent.

◆ blockBrickIds()

const std::vector<int32_t>& stmg::LevelBlock::blockBrickIds ( ) const
noexcept

The current brick ids of the block.

The returned vector might be invalidated by operations such as removeBrick(), fuseTo(), remove(), etc.

Returns
The brick ids.

◆ blockBrickPos()

NPoint stmg::LevelBlock::blockBrickPos ( int32_t  nBrickId) const
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.

Parameters
nBrickIdThe brick id. Must be valid.
Returns
The y position.

◆ blockBricksMaxPos()

NPoint stmg::LevelBlock::blockBricksMaxPos ( ) const
inlinenoexcept

The maximum position (relative to blockPos) of the visible bricks of the current shape.

Returns
The max position or undefined if no bricks visible.

◆ blockBricksMinPos()

NPoint stmg::LevelBlock::blockBricksMinPos ( ) const
inlinenoexcept

The minimum position (relative to blockPos) of the visible bricks of the current shape.

Returns
The min position or undefined if no bricks visible.

◆ blockBricksTot()

int32_t stmg::LevelBlock::blockBricksTot ( ) const
inlinenoexcept

The total number of bricks in the block.

Returns
The number of bricks.

◆ blockBricksTotVisible()

int32_t stmg::LevelBlock::blockBricksTotVisible ( ) const
inlinenoexcept

The total number of visible bricks in the current shape.

Returns
Number of visible bricks.

◆ blockBrickTile()

const Tile& stmg::LevelBlock::blockBrickTile ( int32_t  nBrickId) const
inlinenoexcept

The tile of a brick.

The returned tile might be invalidated by operations such as removeBrick(), fuseTo(), remove(), etc.

Parameters
nBrickIdThe brick id. Must be valid.
Returns
The tile.

◆ blockBrickVisible()

bool stmg::LevelBlock::blockBrickVisible ( int32_t  nBrickId) const
inlinenoexcept

The visibility of the brick in the current shape.

Parameters
nBrickIdThe brick id. Must be valid.
Returns
Whether visible.

◆ blockContacts()

const std::vector< Block::Contact >& stmg::LevelBlock::blockContacts ( Direction::VALUE  eDir)
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.

Parameters
eDirThe direction.
Returns
The contacts.

◆ blockGet()

const Block& stmg::LevelBlock::blockGet ( ) const
inlineprotectednoexcept

The underlying block.

Returns
The block.

◆ blockGetId()

int32_t stmg::LevelBlock::blockGetId ( ) const
inlinenoexcept

The LevelBlock unique identifier.

Returns
The id. Is non negative.

◆ blockGetMgmtType()

MGMT_TYPE stmg::LevelBlock::blockGetMgmtType ( )
inlinenoexcept

◆ blockGetShapeId()

int32_t stmg::LevelBlock::blockGetShapeId ( ) const
inlineprotectednoexcept

The current shape of the underlying block.

Returns
The shape.

◆ blockGetTileAniElapsed()

double stmg::LevelBlock::blockGetTileAniElapsed ( int32_t  nBrickId,
int32_t  nIdxTileAni,
int32_t  nViewTick,
int32_t  nTotViewTicks 
) const
noexcept

The tile animation unary elapsed time.

Parameters
nBrickIdThe brick id. Must be valid.
nIdxTileAniThe tile ani index into Named::tileAnis().
nViewTickThe view tick. Must be >= 0 and < nTotViewTicks.
nTotViewTicksThe total number of view ticks in the game interval. Must be > 0.
Returns
The elapsed >= 0.0 and <=1.0 or -1.0 iftile animation not active.

◆ blockGetTileAnimator()

const TileAnimator* stmg::LevelBlock::blockGetTileAnimator ( int32_t  nBrickId,
int32_t  nIdxTileAni 
) const
noexcept

Get the current tile animator for the given tile animation and brick.

Parameters
nBrickIdThe brick id. Must be valid.
nIdxTileAniThe tile ani index into Named::tileAnis().
Returns
The tile animator or null if none is defined.

◆ blockInitialSet()

void stmg::LevelBlock::blockInitialSet ( const Block oBlock,
int32_t  nShapeId,
NPoint  oPos,
bool  bControllable,
int32_t  nControllerTeam 
)
protectednoexcept

Initialization function.

Use this function before LevelBlock instance is added to Level.

Parameters
oBlockThe block.
nShapeIdThe current shape.
oPosThe position on the level's board.
bControllableWhether the level block is controllable by players.
nControllerTeamThe level team who's players are allowed to control the block or -1 if all teams.

◆ blockIsAutoOwner()

bool stmg::LevelBlock::blockIsAutoOwner ( )
inlineprotectednoexcept

Whether the cell owner is automatically set by the level.

Returns
Whether owner automatically set.

◆ blockIsAutoScrolled()

bool stmg::LevelBlock::blockIsAutoScrolled ( )
inlineprotectednoexcept

Whether the block is automatically scrolled by the level.

Returns
Whether automatically scrolled.

◆ blockModify()

void stmg::LevelBlock::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 
)
protectednoexcept

Modifies the level block.

Parameters
nDeltaXThe number of cells the block should move in the x direction.
nDeltaYThe number of cells the block should move in the y direction.
aRemoveBrickIdThe bricks that should be removed. Value: nBrickId.
aDestroyBrickIdThe bricks that should be destroyed. Value: nBrickId.
aModifyPosBrickThe position and visibility change of bricks. Value: tuple<nBrickId, nRelX, nRelY, bVisible>.
aModifyTileBrickThe brick tiles to be modified. Value: tuple<nBrickId, oTile>.
aAddBrickThe bricks to be added. Value: tuple<oTile, nRelX, nRelY, bVisible>.

◆ blockMove()

void stmg::LevelBlock::blockMove ( int32_t  nDeltaX,
int32_t  nDeltaY 
)
protectednoexcept

Move the block.

Parameters
nDeltaXThe number of cells the block should move in the x direction.
nDeltaYThe number of cells the block should move in the y direction.

◆ blockMoveRotate()

void stmg::LevelBlock::blockMoveRotate ( int32_t  nShapeId,
int32_t  nDeltaX,
int32_t  nDeltaY 
)
protectednoexcept

Set shape and move level block.

Parameters
nShapeIdThe (possibly new) current shape id.
nDeltaXThe number of cells the block should move in the x direction.
nDeltaYThe number of cells the block should move in the y direction.

◆ blockPos()

NPoint stmg::LevelBlock::blockPos ( ) const
inlinenoexcept

The origin position of the block in the board.

Returns
The position.

◆ blockPosZ()

virtual int32_t stmg::LevelBlock::blockPosZ ( ) const
pure virtualnoexcept

The z position.

Returns
The z (drawing priority).

Implemented in stmg::SquarsorEvent, and stmg::DumbBlockEvent.

◆ blockSetTileAnimator()

void stmg::LevelBlock::blockSetTileAnimator ( int32_t  nBrickId,
int32_t  nIdxTileAni,
TileAnimator p0TileAnimator,
int32_t  nHash 
)
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.

Parameters
nBrickIdThe brick id. Must be valid.
nIdxTileAniThe tile ani index into Named::tileAnis().
p0TileAnimatorThe tile animator. Cannot be null.
nHashA custom value that will be passed to the callback.

◆ blockSize()

NSize stmg::LevelBlock::blockSize ( ) const
inlinenoexcept

The size of the current shape.

If at least one brick is visible returns {blockBricksMaxX() - blockBricksMinX() + 1, blockBricksMaxY() - blockBricksMinY() + 1}.

Returns
The size or {0,0} if no brick is visible.

◆ blockVTBrickIds()

virtual const std::vector<int32_t>& stmg::LevelBlock::blockVTBrickIds ( int32_t  nViewTick,
int32_t  nTotViewTicks 
) const
virtualnoexcept

The brick ids at a certain view tick.

The default calls blockBrickIds().

Parameters
nViewTickThe view tick. Must be >= 0 and < nTotViewTicks.
nTotViewTicksThe total number of view ticks in the game interval. Must be > 0.
Returns
The brick ids.

◆ blockVTBrickPos()

virtual NPoint stmg::LevelBlock::blockVTBrickPos ( int32_t  nViewTick,
int32_t  nTotViewTicks,
int32_t  nBrickId 
) const
virtualnoexcept

The position of the brick relative to the block's origin in the current shape at a certain view tick.

Parameters
nViewTickThe view tick. Must be >= 0 and < nTotViewTicks.
nTotViewTicksThe total number of view ticks in the game interval. Must be > 0.
nBrickIdThe brick id. Must be valid.
Returns
The position.

◆ blockVTBrickTile()

virtual const Tile& stmg::LevelBlock::blockVTBrickTile ( int32_t  nViewTick,
int32_t  nTotViewTicks,
int32_t  nBrickId 
) const
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.

Parameters
nViewTickThe view tick. Must be >= 0 and < nTotViewTicks.
nTotViewTicksThe total number of view ticks in the game interval. Must be > 0.
nBrickIdThe brick id. Must be valid.
Returns
The tile.

◆ blockVTBrickVisible()

virtual bool stmg::LevelBlock::blockVTBrickVisible ( int32_t  nViewTick,
int32_t  nTotViewTicks,
int32_t  nBrickId 
) const
virtualnoexcept

The visibility of the brick in the current shape at a certain view tick.

Parameters
nViewTickThe view tick. Must be >= 0 and < nTotViewTicks.
nTotViewTicksThe total number of view ticks in the game interval. Must be > 0.
nBrickIdThe brick id. Must be valid.
Returns
Whether visible.

◆ blockVTPos()

virtual FPoint stmg::LevelBlock::blockVTPos ( int32_t  nViewTick,
int32_t  nTotViewTicks 
) const
virtualnoexcept

The origin position of the block in the board at a certain view tick.

The default calls blockPos().

Parameters
nViewTickThe view tick. Must be >= 0 and < nTotViewTicks.
nTotViewTicksThe total number of view ticks in the game interval. Must be > 0.
Returns
The position.

◆ blockVTPosZ()

virtual int32_t stmg::LevelBlock::blockVTPosZ ( int32_t  nViewTick,
int32_t  nTotViewTicks 
) const
virtualnoexcept

The z position at a certain view tick.

Parameters
nViewTickThe view tick. Must be >= 0 and < nTotViewTicks.
nTotViewTicksThe total number of view ticks in the game interval. Must be > 0.
Returns
The z (drawing priority).

◆ canFuseWith()

virtual bool stmg::LevelBlock::canFuseWith ( LevelBlock oLevelBlock) const
virtualnoexcept

Whether it can fuse with another block.

Parameters
oLevelBlockThe other (slave) block.
Returns
Whether it can fuse.

Reimplemented in stmg::SquarsorEvent.

◆ destroy()

virtual bool stmg::LevelBlock::destroy ( )
virtualnoexcept

Destroy this block.

Returns
Whether it succeeded.

Reimplemented in stmg::DumbBlockEvent, and stmg::SquarsorEvent.

◆ destroyBrick()

virtual bool stmg::LevelBlock::destroyBrick ( int32_t  nBrickId)
virtualnoexcept

Try to destroy a brick from the block.

Parameters
nBrickIdThe brick id.
Returns
Whether the brick could be destroyed.

Reimplemented in stmg::SquarsorEvent, and stmg::DumbBlockEvent.

◆ fall()

virtual void stmg::LevelBlock::fall ( )
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.

◆ freeze()

virtual bool stmg::LevelBlock::freeze ( )
virtualnoexcept

Freeze this block.

Returns
Whether it succeeded.

Reimplemented in stmg::DumbBlockEvent, and stmg::SquarsorEvent.

◆ fuseTo()

virtual bool stmg::LevelBlock::fuseTo ( LevelBlock oLevelBlock)
virtualnoexcept

Fuse to another block and get removed.

Parameters
oLevelBlockThe master block.
Returns
Whether it succeeded.

Reimplemented in stmg::DumbBlockEvent, and stmg::SquarsorEvent.

◆ getControllerTeam()

int32_t stmg::LevelBlock::getControllerTeam ( ) const
inlinenoexcept

Potential team allowed to control this instance.

Only call this function if isPlayerControllable() returns true.

Returns
The level team whose players are allowed to control this block or -1 for any.

◆ getCoords()

static Coords stmg::LevelBlock::getCoords ( const LevelBlock oLevelBlock)
staticnoexcept

Returns coords of visible bricks (of current shape).

Parameters
oLevelBlockLevel block.
Returns
The coords of visible bricks.

◆ getPlayer()

int32_t stmg::LevelBlock::getPlayer ( ) const
inlinenoexcept

The level player that currently controls this instance.

Returns
The level player controlling the LevelBlock or -1 if not controlled.

◆ getTeam()

int32_t stmg::LevelBlock::getTeam ( ) const
inlinenoexcept

The level team of the player that currently controls this instance.

Returns
The level team controlling the LevelBlock or -1 if not controlled.

◆ getTeammate()

int32_t stmg::LevelBlock::getTeammate ( ) const
inlinenoexcept

The teammate of the player that currently controls this instance.

Returns
The level team mate controlling the LevelBlock or -1 if not controlled.

◆ handleInput()

virtual void stmg::LevelBlock::handleInput ( const shared_ptr< stmi::Event > &  refEvent)
protectedvirtualnoexcept

Input event handler.

Function handleKeyActionInput for events of type KeyActionEvent. The base implementation does nothing.

Parameters
refEventThe received event. Cannot be null.

Reimplemented in stmg::DumbBlockEvent, and stmg::SquarsorEvent.

◆ handleKeyActionInput()

virtual void stmg::LevelBlock::handleKeyActionInput ( const shared_ptr< KeyActionEvent > &  refEvent)
protectedvirtualnoexcept

KeyActionevent handler.

The base implementation does nothing.

Parameters
refEventThe key action event. Cannot be null.

Reimplemented in stmg::SquarsorEvent.

◆ handleTimer()

virtual void stmg::LevelBlock::handleTimer ( )
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.

◆ isPlayerControllable()

bool stmg::LevelBlock::isPlayerControllable ( ) const
inlinenoexcept

Whether players can control this level block.

Returns
Whether instance controllable.

◆ onAdded()

virtual void stmg::LevelBlock::onAdded ( )
protectedvirtualnoexcept

Called when block added to level.

Reimplemented in stmg::DumbBlockEvent.

◆ onControllabilityChanged()

virtual void stmg::LevelBlock::onControllabilityChanged ( )
protectedvirtualnoexcept

Called when controllability has changed.

◆ onFusedWith()

virtual void stmg::LevelBlock::onFusedWith ( const LevelBlock oLevelBlock)
protectedvirtualnoexcept

Called when block has fused with another (by now removed) block.

◆ onPlayerChanged()

virtual void stmg::LevelBlock::onPlayerChanged ( )
protectedvirtualnoexcept

Called when controlling player was changed by level.

Reimplemented in stmg::SquarsorEvent.

◆ onScrolled()

virtual void stmg::LevelBlock::onScrolled ( Direction::VALUE  eDir)
protectedvirtualnoexcept

Called when the block was scrolled.

Parameters
eDirThe direction of the scroll.

Reimplemented in stmg::SquarsorEvent.

◆ onUnfreezed()

virtual void stmg::LevelBlock::onUnfreezed ( )
protectedvirtualnoexcept

Called when block is added to level by unfreezing.

◆ queryAttack()

virtual QUERY_ATTACK_TYPE stmg::LevelBlock::queryAttack ( LevelBlock oAttacker,
int32_t  nBoardX,
int32_t  nBoardY,
const Tile oTile 
) const
pure virtualnoexcept

Whether another block can attack this block and the outcome.

Parameters
oAttackerThe attacker block.
nBoardXThe board x position where the attack takes place.
nBoardYThe board y position where the attack takes place.
oTileThe attacker's tile. TODO not sure.
Returns
The theoretical outcome of the attack.

Implemented in stmg::SquarsorEvent, and stmg::DumbBlockEvent.

◆ remove()

virtual bool stmg::LevelBlock::remove ( )
virtualnoexcept

Removes this block from the level.

Returns
Whether it succeeded.

Reimplemented in stmg::DumbBlockEvent, and stmg::SquarsorEvent.

◆ removeBrick()

virtual bool stmg::LevelBlock::removeBrick ( int32_t  nBrickId)
virtualnoexcept

Try to remove a brick from the block.

Parameters
nBrickIdThe brick id.
Returns
Whether the brick could be removed.

Reimplemented in stmg::SquarsorEvent, and stmg::DumbBlockEvent.