- writer.start_list("door");
-
- writer.write_float("x", bbox.p1.x);
- writer.write_float("y", bbox.p1.y);
- writer.write_float("width", bbox.get_width());
- writer.write_float("height", bbox.get_height());
-
- writer.write_string("sector", target_sector);
- writer.write_string("spawnpoint", target_spawnpoint);
-
- writer.end_list("door");
+ switch (state) {
+ 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");
+ stay_open_timer.start(1.0);
+ }
+ 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");
+ }
+ break;
+ }