Skip to content

Commit

Permalink
Make all default components always have id "default_facet".
Browse files Browse the repository at this point in the history
This is mainly so that they are easily identified in the AI components overview in the gamestate inspector,
but it can also be used with [modify_ai]. (It replaces the previous use of * for this.)
  • Loading branch information
CelticMinstrel authored and mattsc committed Mar 22, 2016
1 parent ef880c8 commit cde7041
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/ai/composite/aspect.hpp
Expand Up @@ -269,8 +269,9 @@ class composite_aspect : public typesafe_aspect<T> {
add_facet(-1,cfg_element);
}

const config &_default = this->cfg_.child("default");
config _default = this->cfg_.child("default");
if (_default) {
_default["id"] = "default_facet";
std::vector< aspect_ptr > default_aspects;
engine::parse_aspect_from_config(*this,_default,parent_id_,std::back_inserter(default_aspects));
if (!default_aspects.empty()) {
Expand Down
8 changes: 4 additions & 4 deletions src/ai/composite/property_handler.hpp
Expand Up @@ -185,17 +185,17 @@ class facets_property_handler : public vector_property_handler<T> {

component* handle_get(const path_element &child)
{
//* is a special case - 'get the default facet'
if (child.id == "*") {
// special case - 'get the default facet'
if (child.id == "default_facet") {
return default_.get();
}
return vector_property_handler<T>::handle_get(child);
}

bool handle_change(const path_element &child, config cfg)
{
//* is a special case - 'replace the default facet'
if (child.id == "*") {
// special case - 'replace the default facet'
if (child.id == "default_facet") {
t_ptr_vector values;
this->call_factory(values,cfg);
default_ = values.back();
Expand Down

0 comments on commit cde7041

Please sign in to comment.