33 using ContainsFn = std::function<bool(
const glm::vec3&)>;
43 : m_contains(
std::move(contains))
44 , m_on_enter(
std::move(on_enter))
45 , m_on_exit(
std::move(on_exit))
57 : m_fn_name(
std::move(fn_name))
58 , m_contains(
std::move(contains))
59 , m_on_enter(
std::move(on_enter))
60 , m_on_exit(
std::move(on_exit))
74 std::string on_enter_fn_name,
75 std::string on_exit_fn_name,
79 : m_fn_name(
std::move(fn_name))
80 , m_on_enter_fn_name(
std::move(on_enter_fn_name))
81 , m_on_exit_fn_name(
std::move(on_exit_fn_name))
82 , m_contains(
std::move(contains))
83 , m_on_enter(
std::move(on_enter))
84 , m_on_exit(
std::move(on_exit))
89 [[nodiscard]]
bool contains(
const glm::vec3& p)
const
91 return m_contains && m_contains(p);
95 [[nodiscard]]
const std::string&
fn_name()
const {
return m_fn_name; }
98 void set_fn_name(std::string name) { m_fn_name = std::move(name); }
107 [[nodiscard]]
const std::string&
on_exit_fn_name()
const {
return m_on_exit_fn_name; }
113 [[nodiscard]] uint32_t
id()
const {
return m_id; }
116 [[nodiscard]]
const std::unordered_set<uint32_t>*
occupants(uint32_t fabric_id)
const
118 auto it = m_occupants_by_fabric.find(fabric_id);
119 return it != m_occupants_by_fabric.end() ? &it->second :
nullptr;
125 std::vector<uint32_t> result;
126 result.reserve(m_occupants_by_fabric.size());
127 for (
const auto& [fid, _] : m_occupants_by_fabric)
128 result.push_back(fid);
143 void evaluate(uint32_t fabric_id,
144 std::span<
const std::pair<uint32_t, glm::vec3>> snapshot);
void set_on_exit_fn_name(std::string name)
Set or replace the on_exit callable identifier.
const std::string & on_enter_fn_name() const
Identifier assigned to the on_enter callable, empty if anonymous.
const std::unordered_set< uint32_t > * occupants(uint32_t fabric_id) const
Entity ids inside this Expanse for fabric_id, or nullptr if that fabric has no occupants.
std::string m_on_enter_fn_name
std::unordered_map< uint32_t, std::unordered_set< uint32_t > > m_occupants_by_fabric
std::function< void(uint32_t)> CrossingFn
std::vector< uint32_t > occupied_fabrics() const
All fabric ids that currently have at least one occupant inside this Expanse.
void set_fn_name(std::string name)
Set or replace the predicate identifier.
const std::string & on_exit_fn_name() const
Identifier assigned to the on_exit callable, empty if anonymous.
std::string m_on_exit_fn_name
std::function< bool(const glm::vec3 &)> ContainsFn
uint32_t id() const
Stable id assigned by Fabric on registration.
const std::string & fn_name() const
Identifier assigned to the containment predicate, empty if anonymous.
bool contains(const glm::vec3 &p) const
Test whether a world position lies within the Expanse.
Expanse(std::string fn_name, std::string on_enter_fn_name, std::string on_exit_fn_name, ContainsFn contains, CrossingFn on_enter, CrossingFn on_exit)
Construct with named containment predicate and named crossing actions.
void set_on_enter_fn_name(std::string name)
Set or replace the on_enter callable identifier.
Expanse(ContainsFn contains, CrossingFn on_enter, CrossingFn on_exit)
Construct with a containment predicate and crossing actions.
Expanse(std::string fn_name, ContainsFn contains, CrossingFn on_enter, CrossingFn on_exit)
Construct with a named containment predicate and crossing actions.
A defined region of space with a containment test and crossing actions.
Orchestrates spatial indexing and scheduling for Nexus objects.