23#include "guillaume/systems/selection.hpp"
25#include "guillaume/components/hierarchy.hpp"
26#include "guillaume/ecs/entity.hpp"
48 const auto childIdentifiers =
50 .getChildIdentifiers();
58 const std::vector<ecs::Entity::Identifier> &childIdentifiers)
65 for (
const auto &childIdentifier: childIdentifiers) {
74 if (!selectable.isSelected()) {
79 selected = childIdentifier;
81 selectable.setSelected(
false);
86 group.setSelected(selected);
87 return group.getSelected();
93 const auto previous = group.getSelected();
101 if (!group.isEmptyAllowed()) {
102 for (
const auto &childIdentifier: childIdentifiers) {
108 group.setSelected(childIdentifier);
109 return childIdentifier;
114 group.clearSelection();
121 const std::vector<ecs::Entity::Identifier> &childIdentifiers,
124 for (
const auto &childIdentifier: childIdentifiers) {
131 .setSelected(childIdentifier == selectedIdentifier);
134 return reconcile(registry, groupIdentifier, childIdentifiers);
Selected/unselected flag of an entity, with a callback run when it changes.
Marks an entity whose Selectable children are mutually exclusive, and remembers which one is selected...
Stores every component of a scene, per component type and per entity identifier, and knows which ones...
ComponentType & getComponent(const Entity::Identifier &entityIdentifier)
Get a component of an entity, to read or modify it.
bool hasComponent(const Entity::Identifier &entityIdentifier) const
Tell whether an entity has a component of a given type.
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
static constexpr Identifier InvalidIdentifier
"No entity": never the identifier of a real entity
SystemFiller(Phase phase)
ecs::ComponentRegistry & getComponentRegistry(void)
Get the component registry of the scene being processed.
bool hasComponent(const ecs::Entity::Identifier &entityIdentifier) const
Tell whether an entity has a component, in the bound registry.
ComponentType & getComponent(const ecs::Entity::Identifier &entityIdentifier)
Get a component of an entity from the bound registry, to read or modify it.
bool requireComponent(const ecs::Entity::Identifier &entityIdentifier)
Tell whether an entity has a component, and log a warning naming the entity and the component when it...
Selection(void)
Create the system, in the Event phase.
static ecs::Entity::Identifier select(ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &groupIdentifier, const std::vector< ecs::Entity::Identifier > &childIdentifiers, ecs::Entity::Identifier selectedIdentifier)
Select one child of a group, at once.
static ecs::Entity::Identifier reconcile(ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &groupIdentifier, const std::vector< ecs::Entity::Identifier > &childIdentifiers)
Make a group and its children agree on which child is selected.
void update(const ecs::Entity::Identifier &entityIdentifier) override
Reconcile one group with the children listed in its components::Hierarchy.
State. Every class here is plain data attached to an entity.
The entity-component-system core, independent of any widget.
Rules. Every class here runs each frame on the entities that have the components it declares.