-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#26: finished implementing Being respawn
- Loading branch information
1 parent
fe396b9
commit d63b559
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "../../include/event/triggers/respawn.h" | ||
#include "../../include/timer/jobs/respawn.h" | ||
|
||
using namespace std; | ||
|
||
namespace core { namespace event { | ||
|
||
|
||
void RespawnEventTrigger::execute(EventArgumentList args) { | ||
|
||
Game *game = boost::get<Game *>(args[0]); | ||
Being *being = static_cast<Being *>(boost::get<Entity *>(args[1])); | ||
|
||
if (being->getRespawnEnabled()) { | ||
|
||
int in = being->getRespawnInterval(); | ||
|
||
// we have to wait a certain number of clock ticks | ||
if (in > 0) { | ||
RespawnTimerJob *j = new RespawnTimerJob(game, in, 1, in, being); | ||
game->insertTimerJob(j); | ||
} | ||
|
||
// respawn right away | ||
else { | ||
being->doRespawn(); | ||
} | ||
} | ||
|
||
continueExecutionFlag = true; | ||
allowActionFlag = true; | ||
} | ||
}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef RESPAWNEVENTTRIGGER_H | ||
#define RESPAWNEVENTTRIGGER_H | ||
|
||
|
||
#include "../eventtrigger.h" | ||
|
||
|
||
using namespace std; | ||
|
||
namespace core { namespace event { | ||
|
||
|
||
class RespawnEventTrigger: public EventTrigger { | ||
|
||
public: | ||
|
||
/* | ||
Triggers a Being's respawning. | ||
Input: | ||
list of arguments | ||
Output: | ||
(none) | ||
*/ | ||
virtual void execute(EventArgumentList args); | ||
}; | ||
}} | ||
|
||
|
||
#endif | ||
|