Engine → Scripting → script_component.h
script_store¶
| Type | Class |
| Namespace | conjure::scripting |
| Include File Path | engine/include/conjure/scripting/script_component.h |
| Source File Path | engine/src/scripting/script_component.cpp |
| API ↗ | Scripting, Scripts, components and the runtime |
Syntax¶
Constructors¶
| Access | Signature | Description |
|---|---|---|
| public | script_store(); | |
| public | script_store(
script_store &&) noexcept = default; |
Important
Copy constructor and assignment has been deleted.
Destructors¶
| Access | Signature | Description |
|---|---|---|
| public | ~script_store(); |
Variables¶
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| public | GENERATION_ | static constexpr u32 | 0xFFFu | |
| public | INDEX_BITS | static constexpr u32 | 20 | |
| public | MAX_SETS | static constexpr u32 | 1u << INDEX_BITS | |
| private | mFreeList | std::vector<u32> | {} | |
| private | mLiveCount | usize | 0 | |
| private | mMappedCount | usize | 0 | |
| private | mSlots | std::vector<set_slot> | {} | |
| private | mSlotToEntry | std:: | {} |
Functions¶
Public¶
add_entry¶
add_entry¶[[nodiscard]] script_entry_id add_entry(
u32 handle,
script_entry entry);Appends an entry; an invalid id when the set is unknown or holds MAX_SCRIPTS_PER_ENTITY.
clone_set¶
clone_set¶[[nodiscard]] u32 clone_set(
u32 handle,
ecs::entity owner = {});Deep-copies a set into a new one: same class hashes and JSON, no managed slots, flags reset to CLASS_MISSING where it was set. INVALID_SET_HANDLE for an invalid source.
create_set¶
create_set¶[[nodiscard]] u32 create_set(
ecs::entity owner);Creates an empty set and returns its handle; INVALID_SET_HANDLE (and an assert) when MAX_SETS sets are live.
find¶
find¶[[nodiscard]] script_set *find(
u32 handle) noexcept;[[nodiscard]] const script_set *find(
u32 handle) const noexcept;find_entry¶
find_entry¶[[nodiscard]] script_entry *find_entry(
script_entry_id id) noexcept;[[nodiscard]] const script_entry *find_entry(
script_entry_id id) const noexcept;for_each_set¶
for_each_set¶void for_each_set(
const std::function<void(u32, script_set &)> &callable);Invokes callable(u32 handle, script_set &) for every live set.
free_set¶
free_set¶bool free_set(
u32 handle);Frees a set and unmaps its live slots. False for a null, stale or unknown handle.
make_handle¶
make_handle¶Handle arithmetic.
map_slot¶
map_slot¶void map_slot(
i32 slot,
script_entry_id id);Binds a managed slot to an entry (and writes the entry's managedSlot).
mapped_slot_count¶
mapped_slot_count¶[[nodiscard]] usize mapped_slot_count() const noexcept;Number of mapped slots: a counter the mapping functions keep, so stats() costs nothing.
remove_entry¶
remove_entry¶bool remove_entry(
script_entry_id id);Removes an entry (later entries shift down; the reverse map follows). False when unknown.
resolve_slot¶
resolve_slot¶[[nodiscard]] std::optional<script_entry_id> resolve_slot(
i32 slot) const noexcept;The entry a managed slot belongs to, or nullopt.
unmap_slot¶
unmap_slot¶void unmap_slot(
i32 slot);Clears the mapping of a slot (and the entry's managedSlot when it still points at the slot).
Private¶
live_slot¶
live_slot¶Operator Overloads¶
Public¶
operator=¶
operator=¶script_store &operator=(
script_store &&) noexcept = default;