mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-17 22:03:56 -07:00
eslint --no-config-lookup --fix --rule '"prefer-const": 1' \
binaries/data/mods/public/maps/scripts
Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
25 lines
859 B
JavaScript
25 lines
859 B
JavaScript
/**
|
|
* This will print the statistics at the end of a game.
|
|
* In order for this to work, the player's state has to be changed before the event.
|
|
*/
|
|
Trigger.prototype.EndGameAction = function()
|
|
{
|
|
if (!this.once || Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetActivePlayers().length)
|
|
return;
|
|
|
|
this.once = false;
|
|
|
|
for (const player of Engine.GetEntitiesWithInterface(IID_StatisticsTracker))
|
|
{
|
|
const cmpStatisticsTracker = Engine.QueryInterface(player, IID_StatisticsTracker);
|
|
if (cmpStatisticsTracker)
|
|
print(cmpStatisticsTracker.GetStatisticsJSON() + "\n");
|
|
}
|
|
};
|
|
|
|
{
|
|
const cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
|
|
cmpTrigger.RegisterTrigger("OnPlayerWon", "EndGameAction", { "enabled": true });
|
|
cmpTrigger.RegisterTrigger("OnPlayerDefeated", "EndGameAction", { "enabled": true });
|
|
cmpTrigger.once = true;
|
|
}
|