X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fbadguy%2Fwillowisp.cpp;h=eafe2874c301aa23db3a9ba19f31508007aa7ba1;hb=8b8e1c3576cedddb1d88eafa5fd4804e8257793c;hp=22ec6171b82cf64175cbd14538a8906445cface7;hpb=bbc091a52439e4942cfa614a6c16b3f530dfab8a;p=supertux.git diff --git a/src/badguy/willowisp.cpp b/src/badguy/willowisp.cpp index 22ec6171b..eafe2874c 100644 --- a/src/badguy/willowisp.cpp +++ b/src/badguy/willowisp.cpp @@ -34,6 +34,7 @@ static const std::string SOUNDFILE = "sounds/willowisp.wav"; WillOWisp::WillOWisp(const lisp::Lisp& reader) : BadGuy(reader, "images/creatures/willowisp/willowisp.sprite", LAYER_FLOATINGOBJECTS), mystate(STATE_IDLE), target_sector("main"), target_spawnpoint("main") { + bool running = false; flyspeed = FLYSPEED; track_range = TRACK_RANGE; vanish_range = VANISH_RANGE; @@ -45,16 +46,22 @@ WillOWisp::WillOWisp(const lisp::Lisp& reader) reader.get("track-range", track_range); reader.get("vanish-range", vanish_range); reader.get("hit-script", hit_script); + reader.get("running", running); const lisp::Lisp* pathLisp = reader.get_lisp("path"); if(pathLisp != NULL) { path.reset(new Path()); - path->read(*pathLisp); - walker.reset(new PathWalker(path.get(), false)); + path->read(*pathLisp); + walker.reset(new PathWalker(path.get(), running)); + if(running) + mystate = STATE_PATHMOVING_TRACK; } countMe = false; sound_manager->preload(SOUNDFILE); + sound_manager->preload("sounds/warp.wav"); + + sprite->set_action("idle"); } void @@ -131,8 +138,6 @@ WillOWisp::active_update(float elapsed_time) void WillOWisp::activate() { - sprite->set_action("idle"); - sound_source.reset(sound_manager->create_sound_source(SOUNDFILE)); sound_source->set_position(get_pos()); sound_source->set_looping(true); @@ -167,7 +172,7 @@ WillOWisp::vanish() { mystate = STATE_VANISHING; sprite->set_action("vanishing", 1); - set_group(COLGROUP_DISABLED); + set_colgroup_active(COLGROUP_DISABLED); } bool @@ -211,11 +216,22 @@ WillOWisp::goto_node(int node_no) walker->goto_node(node_no); if(mystate != STATE_PATHMOVING && mystate != STATE_PATHMOVING_TRACK) { mystate = STATE_PATHMOVING; - walker->start_moving(); } } void +WillOWisp::start_moving() +{ + walker->start_moving(); +} + +void +WillOWisp::stop_moving() +{ + walker->stop_moving(); +} + +void WillOWisp::set_state(const std::string& new_state) { if(new_state == "stopped") { @@ -230,10 +246,12 @@ WillOWisp::set_state(const std::string& new_state) walker->start_moving(); } else if(new_state == "normal") { mystate = STATE_IDLE; + } else if(new_state == "vanish") { + vanish(); } else { std::ostringstream msg; msg << "Can't set unknown willowisp state '" << new_state << "', should " - "be stopped, move_path, move_path_track or normal"; + "be stopped, move_path, move_path_track or normal"; throw new std::runtime_error(msg.str()); } }