case CLOSED:
break;
case OPENING:
+ // if door has finished opening, start timer and keep door open
if(sprite->animation_done()) {
state = OPEN;
sprite->set_action("open");
}
break;
case OPEN:
+ // if door was open long enough, start closing it
if (stay_open_timer.check()) {
state = CLOSING;
sprite->set_action("closing", 1);
}
break;
case CLOSING:
+ // if door has finished closing, keep it shut
if(sprite->animation_done()) {
state = CLOSED;
sprite->set_action("closed");
}
void
-Door::event(Player& who, EventType type)
+Door::event(Player& , EventType type)
{
switch (state) {
case CLOSED:
+ // if door was activated, start opening it
if (type == EVENT_ACTIVATE) {
state = OPENING;
sprite->set_action("opening", 1);
break;
case OPEN:
{
+ // if door is open and was touched by a player, teleport the player
Player* player = dynamic_cast<Player*> (&other);
if (player) {
state = CLOSING;
CLOSING
};
- DoorState state;
- std::string target_sector;
- std::string target_spawnpoint;
- Sprite* sprite;
- Timer stay_open_timer;
+ DoorState state; /**< current state of the door */
+ std::string target_sector; /**< target sector to teleport to */
+ std::string target_spawnpoint; /**< target spawnpoint to teleport to */
+ Sprite* sprite; /**< "door" sprite to render */
+ Timer stay_open_timer; /**< time until door will close again */
};
#endif