The Battle for Wesnoth  1.19.7+dev
gamestate_observer.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2024
3  by Yurii Chernyi <terraninfo@terraninfo.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 /**
17  * Base gamestate observer - useful to see if the gamestate has changed
18  * between two points of time
19  * @file
20  */
21 
22 #include "ai/manager.hpp"
24 
25 namespace ai {
26 // =======================================================================
27 
29  : gamestate_change_counter_(0)
30 {
32 }
33 
34 
36 {
38 }
39 
40 
41 void gamestate_observer::handle_generic_event(const std::string &/*event_name*/)
42 {
44 }
45 
46 
48 {
49  return (gamestate_change_counter_>0);
50 }
51 
52 
54 {
56 }
57 
58 // =======================================================================
59 } //end of namespace ai
Managing the AIs lifecycle - headers TODO: Refactor history handling and internal commands.
void handle_generic_event(const std::string &event_name)
bool is_gamestate_changed()
Check if the gamestate has changed since last reset reset is done once on construction,...
void reset()
Reset the counter of gamestate changes.
void remove_gamestate_observer(events::observer *event_observer)
Removes an observer of game events except ai_user_interact event and ai_sync_network event.
Definition: manager.cpp:380
void add_gamestate_observer(events::observer *event_observer)
Adds observer of game events except ai_user_interact event and ai_sync_network event.
Definition: manager.cpp:374
static manager & get_singleton()
Definition: manager.hpp:140
A helper class to observe the game state.
A small explanation about what's going on here: Each action has access to two game_info objects First...
Definition: actions.cpp:59