stmm-games-doc  0.32.0
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
stmg::DumbBlockEvent Class Reference

Block that does nothing. More...

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

Classes

struct  Init
 
struct  LocalInit
 

Public Types

enum  {
  LISTENER_GROUP_CANNOT_PLACE = 10, LISTENER_GROUP_COULD_PLACE = 11, LISTENER_GROUP_REMOVED = 90, LISTENER_GROUP_DESTROYED = 91,
  LISTENER_GROUP_FREEZED = 92
}
 
- Public Types inherited from stmg::Event
enum  MSG_FILTER_VALUE_OP {
  MSG_FILTER_VALUE_OP_FIRST = 0, MSG_FILTER_VALUE_OP_UNCHANGED = 0, MSG_FILTER_VALUE_OP_SET = 1, MSG_FILTER_VALUE_OP_MULT_ADD = 2,
  MSG_FILTER_VALUE_OP_DIV_ADD = 3, MSG_FILTER_VALUE_OP_PERCENT_ADD = 4, MSG_FILTER_VALUE_OP_PERMILL_ADD = 5, MSG_FILTER_VALUE_OP_MOD_ADD = 6,
  MSG_FILTER_VALUE_OP_MIN_ADD = 7, MSG_FILTER_VALUE_OP_MAX_ADD = 8, MSG_FILTER_VALUE_OP_LAST = 8
}
 Value filter. More...
 
enum  { LISTENER_GROUP_FINISHED = 0 }
 
- Public Types inherited from stmg::LevelBlock
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

 DumbBlockEvent (Init &&oInit) noexcept
 Constructor. More...
 
void trigger (int32_t nMsg, int32_t nValue, Event *p0TriggeringEvent) noexcept override
 The trigger function. More...
 
int32_t blockPosZ () const noexcept override
 The z position. More...
 
void handleInput (const shared_ptr< stmi::Event > &) noexcept override
 Input event handler. More...
 
void handleTimer () noexcept override
 Function called each game tick. More...
 
void fall () noexcept override
 Function called when block supposed to fall. More...
 
bool remove () noexcept override
 Removes this block from the level. More...
 
bool destroy () noexcept override
 Destroy this block. More...
 
bool freeze () noexcept override
 Freeze this block. More...
 
bool fuseTo (LevelBlock &oLevelBlock) noexcept override
 Fuse to another block and get removed. More...
 
bool removeBrick (int32_t nBrickId) noexcept override
 Try to remove a brick from the block. More...
 
bool destroyBrick (int32_t nBrickId) noexcept override
 Try to destroy a brick from the block. More...
 
LevelBlock::QUERY_ATTACK_TYPE queryAttack (LevelBlock &oAttacker, int32_t nBoardX, int32_t nBoardY, const Tile &oTile) const noexcept override
 Whether another block can attack this block and the outcome. More...
 
bool attack (LevelBlock &oAttacker, int32_t nBoardX, int32_t nBoardY, const Tile &oTile) noexcept override
 Another block attacks this block. More...
 
void boabloPreFreeze (LevelBlock &oBlock) noexcept override
 Pre freeze callback. More...
 
void boabloPostFreeze (const Coords &oCoords) noexcept override
 Post freeze callback. More...
 
void boabloPreUnfreeze (const Coords &oCoords) noexcept override
 Pre unfreeze callback. More...
 
void boabloPostUnfreeze (LevelBlock &oBlock) noexcept override
 Post unfreeze callback. More...
 
void boardPreScroll (Direction::VALUE eDir, const shared_ptr< TileRect > &refTiles) noexcept override
 Pre scroll callback. More...
 
void boardPostScroll (Direction::VALUE eDir) noexcept override
 Post scroll callback. More...
 
void boardPreInsert (Direction::VALUE eDir, NRect oRect, const shared_ptr< TileRect > &refTiles) noexcept override
 Pre insert callback. More...
 
void boardPostInsert (Direction::VALUE eDir, NRect oRect) noexcept override
 Post insert callback. More...
 
void boardPreDestroy (const Coords &oCoords) noexcept override
 Pre destroy callback. More...
 
void boardPostDestroy (const Coords &oCoords) noexcept override
 Post destroy callback. More...
 
void boardPreModify (const TileCoords &oTileCoords) noexcept override
 Pre modify callback. More...
 
void boardPostModify (const Coords &oCoords) noexcept override
 Post modify callback. More...
 
- Public Member Functions inherited from stmg::Event
virtual ~Event () noexcept=default
 
virtual void addMsgFilter (int32_t nInFromMsg, int32_t nInToMsg, int32_t nInFromValue, int32_t nInToValue, bool bOutMsgDefined, int32_t nOutMsg, MSG_FILTER_VALUE_OP eOutValueOperator, int32_t nOutValueOperand, int32_t nOutValueAdd) noexcept
 Add a message filter. More...
 
virtual void addListener (int32_t nGroupId, Event *p0ListenerEvent, int32_t nMsg) noexcept
 Adds a listener to the event. More...
 
bool isActive () const noexcept
 Tells whether the event is active. More...
 
int32_t getTriggerTime () const noexcept
 The triggering time. More...
 
int32_t getPriority () const noexcept
 The priority. More...
 
int32_t getDebugTag () const noexcept
 The debug tag. More...
 
- Public Member Functions inherited from stmg::LevelBlock
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 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 canFuseWith (LevelBlock &oLevelBlock) const noexcept
 Whether it can fuse with another 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...
 
- Public Member Functions inherited from stmg::BoardScrollListener
virtual ~BoardScrollListener () noexcept=default
 
- Public Member Functions inherited from stmg::BoaBloListener
virtual ~BoaBloListener () noexcept=default
 

Protected Member Functions

void reInit (Init &&oInit) noexcept
 Reinitialization. More...
 
void onAdded () noexcept override
 Called when block added to level. More...
 
- Protected Member Functions inherited from stmg::Event
 Event (Init &&oInit) noexcept
 Constructor. More...
 
void reInit (Init &&oInit) noexcept
 Reinitialization. More...
 
virtual void informListeners (int32_t nGroupId, int32_t nValue) noexcept
 Calls the trigger function of a group of listeners. More...
 
const Levellevel () const noexcept
 The level this event belongs to. More...
 
Levellevel () noexcept
 The level this event belongs to. More...
 
- Protected Member Functions inherited from stmg::LevelBlock
 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 handleKeyActionInput (const shared_ptr< KeyActionEvent > &refEvent) noexcept
 KeyActionevent handler. 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 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...
 

Additional Inherited Members

- Static Public Member Functions inherited from stmg::LevelBlock
static Coords getCoords (const LevelBlock &oLevelBlock) noexcept
 Returns coords of visible bricks (of current shape). More...
 

Detailed Description

Block that does nothing.

Does not fall. But you can freeze it.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
LISTENER_GROUP_CANNOT_PLACE 
LISTENER_GROUP_COULD_PLACE 
LISTENER_GROUP_REMOVED 
LISTENER_GROUP_DESTROYED 
LISTENER_GROUP_FREEZED 

Constructor & Destructor Documentation

◆ DumbBlockEvent()

stmg::DumbBlockEvent::DumbBlockEvent ( Init &&  oInit)
noexcept

Constructor.

Parameters
oInitThe initialization data.

Member Function Documentation

◆ attack()

bool stmg::DumbBlockEvent::attack ( LevelBlock oAttacker,
int32_t  nBoardX,
int32_t  nBoardY,
const Tile oTile 
)
overridevirtualnoexcept

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.

Implements stmg::LevelBlock.

◆ blockPosZ()

int32_t stmg::DumbBlockEvent::blockPosZ ( ) const
inlineoverridevirtualnoexcept

The z position.

Returns
The z (drawing priority).

Implements stmg::LevelBlock.

◆ boabloPostFreeze()

void stmg::DumbBlockEvent::boabloPostFreeze ( const Coords oCoords)
overridevirtualnoexcept

Post freeze callback.

The block has been removed and the board modified. Called by LevelBlock::freeze().

Parameters
oCoordsThe coords of the modified cells.

Implements stmg::BoaBloListener.

◆ boabloPostUnfreeze()

void stmg::DumbBlockEvent::boabloPostUnfreeze ( LevelBlock oBlock)
overridevirtualnoexcept

Post unfreeze callback.

The block has been created and the board cells emptied. Called by Level::boabloUnfreeze().

Parameters
oBlock

Implements stmg::BoaBloListener.

◆ boabloPreFreeze()

void stmg::DumbBlockEvent::boabloPreFreeze ( LevelBlock oBlock)
overridevirtualnoexcept

Pre freeze callback.

Called by LevelBlock::freeze().

Parameters
oBlockThe block that will freeze on the board.

Implements stmg::BoaBloListener.

◆ boabloPreUnfreeze()

void stmg::DumbBlockEvent::boabloPreUnfreeze ( const Coords oCoords)
overridevirtualnoexcept

Pre unfreeze callback.

Called by Level::boabloUnfreeze().

Parameters
oCoordsThe coords of the cells that will be used for the block. Is not empty.

Implements stmg::BoaBloListener.

◆ boardPostDestroy()

void stmg::DumbBlockEvent::boardPostDestroy ( const Coords oCoords)
overridevirtualnoexcept

Post destroy callback.

Called by Level::boardDestroy().

Parameters
oCoordsThe destroyed tiles (now empty) positions.

Implements stmg::BoardListener.

◆ boardPostInsert()

void stmg::DumbBlockEvent::boardPostInsert ( Direction::VALUE  eDir,
NRect  oArea 
)
overridevirtualnoexcept

Post insert callback.

Called by Level::boardInsert().

Parameters
eDirThe direction.
oAreaThe modified area.

Implements stmg::BoardListener.

◆ boardPostModify()

void stmg::DumbBlockEvent::boardPostModify ( const Coords oCoords)
overridevirtualnoexcept

Post modify callback.

Called by Level::boardModify().

Parameters
oCoordsThe positions of the modified tiles.

Implements stmg::BoardListener.

◆ boardPostScroll()

void stmg::DumbBlockEvent::boardPostScroll ( Direction::VALUE  eDir)
overridevirtualnoexcept

Post scroll callback.

Called by Level::boardScroll().

Parameters
eDirThe direction of the scroll.

Implements stmg::BoardScrollListener.

◆ boardPreDestroy()

void stmg::DumbBlockEvent::boardPreDestroy ( const Coords oCoords)
overridevirtualnoexcept

Pre destroy callback.

Called by Level::boardDestroy().

Parameters
oCoordsThe destroyed tiles' position.

Implements stmg::BoardListener.

◆ boardPreInsert()

void stmg::DumbBlockEvent::boardPreInsert ( Direction::VALUE  eDir,
NRect  oArea,
const shared_ptr< TileRect > &  refTiles 
)
overridevirtualnoexcept

Pre insert callback.

Called by Level::boardInsert().

Parameters
eDirThe direction.
oAreaThe area. Is within board.
refTilesThe tiles to insert.

Implements stmg::BoardListener.

◆ boardPreModify()

void stmg::DumbBlockEvent::boardPreModify ( const TileCoords oTileCoords)
overridevirtualnoexcept

Pre modify callback.

Called by Level::boardModify().

Parameters
oTileCoordsThe new tiles and their position.

Implements stmg::BoardListener.

◆ boardPreScroll()

void stmg::DumbBlockEvent::boardPreScroll ( Direction::VALUE  eDir,
const shared_ptr< TileRect > &  refTiles 
)
overridevirtualnoexcept

Pre scroll callback.

Called by Level::boardScroll().

Parameters
eDirThe direction of the scroll.
refTilesThe tiles that will be placed on the freed cells. If null all empty tiles.

Implements stmg::BoardScrollListener.

◆ destroy()

bool stmg::DumbBlockEvent::destroy ( )
overridevirtualnoexcept

Destroy this block.

Returns
Whether it succeeded.

Reimplemented from stmg::LevelBlock.

◆ destroyBrick()

bool stmg::DumbBlockEvent::destroyBrick ( int32_t  nBrickId)
overridevirtualnoexcept

Try to destroy a brick from the block.

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

Reimplemented from stmg::LevelBlock.

◆ fall()

void stmg::DumbBlockEvent::fall ( )
overridevirtualnoexcept

Function called when block supposed to fall.

Called each Level::getFallEachTicks() game ticks. It is called after LevelBlock::handleTimer().

Implements stmg::LevelBlock.

◆ freeze()

bool stmg::DumbBlockEvent::freeze ( )
overridevirtualnoexcept

Freeze this block.

Returns
Whether it succeeded.

Reimplemented from stmg::LevelBlock.

◆ fuseTo()

bool stmg::DumbBlockEvent::fuseTo ( LevelBlock oLevelBlock)
overridevirtualnoexcept

Fuse to another block and get removed.

Parameters
oLevelBlockThe master block.
Returns
Whether it succeeded.

Reimplemented from stmg::LevelBlock.

◆ handleInput()

void stmg::DumbBlockEvent::handleInput ( const shared_ptr< stmi::Event > &  refEvent)
inlineoverridevirtualnoexcept

Input event handler.

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

Parameters
refEventThe received event. Cannot be null.

Reimplemented from stmg::LevelBlock.

◆ handleTimer()

void stmg::DumbBlockEvent::handleTimer ( )
overridevirtualnoexcept

Function called each game tick.

This function is called before LevelBlock::fall() if the block is falling on a specific game tick.

Implements stmg::LevelBlock.

◆ onAdded()

void stmg::DumbBlockEvent::onAdded ( )
overrideprotectedvirtualnoexcept

Called when block added to level.

Reimplemented from stmg::LevelBlock.

◆ queryAttack()

LevelBlock::QUERY_ATTACK_TYPE stmg::DumbBlockEvent::queryAttack ( LevelBlock oAttacker,
int32_t  nBoardX,
int32_t  nBoardY,
const Tile oTile 
) const
overridevirtualnoexcept

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.

Implements stmg::LevelBlock.

◆ reInit()

void stmg::DumbBlockEvent::reInit ( Init &&  oInit)
protectednoexcept

Reinitialization.

Parameters
oInitThe initialization data.

◆ remove()

bool stmg::DumbBlockEvent::remove ( )
overridevirtualnoexcept

Removes this block from the level.

Returns
Whether it succeeded.

Reimplemented from stmg::LevelBlock.

◆ removeBrick()

bool stmg::DumbBlockEvent::removeBrick ( int32_t  nBrickId)
overridevirtualnoexcept

Try to remove a brick from the block.

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

Reimplemented from stmg::LevelBlock.

◆ trigger()

void stmg::DumbBlockEvent::trigger ( int32_t  nMsg,
int32_t  nValue,
Event p0TriggeringEvent 
)
overridevirtualnoexcept

The trigger function.

This function provides the functionality of the event and can be called in two ways.

It can be called by an event through informListeners() this event was listening to. Note: events can listen to themselves.

It can also be called by the timer if the event was active.

When this function is called the event has already been deactivated by the level (if it was active in the first place).

When this function is called the filters of this event have already been applied.

Parameters
nMsgThe message received.
nValueThe value received.
p0TriggeringEventThe triggering event or null if triggered by timer.

Implements stmg::Event.