whiteboard/suppose_dead.hpp

Go to the documentation of this file.
00001 /* $Id: suppose_dead.hpp 53789 2012-04-05 21:16:56Z ejls $ */
00002 /*
00003  Copyright (C) 2011 - 2012 by Tommy Schmitz
00004  Part of the Battle for Wesnoth Project http://www.wesnoth.org
00005 
00006  This program is free software; you can redistribute it and/or modify
00007  it under the terms of the GNU General Public License as published by
00008  the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010  This program is distributed in the hope that it will be useful,
00011  but WITHOUT ANY WARRANTY.
00012 
00013  See the COPYING file for more details.
00014  */
00015 
00016 /**
00017  * @file
00018  */
00019 
00020 #ifndef WB_SUPPOSE_DEAD_HPP_
00021 #define WB_SUPPOSE_DEAD_HPP_
00022 
00023 #include "action.hpp"
00024 
00025 namespace wb {
00026 
00027     /**
00028      * A planned action that temporarily removes a unit from the map
00029      * for planning purposes
00030      */
00031     class suppose_dead
00032     : public action
00033     {
00034         friend class validate_visitor;
00035         friend class highlight_visitor;
00036 
00037     public:
00038         suppose_dead(size_t team_index, bool hidden, unit& curr_unit, map_location const& loc);
00039         suppose_dead(config const&, bool hidden); // For deserialization
00040         virtual ~suppose_dead();
00041 
00042         /** Return the unit targeted by this action. Null if unit doesn't exist. */
00043         virtual unit* get_unit() const;
00044         /** @return null pointer */
00045         virtual fake_unit_ptr get_fake_unit() { return fake_unit_ptr(); }
00046         /** Return the location at which this action was planned. */
00047         virtual map_location get_source_hex() const { return loc_; }
00048 
00049     //  Inherits from action
00050     //  {
00051             virtual std::ostream& print(std::ostream& s) const;
00052 
00053             virtual void accept(visitor &v);
00054 
00055             virtual void execute(bool& success, bool& complete);
00056 
00057             /** Applies temporarily the result of this action to the specified unit map. */
00058             virtual void apply_temp_modifier(unit_map& unit_map);
00059             /** Removes the result of this action from the specified unit map. */
00060             virtual void remove_temp_modifier(unit_map& unit_map);
00061 
00062             /** Gets called by display when drawing a hex, to allow actions to draw to the screen. */
00063             virtual void draw_hex(const map_location& hex);
00064 
00065             virtual map_location get_numbering_hex() const { return loc_; }
00066 
00067             virtual void set_valid(bool valid);
00068             virtual bool is_valid() const { return valid_; }
00069 
00070             virtual config to_config() const;
00071     //  }   End Inherits from action
00072 
00073     protected:
00074 
00075         boost::shared_ptr<suppose_dead> shared_from_this() {
00076             return boost::static_pointer_cast<suppose_dead>(action::shared_from_this());
00077         }
00078 
00079         size_t unit_underlying_id_;
00080         std::string unit_id_;
00081         map_location loc_;
00082 
00083         bool valid_;
00084 
00085     private:
00086         void init();
00087     };
00088 
00089     /** Dumps a suppose_dead on a stream, for debug purposes. */
00090     std::ostream &operator<<(std::ostream &s, suppose_dead_ptr sup_d);
00091     std::ostream &operator<<(std::ostream &s, suppose_dead_const_ptr sup_d);
00092 } // end namespace wb
00093 
00094 #endif /* WB_SUPPOSE_DEAD_HPP_ */
00095 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:15 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs