// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
+#include "trigger/door.hpp"
+
+#include <sstream>
+
#include "audio/sound_manager.hpp"
#include "object/player.hpp"
#include "sprite/sprite_manager.hpp"
#include "supertux/game_session.hpp"
#include "supertux/object_factory.hpp"
-#include "trigger/door.hpp"
+#include "supertux/sector.hpp"
#include "util/reader.hpp"
Door::Door(const Reader& reader) :
state(CLOSED),
target_sector(),
target_spawnpoint(),
+ script(),
sprite(),
stay_open_timer()
{
reader.get("sector", target_sector);
reader.get("spawnpoint", target_spawnpoint);
+ reader.get("script", script);
+
sprite = sprite_manager->create("images/objects/door/door.sprite");
sprite->set_action("closed");
bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
state(CLOSED),
target_sector(),
target_spawnpoint(),
+ script(),
sprite(),
stay_open_timer()
{
}
HitResponse
-Door::collision(GameObject& other, const CollisionHit& hit)
+Door::collision(GameObject& other, const CollisionHit& hit_)
{
switch (state) {
case CLOSED:
if (player) {
state = CLOSING;
sprite->set_action("closing", 1);
- GameSession::current()->respawn(target_sector, target_spawnpoint);
+ if(!script.empty()) {
+ std::istringstream stream(script);
+ Sector::current()->run_script(stream, "Door");
+ }
+
+ if(!target_sector.empty()) {
+ GameSession::current()->respawn(target_sector, target_spawnpoint);
+ }
}
}
break;
break;
}
- return TriggerBase::collision(other, hit);
+ return TriggerBase::collision(other, hit_);
}
/* EOF */