4 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "sequence_trigger.hpp"
24 #include "game_session.hpp"
25 #include "lisp/lisp.hpp"
26 #include "lisp/writer.hpp"
27 #include "object_factory.hpp"
29 SequenceTrigger::SequenceTrigger(const lisp::Lisp& reader)
31 reader.get("x", bbox.p1.x);
32 reader.get("y", bbox.p1.y);
34 reader.get("width", w);
35 reader.get("height", h);
37 reader.get("sequence", sequence_name);
38 triggerevent = EVENT_TOUCH;
41 SequenceTrigger::SequenceTrigger(const Vector& pos, const std::string& sequence)
44 bbox.set_size(32, 32);
45 sequence_name = sequence;
46 triggerevent = EVENT_TOUCH;
49 SequenceTrigger::~SequenceTrigger()
54 SequenceTrigger::write(lisp::Writer& writer)
56 writer.start_list("sequencetrigger");
58 writer.write_float("x", bbox.p1.x);
59 writer.write_float("y", bbox.p1.y);
60 writer.write_float("width", bbox.get_width());
61 writer.write_float("height", bbox.get_height());
62 writer.write_string("sequence", sequence_name);
64 writer.end_list("sequencetrigger");
68 SequenceTrigger::event(Player& , EventType type)
70 if(type == triggerevent) {
71 GameSession::current()->start_sequence(sequence_name);
75 IMPLEMENT_FACTORY(SequenceTrigger, "sequencetrigger")