kroys::World
Scene access on a world: the editor document (Host::Document) or a running game (system ticks). Reading needs permission scene.read, editing scene.write.
Declaration
Declared in kroys/plugin.hpp.
plugin.hpp
class World
Members
#World() = default;An invalid world (Valid() is false).
#World(const KroysHost* host, KroysWorld world);Wraps a raw world handle.
#[[nodiscard]] bool Valid() const;True when it refers to a world and the host has the scene API.
#[[nodiscard]] KroysWorld Raw() const;The raw KroysWorld handle.
#[[nodiscard]] ComponentType FindType(const std::string& name) const;Any registered component: engine ("TransformComponent") or plugin ("Plugin.Id.Name").
#[[nodiscard]] uint32_t EntityCount() const;Number of entities in the world.
#[[nodiscard]] Entity EntityAt(uint32_t index) const;The entity at index (0 .. EntityCount - 1); 0 past the end.
#[[nodiscard]] bool Alive(Entity entity) const;Nonzero while the entity exists.
#[[nodiscard]] Entity Find(const std::string& name) const;The first entity with this name; 0 when none.
#Entity Create(const std::string& name, Entity parent = {}) const;Creates an entity (with a transform) under parent (0: a root entity); its id in *outEntity.
#Result Destroy(Entity entity) const;Destroys an entity and its children.
#[[nodiscard]] std::string Name(Entity entity) const;The entity's name (host string).
#Result SetName(Entity entity, const std::string& name) const;Renames an entity.
#[[nodiscard]] Entity Parent(Entity entity) const;The parent; 0 for a root entity.
#[[nodiscard]] std::optional<KroysTransform> Transform(Entity entity) const;The local transform.
#Result SetTransform(Entity entity, const KroysTransform& transform) const;Sets the local transform.
#[[nodiscard]] bool Has(Entity entity, ComponentType type) const;Nonzero when the entity has the component.
#Result Add(Entity entity, ComponentType type) const;Adds a component with its default values.
#Result Remove(Entity entity, ComponentType type) const;Removes a component.
#[[nodiscard]] std::vector<Entity> Query(ComponentType type) const;Entities with the component; writes at most capacity, returns the total count.
#[[nodiscard]] std::optional<KroysValue> Get(Entity entity, ComponentType type, const std::string& path) const;Reflected field by path ("speed", "transform.position"). Strings in outValue are host strings (valid until the next host call on this thread).
#[[nodiscard]] float GetFloat(Entity entity, ComponentType type, const std::string& path, float fallback = 0.0f) const;A FLOAT field (an INT field converts); fallback when missing or of another type.
#[[nodiscard]] std::string GetString(Entity entity, ComponentType type, const std::string& path) const;A STRING field; empty when missing or of another type.
#Result Set(Entity entity, ComponentType type, const std::string& path, const KroysValue& value) const;Sets a reflected field by path; the value's type must match the field (INT for integers, FLOAT for floats, ...).
#Result SetFloat(Entity entity, ComponentType type, const std::string& path, float number) const;Sets a FLOAT field.
#Result SetInt(Entity entity, ComponentType type, const std::string& path, int64_t number) const;Sets an INT field.
#Result SetBool(Entity entity, ComponentType type, const std::string& path, bool flag) const;Sets a BOOL field.
#Result SetString(Entity entity, ComponentType type, const std::string& path, const std::string& text) const;Sets a STRING field.
#Result SetVec3(Entity entity, ComponentType type, const std::string& path, Vec3 vector) const;Sets a VEC3 field.
#explicit operator bool() const;True when the object is valid (open, alive or non-null).
Signatures
World() = default; World(const KroysHost* host, KroysWorld world); [[nodiscard]] bool Valid() const; explicit operator bool() const; [[nodiscard]] KroysWorld Raw() const; [[nodiscard]] ComponentType FindType(const std::string& name) const; [[nodiscard]] uint32_t EntityCount() const; [[nodiscard]] Entity EntityAt(uint32_t index) const; [[nodiscard]] bool Alive(Entity entity) const; [[nodiscard]] Entity Find(const std::string& name) const; Entity Create(const std::string& name, Entity parent = {}) const; Result Destroy(Entity entity) const; [[nodiscard]] std::string Name(Entity entity) const; Result SetName(Entity entity, const std::string& name) const; [[nodiscard]] Entity Parent(Entity entity) const; [[nodiscard]] std::optional<KroysTransform> Transform(Entity entity) const; Result SetTransform(Entity entity, const KroysTransform& transform) const; [[nodiscard]] bool Has(Entity entity, ComponentType type) const; Result Add(Entity entity, ComponentType type) const; Result Remove(Entity entity, ComponentType type) const; [[nodiscard]] std::vector<Entity> Query(ComponentType type) const; [[nodiscard]] std::optional<KroysValue> Get(Entity entity, ComponentType type, const std::string& path) const; [[nodiscard]] float GetFloat(Entity entity, ComponentType type, const std::string& path, float fallback = 0.0f) const; [[nodiscard]] std::string GetString(Entity entity, ComponentType type, const std::string& path) const; Result Set(Entity entity, ComponentType type, const std::string& path, const KroysValue& value) const; Result SetFloat(Entity entity, ComponentType type, const std::string& path, float number) const; Result SetInt(Entity entity, ComponentType type, const std::string& path, int64_t number) const; Result SetBool(Entity entity, ComponentType type, const std::string& path, bool flag) const; Result SetString(Entity entity, ComponentType type, const std::string& path, const std::string& text) const; Result SetVec3(Entity entity, ComponentType type, const std::string& path, Vec3 vector) const;
KroysEngine 0.1.0 documentation, built from the engine repository by Tools/BuildDocsSite.py.