27 #define DBG_AI_ASPECT LOG_STREAM(debug, log_ai_aspect)
28 #define LOG_AI_ASPECT LOG_STREAM(info, log_ai_aspect)
29 #define WRN_AI_ASPECT LOG_STREAM(warn, log_ai_aspect)
30 #define ERR_AI_ASPECT LOG_STREAM(err, log_ai_aspect)
33 time_of_day_(cfg[
"time_of_day"]),turns_(cfg[
"turns"]),
34 valid_(false), valid_variant_(false), valid_lua_(false), cfg_(cfg),
35 invalidate_on_turn_start_(cfg[
"invalidate_on_turn_start"].to_bool(true)),
36 invalidate_on_tod_change_(cfg[
"invalidate_on_tod_change"].to_bool(true)),
37 invalidate_on_gamestate_change_(cfg[
"invalidate_on_gamestate_change"].to_bool()),
38 engine_(cfg[
"engine"]), name_(cfg[
"name"]), id_(
id)
91 name_ = cfg[
"name"].str();
92 id_ = cfg[
"id"].str();
150 if (
s.find_first_of(
'"') == std::string::npos) {
151 return '"' +
s +
'"';
152 }
else if (
s.find_first_of(
"'") == std::string::npos) {
153 return "'" +
s +
"'";
155 return "[=====[" +
s +
"]=====]";
163 ERR_AI_ASPECT <<
"Error: Attempt to double-register aspect " << name;
Managing the AIs lifecycle - headers TODO: Refactor history handling and internal commands.
bool is_duplicate(const std::string &name)
static factory_map & get_list()
bool invalidate_on_gamestate_change_
bool invalidate_on_turn_start_
static lg::log_domain & log()
virtual config to_config() const
virtual bool delete_all_facets()
aspect(readonly_context &context, const config &cfg, const std::string &id)
bool invalidate_on_tod_change_
virtual bool active() const
virtual bool redeploy(const config &cfg, const std::string &id)
const std::string & get_name() const
known_aspect(const std::string &name)
static std::string quote_string(const std::string &s)
Class that manages AIs for all sides and manages AI redeployment.
void remove_gamestate_observer(events::observer *event_observer)
Removes an observer of game events except ai_user_interact event and ai_sync_network event.
void add_gamestate_observer(events::observer *event_observer)
Adds observer of game events except ai_user_interact event and ai_sync_network event.
static manager & get_singleton()
void add_turn_started_observer(events::observer *event_observer)
Adds an observer of 'ai_turn_started' event.
void remove_turn_started_observer(events::observer *event_observer)
Deletes an observer of 'ai_turn_started' event.
void add_tod_changed_observer(events::observer *event_observer)
Adds an observer of 'ai_tod_changed' event.
void remove_tod_changed_observer(events::observer *event_observer)
Deletes an observer of 'ai_tod_changed' event.
virtual bool is_active(const std::string &time_of_day, const std::string &turns) const override
void init_readonly_context_proxy(readonly_context &target)
A config object defines a single node in a WML file, with access to child nodes.
std::string id
Text to match against addon_info.tags()
Standard logging facilities (interface).
A small explanation about what's going on here: Each action has access to two game_info objects First...
static lg::log_domain log_ai_aspect("ai/aspect")
auto * find(Container &container, const Value &value)
Convenience wrapper for using find on a container without needing to comare to end()
static map_location::direction s