Main unit API plugin
This is available events that is called by engine in certain situations
Table of contents
- PLUGIN_setup
- PLUGIN_gameLoaded
- PLUGIN_gameStateChanged
- PLUGIN_receivedCustomData
- PLUGIN_receivedCustomBackupData
- PLUGIN_main
- PLUGIN_newLeader
- PLUGIN_playerGotHit
- PLUGIN_playerGetKilled
- PLUGIN_playerDiBonusdKill
- PLUGIN_playerLifeChanged
- PLUGIN_playerAmmoChanged
- PLUGIN_playerHealthChanged
- PLUGIN_playerFootStepsChanged
- PLUGIN_deviceIsReady
- PLUGIN_lightGotHit
- PLUGIN_destroyed
- PLUGIN_stopped
- PLUGIN_serializeOtherCustomVariables
- PLUGIN_customVariableChanged
- PLUGIN_customMessageFromVisualization
PLUGIN_setup
Function for setup - This is called before game setup is uploaded to devices
void PLUGIN_setup();
PLUGIN_gameLoaded
When game setting is uploaded this function is called
void PLUGIN_gameLoaded();
PLUGIN_gameStateChanged
When game state is changed
void PLUGIN_gameStateChanged(uint8_t aState);
Params
- aState - new state of game
PLUGIN_receivedCustomData
When some of the devices sends custom message
void PLUGIN_receivedCustomData(uint8_t *apData, uint8_t aLen, uint8_t aPlayerIndex);
Params
- apData - Bytes array with data
- aLen - length of data
- aPlayerIndex - Player index who send message
PLUGIN_receivedCustomBackupData
Some custom data added to backup message
void PLUGIN_receivedCustomBackupData(uint8_t *apData, uint8_t aLen, uint8_t aPlayerIndex);
Params
- apData - Bytes array with data
- aLen - length of data
- aPlayerIndex - Player index
PLUGIN_main
Main function besides custom timers this is called every one second - typically for whole game evaluation
void PLUGIN_main();
PLUGIN_newLeader
When system detect new leader based on score
void PLUGIN_newLeader(const Player *apPlayer);
Params
- apPlayer - player object
PLUGIN_playerGotHit
System detected player hit
void PLUGIN_playerGotHit(uint8_t aPlayerIndex, uint8_t aWhoPlayerIndex);
Params
- aPlayerIndex - index of player who received hit
- aWhoPlayerIndex - index of player who did hit
- aFriendlyFire - if hit was friendly
PLUGIN_playerGetKilled
System detected player get killed
void PLUGIN_playerGetKilled(uint8_t aPlayerIndex, uint8_t aWhoPlayerIndex);
Params
- aPlayerIndex - index of player who received kill
- aWhoPlayerIndex - index of player who did kill
PLUGIN_playerDiBonusdKill
System detected player did kill
void PLUGIN_playerDiBonusdKill(uint8_t aPlayerIndex, uint8_t aBonus);
Params
- aPlayerIndex - who did kill
- aBonus - bonus if more players where killed in row
PLUGIN_playerLifeChanged
When player life changed
void PLUGIN_playerLifeChanged(uint8_t aPlayerIndex, uint16_t aOldValue, uint16_t aNewValue);
Params
- aPlayerIndex - index of player
- aOldValue - previous value
- aNewValue - new value
PLUGIN_playerAmmoChanged
When player ammo changed
void PLUGIN_playerAmmoChanged(uint8_t aPlayerIndex,
uint16_t aOldValue,
uint16_t aNewValue,
uint16_t aMissedAmmoInRow);
Params
- aPlayerIndex - index of player
- aOldValue - previous value
- aNewValue - new value
- aMissedAmmoInRow - used ammo from last hit
PLUGIN_playerHealthChanged
When player health changed
void PLUGIN_playerHealthChanged(uint8_t aPlayerIndex, uint16_t aOldValue, uint16_t aNewValue);
Params
- aPlayerIndex - index of player
- aOldValue - previous value
- aNewValue - new value
PLUGIN_playerFootStepsChanged
When footsteps changed
void PLUGIN_playerFootStepsChanged(uint8_t aPlayerIndex, uint16_t aOldValue, uint16_t aNewValue);
Params
- aPlayerIndex - index of player
- aOldValue - previous value
- aNewValue - new value
PLUGIN_deviceIsReady
When device is ready
void PLUGIN_deviceIsReady(uint8_t aPlayerIndex);
Params
- aPlayerIndex - player’s device which is ready
PLUGIN_lightGotHit
When light receive hit on IR sensor
void PLUGIN_lightGotHit(std::string aAddress, uint8_t aCode, uint8_t aInfo);
Params
- aAddress - address of device
- aCode - code of player who did hit
- aInfo - info coded in shot received
PLUGIN_destroyed
game ended and plugin is destroyed - should be used only for cleanup
void PLUGIN_destroyed();
PLUGIN_stopped
game received stop command after this last PLUGIN_main is called use this to finalize data etc.
void PLUGIN_stopped(bool aForce);
Params
- aForce - if game was stop by time or by command from application
PLUGIN_serializeOtherCustomVariables
When engine is going to save or stream data serialize your own custom
void PLUGIN_serializeOtherCustomVariables(rapidjson::Value& aValue, rapidjson::Document::AllocatorType& al, bool aIsFinal);
Params
- aValue - predefined rapid json Value as object
- al - rapid json allocator
- aIsFinal - if the last call before saving results
PLUGIN_customVariableChanged
When custom variable is changed when game is active
void PLUGIN_customVariableChanged(const std::string& aName);
Params
- aName - name of custom variable
PLUGIN_customMessageFromVisualization
When web results sends some data
void PLUGIN_customMessageFromVisualization(const rapidjson::Value& aValue);
Params
- aDocument json value