stmm-games-doc  0.32.0
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
stmg::SquarsorEvent Class Reference
Inheritance diagram for stmg::SquarsorEvent:
Inheritance graph
[legend]

Classes

struct  Init
 
struct  LocalInit
 

Public Types

enum  { MESSAGE_INVERT_POINTER_AB_ON = 10, MESSAGE_INVERT_POINTER_AB_OFF = 11, MESSAGE_INVERT_POINTER_AB_TOGGLE = 12, MESSAGE_SET_TEAM = 20 }
 
enum  {
  LISTENER_GROUP_BUTTON_A_PRESS = 10, LISTENER_GROUP_BUTTON_A_RELEASE = 11, LISTENER_GROUP_BUTTON_A_RELEASE_CANCEL = 12, LISTENER_GROUP_BUTTON_A_MOVE = 15,
  LISTENER_GROUP_BUTTON_A_OOB_PRESS = 18, LISTENER_GROUP_BUTTON_B_PRESS = 20, LISTENER_GROUP_BUTTON_B_RELEASE = 21, LISTENER_GROUP_BUTTON_B_RELEASE_CANCEL = 22,
  LISTENER_GROUP_BUTTON_B_MOVE = 25, LISTENER_GROUP_BUTTON_B_OOB_PRESS = 28, LISTENER_GROUP_BUTTON_C_PRESS = 30, LISTENER_GROUP_BUTTON_C_RELEASE = 31,
  LISTENER_GROUP_BUTTON_C_RELEASE_CANCEL = 32, LISTENER_GROUP_BUTTON_C_MOVE = 35, LISTENER_GROUP_BUTTON_C_OOB_PRESS = 38, LISTENER_GROUP_POINTER_HOVER = 50
}
 
- 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

 SquarsorEvent (Init &&oInit) noexcept
 Constructor. More...
 
void trigger (int32_t nMsg, int32_t nValue, Event *p0TriggeringEvent) noexcept override
 The trigger function. More...
 
void handleInput (const shared_ptr< stmi::Event > &refEvent) noexcept override
 Input event handler. More...
 
void handleKeyActionInput (const shared_ptr< KeyActionEvent > &refEvent) noexcept override
 KeyActionevent handler. More...
 
void handleTimer () noexcept override
 Function called each game tick. More...
 
int32_t blockPosZ () const noexcept override
 The z position. 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 canFuseWith (LevelBlock &oLevelBlock) const noexcept override
 Whether it can fuse with another block. 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 &, int32_t, int32_t, const Tile &) const noexcept override
 Whether another block can attack this block and the outcome. More...
 
bool attack (LevelBlock &, int32_t, int32_t, const Tile &) noexcept override
 Another block attacks this block. 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...
 
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...
 

Static Public Attributes

static const std::string s_sPlayerOptionMoveOnKeyRelease
 
static const std::string s_sKeyActionLeft
 
static const std::string s_sKeyActionRight
 
static const std::string s_sKeyActionUp
 
static const std::string s_sKeyActionDown
 
static const std::string s_sKeyActionButtonA
 
static const std::string s_sKeyActionButtonB
 
static const std::string s_sKeyActionButtonC
 
static const std::string s_sKeyActionNext
 
static const int32_t s_nAreaMinW
 
static const int32_t s_nAreaMinH
 

Protected Member Functions

void reInit (Init &&oInit) noexcept
 Reinitialization. More...
 
void onScrolled (Direction::VALUE eDir) noexcept override
 Called when the block was scrolled. More...
 
void onPlayerChanged () noexcept override
 Called when controlling player was changed by level. More...
 
void handlePointerInput (stmi::PointerEvent::POINTER_INPUT_TYPE eType, double fNewX, double fNewY, int32_t nButton, bool bInformMove) noexcept
 
void handleTouchInput (stmi::TouchEvent::TOUCH_INPUT_TYPE eType, double fNewX, double fNewY, int64_t nFingerId, bool bInformMove) noexcept
 
- 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...
 
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 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...
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
MESSAGE_INVERT_POINTER_AB_ON 

Inverts A and B pointer buttons.

MESSAGE_INVERT_POINTER_AB_OFF 

Don't invert A and B pointer buttons.

MESSAGE_INVERT_POINTER_AB_TOGGLE 

Toggles A and B pointer buttons inversion.

MESSAGE_SET_TEAM 

Changes to the team in nValue.

If nValue is -1 changes to the next team or team 0 if no player is controlling the squarsor.

◆ anonymous enum

anonymous enum
Enumerator
LISTENER_GROUP_BUTTON_A_PRESS 
LISTENER_GROUP_BUTTON_A_RELEASE 
LISTENER_GROUP_BUTTON_A_RELEASE_CANCEL 
LISTENER_GROUP_BUTTON_A_MOVE 
LISTENER_GROUP_BUTTON_A_OOB_PRESS 
LISTENER_GROUP_BUTTON_B_PRESS 
LISTENER_GROUP_BUTTON_B_RELEASE 
LISTENER_GROUP_BUTTON_B_RELEASE_CANCEL 
LISTENER_GROUP_BUTTON_B_MOVE 
LISTENER_GROUP_BUTTON_B_OOB_PRESS 
LISTENER_GROUP_BUTTON_C_PRESS 
LISTENER_GROUP_BUTTON_C_RELEASE 
LISTENER_GROUP_BUTTON_C_RELEASE_CANCEL 
LISTENER_GROUP_BUTTON_C_MOVE 
LISTENER_GROUP_BUTTON_C_OOB_PRESS 
LISTENER_GROUP_POINTER_HOVER 

Constructor & Destructor Documentation

◆ SquarsorEvent()

stmg::SquarsorEvent::SquarsorEvent ( Init &&  oInit)
explicitnoexcept

Constructor.

Parameters
oInitInitialization data.

Member Function Documentation

◆ attack()

bool stmg::SquarsorEvent::attack ( LevelBlock oAttacker,
int32_t  nBoardX,
int32_t  nBoardY,
const Tile oTile 
)
inlineoverridevirtualnoexcept

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::SquarsorEvent::blockPosZ ( ) const
overridevirtualnoexcept

The z position.

Returns
The z (drawing priority).

Implements stmg::LevelBlock.

◆ canFuseWith()

bool stmg::SquarsorEvent::canFuseWith ( LevelBlock oLevelBlock) const
overridevirtualnoexcept

Whether it can fuse with another block.

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

Reimplemented from stmg::LevelBlock.

◆ destroy()

bool stmg::SquarsorEvent::destroy ( )
overridevirtualnoexcept

Destroy this block.

Returns
Whether it succeeded.

Reimplemented from stmg::LevelBlock.

◆ destroyBrick()

bool stmg::SquarsorEvent::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::SquarsorEvent::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::SquarsorEvent::freeze ( )
overridevirtualnoexcept

Freeze this block.

Returns
Whether it succeeded.

Reimplemented from stmg::LevelBlock.

◆ fuseTo()

bool stmg::SquarsorEvent::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::SquarsorEvent::handleInput ( const shared_ptr< stmi::Event > &  refEvent)
overridevirtualnoexcept

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.

◆ handleKeyActionInput()

void stmg::SquarsorEvent::handleKeyActionInput ( const shared_ptr< KeyActionEvent > &  refEvent)
overridevirtualnoexcept

KeyActionevent handler.

The base implementation does nothing.

Parameters
refEventThe key action event. Cannot be null.

Reimplemented from stmg::LevelBlock.

◆ handlePointerInput()

void stmg::SquarsorEvent::handlePointerInput ( stmi::PointerEvent::POINTER_INPUT_TYPE  eType,
double  fNewX,
double  fNewY,
int32_t  nButton,
bool  bInformMove 
)
protectednoexcept

◆ handleTimer()

void stmg::SquarsorEvent::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.

◆ handleTouchInput()

void stmg::SquarsorEvent::handleTouchInput ( stmi::TouchEvent::TOUCH_INPUT_TYPE  eType,
double  fNewX,
double  fNewY,
int64_t  nFingerId,
bool  bInformMove 
)
protectednoexcept

◆ onPlayerChanged()

void stmg::SquarsorEvent::onPlayerChanged ( )
overrideprotectedvirtualnoexcept

Called when controlling player was changed by level.

Reimplemented from stmg::LevelBlock.

◆ onScrolled()

void stmg::SquarsorEvent::onScrolled ( Direction::VALUE  eDir)
overrideprotectedvirtualnoexcept

Called when the block was scrolled.

Parameters
eDirThe direction of the scroll.

Reimplemented from stmg::LevelBlock.

◆ queryAttack()

LevelBlock::QUERY_ATTACK_TYPE stmg::SquarsorEvent::queryAttack ( LevelBlock oAttacker,
int32_t  nBoardX,
int32_t  nBoardY,
const Tile oTile 
) const
inlineoverridevirtualnoexcept

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::SquarsorEvent::reInit ( Init &&  oInit)
protectednoexcept

Reinitialization.

Parameters
oInitInitialization data.

◆ remove()

bool stmg::SquarsorEvent::remove ( )
overridevirtualnoexcept

Removes this block from the level.

Returns
Whether it succeeded.

Reimplemented from stmg::LevelBlock.

◆ removeBrick()

bool stmg::SquarsorEvent::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::SquarsorEvent::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.

Member Data Documentation

◆ s_nAreaMinH

const int32_t stmg::SquarsorEvent::s_nAreaMinH
static

◆ s_nAreaMinW

const int32_t stmg::SquarsorEvent::s_nAreaMinW
static

◆ s_sKeyActionButtonA

const std::string stmg::SquarsorEvent::s_sKeyActionButtonA
static

◆ s_sKeyActionButtonB

const std::string stmg::SquarsorEvent::s_sKeyActionButtonB
static

◆ s_sKeyActionButtonC

const std::string stmg::SquarsorEvent::s_sKeyActionButtonC
static

◆ s_sKeyActionDown

const std::string stmg::SquarsorEvent::s_sKeyActionDown
static

◆ s_sKeyActionLeft

const std::string stmg::SquarsorEvent::s_sKeyActionLeft
static

◆ s_sKeyActionNext

const std::string stmg::SquarsorEvent::s_sKeyActionNext
static

◆ s_sKeyActionRight

const std::string stmg::SquarsorEvent::s_sKeyActionRight
static

◆ s_sKeyActionUp

const std::string stmg::SquarsorEvent::s_sKeyActionUp
static

◆ s_sPlayerOptionMoveOnKeyRelease

const std::string stmg::SquarsorEvent::s_sPlayerOptionMoveOnKeyRelease
static