52 virtual void get_lua(lua_State* L)
const = 0;
69 virtual bool active()
const;
115 virtual const T&
get()
const
150 }
else lua_pushnil(L);
193 const std::string&
get_name()
const;
214 assert (
c->get_id()== this->get_name());
218 LOG_STREAM(
debug,
aspect::log()) <<
"typesafe_known_aspect [" << this->
get_name() <<
"] : while setting aspect, got null. this might be caused by invalid [aspect] WML";
224 std::shared_ptr< composite_aspect <T>>
c = std::dynamic_pointer_cast< composite_aspect<T>>(
where_);
226 assert (
c->get_id()==this->get_name());
227 c->add_facet(-1, cfg);
230 LOG_STREAM(
debug,
aspect::log()) <<
"typesafe_known_aspect [" << this->
get_name() <<
"] : while adding facet to aspect, got null. this might be caused by target [aspect] being not composite";
254 cfg_default[
"id"] =
"default_facet";
255 std::vector< aspect_ptr > default_aspects;
257 if (!default_aspects.empty()) {
275 std::vector<aspect_ptr> facets_base;
319 std::vector< aspect_ptr > facets;
363 this->
name_ =
"standard_aspect";
384 #ifdef USING_BOOST_VARIANT
385 :
public boost::static_visitor<std::string>
392 std::string
operator()(
unsigned long long i)
const {
return std::to_string(
i);}
396 std::string
operator()(utils::monostate)
const {
return "nil";}
407 this->
name_ =
"lua_aspect";
410 code_ = cfg[
"code"].str();
457 if (aspect_factories==
nullptr) {
460 return *aspect_factories;
471 get_list().emplace(name,ptr_to_this);
477 template<
class ASPECT>
487 aspect_ptr a = std::make_shared<ASPECT>(context, cfg,
id);
501 if (aspect_factories==
nullptr) {
504 return *aspect_factories;
512 get_list().emplace(name,ptr_to_this);
518 template<
class ASPECT>
528 aspect_ptr a = std::make_shared<ASPECT>(context, cfg,
id, l_ctx);
virtual aspect_ptr get_new_instance(readonly_context &context, const config &cfg, const std::string &id)=0
std::map< std::string, factory_ptr > factory_map
std::shared_ptr< aspect_factory > factory_ptr
bool is_duplicate(const std::string &name)
virtual ~aspect_factory()
static factory_map & get_list()
aspect_factory(const std::string &name)
std::pair< const std::string, factory_ptr > factory_map_pair
bool invalidate_on_gamestate_change_
virtual void get_lua(lua_State *L) const =0
bool invalidate_on_turn_start_
virtual std::string get_engine() const
static lg::log_domain & log()
virtual void recalculate() const =0
virtual config to_config() const
virtual std::shared_ptr< wfl::variant > get_variant_ptr() const =0
virtual bool delete_all_facets()
virtual const wfl::variant & get_variant() const =0
void handle_generic_event(const std::string &)
aspect(readonly_context &context, const config &cfg, const std::string &id)
bool invalidate_on_tod_change_
virtual std::string get_id() const
virtual std::string get_name() const
virtual bool active() const
virtual bool redeploy(const config &cfg, const std::string &id)
property_handler_map & property_handlers()
virtual bool delete_all_facets()
composite_aspect(readonly_context &context, const config &cfg, const std::string &id)
typesafe_aspect_ptr< T > default_
virtual bool add_facet(int pos, const config &cfg)
virtual void recalculate() const
virtual config to_config() const
typesafe_aspect_vector< T > facets_
void create_facet(typesafe_aspect_vector< T > &facets, const config &cfg)
static void value_to_cfg(const T &value, config &cfg)
static void parse_aspect_from_config(readonly_context &context, const config &cfg, const std::string &id, std::back_insert_iterator< std::vector< aspect_ptr >> b)
virtual void add_facet(const config &cfg)=0
const std::string & get_name() const
virtual void set(aspect_ptr a)=0
known_aspect(const std::string &name)
std::shared_ptr< lua_aspect_factory > factory_ptr
lua_aspect_factory(const std::string &name)
std::pair< const std::string, factory_ptr > factory_map_pair
virtual aspect_ptr get_new_instance(readonly_context &context, const config &cfg, const std::string &id, std::shared_ptr< lua_ai_context > &l_ctx)=0
static factory_map & get_list()
virtual ~lua_aspect_factory()
std::map< std::string, factory_ptr > factory_map
static std::string quote_string(const std::string &s)
std::string operator()(double i) const
std::string operator()(bool b) const
std::string operator()(int i) const
std::string operator()(const t_string &s) const
std::string operator()(const std::string &s) const
std::string operator()(utils::monostate) const
std::string operator()(unsigned long long i) const
std::shared_ptr< lua_ai_action_handler > handler_
lua_aspect(readonly_context &context, const config &cfg, const std::string &id, std::shared_ptr< lua_ai_context > &l_ctx)
aspect_ptr get_new_instance(readonly_context &context, const config &cfg, const std::string &id)
register_aspect_factory(const std::string &name)
register_lua_aspect_factory(const std::string &name)
aspect_ptr get_new_instance(readonly_context &context, const config &cfg, const std::string &id, std::shared_ptr< lua_ai_context > &l_ctx)
standard_aspect(readonly_context &context, const config &cfg, const std::string &id)
typesafe_aspect(readonly_context &context, const config &cfg, const std::string &id)
virtual std::shared_ptr< wfl::variant > get_variant_ptr() const
std::shared_ptr< wfl::variant > value_variant_
void get_lua(lua_State *L) const
std::shared_ptr< T > value_
std::shared_ptr< lua_object< T > > value_lua_
virtual std::shared_ptr< T > get_ptr() const
virtual const wfl::variant & get_variant() const
virtual const T & get() const
virtual ~typesafe_aspect()
virtual void recalculate() const =0
typesafe_known_aspect(const std::string &name, typesafe_aspect_ptr< T > &where, aspect_map &aspects)
typesafe_aspect_ptr< T > & where_
virtual void add_facet(const config &cfg)
A config object defines a single node in a WML file, with access to child nodes.
bool has_attribute(config_key_type key) const
child_itors child_range(config_key_type key)
optional_config_impl< config > optional_child(config_key_type key, int n=0)
Equivalent to mandatory_child, but returns an empty optional if the nth child was not found.
config & add_child(config_key_type key)
std::string id
Text to match against addon_info.tags()
Standard logging facilities (interface).
#define LOG_STREAM(level, domain)
Lua object(value) wrapper implementation.
A small explanation about what's going on here: Each action has access to two game_info objects First...
std::shared_ptr< typesafe_aspect< T > > typesafe_aspect_ptr
std::shared_ptr< aspect > aspect_ptr
static void register_facets_property(property_handler_map &property_handlers, const std::string &property, std::vector< std::shared_ptr< X >> &values, std::shared_ptr< X > &def, std::function< void(std::vector< std::shared_ptr< X >> &, const config &)> construction_factory)
std::map< std::string, aspect_ptr > aspect_map
std::vector< typesafe_aspect_ptr< T > > typesafe_aspect_vector
game_lua_kernel * lua_kernel
auto reversed_view(T &container)
std::string bool_string(const bool value)
Converts a bool value to 'true' or 'false'.
static map_location::direction s