script_component.h¶
| File Path | engine/include/conjure/scripting/script_component.h |
| API ↗ | Scripting, Scripts, components and the runtime |
The script component and its store.
Structs¶
| File | Description |
|---|---|
script_component |
|
script_entry |
|
script_entry_id |
Public handle to one script of one entity: the set handle plus the entry's index in the set. |
script_set |
|
script_store::set_slot |
Classes¶
| File | Description |
|---|---|
script_store |
Generational storage of script sets plus the managed slot -> entry reverse map. Handles pack a 20-bit index and a 12-bit generation (1..4095, 0 never issued) into the component's 32 bits. |
Enumerations¶
script_entry_flags¶
enum class script_entry_flags : u8 {
NONE = 0,
STARTED = 1 << 0, // OnStart was attempted (or the entry was created ALREADY_STARTED)
FAULTED = 1 << 1, // a callback was disabled (three consecutive faults, or OnCreate/OnReload threw)
CLASS_MISSING = 1 << 2, // no class for the hash in the active registry; JSON preserved
CREATED = 1 << 3, // OnCreate returned this session (not threw); a reload then runs OnReload instead
INACTIVE = 1 << 4 // the live instance was told its entity is inactive; runtime only, never saved
};
Forward Declarations¶
script_runtime¶
Constants¶
| Name | Type | Value | Description |
|---|---|---|---|
INVALID_SET_HANDLE |
inline constexpr u32 |
0 |
The null store handle: zero-filled component memory refers to no set. |
INVALID_SLOT |
inline constexpr i32 |
-1 |
Managed slot of an entry without a live instance (edit mode, missing class, disabled runtime). |
MAX_SCRIPTS_PER_ENTITY |
inline constexpr u32 |
8 |
Scripts one entity may carry. |
SCRIPT_COMPONENT_NAME |
inline constexpr std:: |
"conjure.scripting.script_ |
Registered component name. |
Macros¶
CONJURE_COMPONENT¶
CONJURE_ENUM_FLAGS¶
Functions¶
Public¶
register_script_component¶
register_script_component¶[[nodiscard]] CONJURE_API core::result<ecs::component_id> register_script_component(
ecs::component_registry ®istry);Registers script_component (name SCRIPT_COMPONENT_NAME, 4 bytes, custom copy/destruct, memcpy relocate) and returns its id. Re-registration returns the existing id.
script_component_ops¶
script_component_ops¶[[nodiscard]] CONJURE_API ecs::component_ops script_component_ops() noexcept;The lifecycle hooks the component registers: copy deep-copies the set, destruct frees it; both go through script_runtime::active() and do nothing when no runtime is alive.
script_component_serializer¶
script_component_serializer¶[[nodiscard]] CONJURE_API ecs::component_serializer script_component_serializer() noexcept;The serializer hooks of the component: {"scripts":[{"class","hash","fields"}]} through the active runtime; remapEntities rewrites ENTITY fields of every entry with the class schema. Without a live runtime writeJson writes {"scripts":[]} for a component without a set and fails with INVALID_STATE for one with a set (its scripts would be lost), readJson fails with INVALID_STATE, remapEntities does nothing.