00001 /* $Id: gamestate_observer.cpp 52533 2012-01-07 02:35:17Z shadowmaster $ */ 00002 /* 00003 Copyright (C) 2010 - 2012 by Yurii Chernyi <terraninfo@terraninfo.net> 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 * Base gamestate observer - useful to see if the gamestate has changed 00018 * between two points of time 00019 * @file 00020 */ 00021 00022 #include "manager.hpp" 00023 #include "gamestate_observer.hpp" 00024 00025 namespace ai { 00026 // ======================================================================= 00027 00028 gamestate_observer::gamestate_observer() 00029 : gamestate_change_counter_(0) 00030 { 00031 ai::manager::add_gamestate_observer(this); 00032 } 00033 00034 00035 gamestate_observer::~gamestate_observer() 00036 { 00037 ai::manager::remove_gamestate_observer(this); 00038 } 00039 00040 00041 void gamestate_observer::handle_generic_event(const std::string &/*event_name*/) 00042 { 00043 ++gamestate_change_counter_; 00044 } 00045 00046 00047 bool gamestate_observer::is_gamestate_changed() 00048 { 00049 return (gamestate_change_counter_>0); 00050 } 00051 00052 00053 void gamestate_observer::reset() 00054 { 00055 gamestate_change_counter_=0; 00056 } 00057 00058 // ======================================================================= 00059 } //end of namespace ai
| Generated by doxygen 1.7.1 on Fri May 25 2012 01:02:44 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |