Support creating entities with prescribes values of some components
This commit is contained in:
parent
20401bee45
commit
ca85b7ee18
1 changed files with 5 additions and 2 deletions
|
|
@ -550,7 +550,8 @@ namespace psemek::util
|
||||||
|
|
||||||
static species_handle entity_species(entity_handle entity) { return {ecs_detail::unpack(entity.value).species}; }
|
static species_handle entity_species(entity_handle entity) { return {ecs_detail::unpack(entity.value).species}; }
|
||||||
|
|
||||||
entity_handle add_entity(species_handle species);
|
template <typename ... Components>
|
||||||
|
entity_handle add_entity(species_handle species, typename Components::data ... components);
|
||||||
ecs_detail::entity_id entity_count(species_handle species) const;
|
ecs_detail::entity_id entity_count(species_handle species) const;
|
||||||
void remove_entity(entity_handle entity);
|
void remove_entity(entity_handle entity);
|
||||||
bool entity_active(entity_handle entity);
|
bool entity_active(entity_handle entity);
|
||||||
|
|
@ -635,9 +636,11 @@ namespace psemek::util
|
||||||
return {result};
|
return {result};
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ecs::entity_handle ecs::add_entity(species_handle species)
|
template <typename ... Components>
|
||||||
|
inline ecs::entity_handle ecs::add_entity(species_handle species, typename Components::data ... components)
|
||||||
{
|
{
|
||||||
entity_handle entity{species_[species.value]->add_entity()};
|
entity_handle entity{species_[species.value]->add_entity()};
|
||||||
|
((get<Components>(entity) = std::move(components)), ...);
|
||||||
for (auto const & ctor : constructors_)
|
for (auto const & ctor : constructors_)
|
||||||
ctor(entity);
|
ctor(entity);
|
||||||
for (auto const & ctor : species_constructors_[species.value])
|
for (auto const & ctor : species_constructors_[species.value])
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue