Function mut

Summary

#include <include/flecs/addons/cpp/entity_view.hpp>

(1) flecs::entity mut(const flecs::world &stage) const

(2) flecs::entity mut(const flecs::iter &it) const

(3) flecs::entity mut(const flecs::entity_view &e) const

Function overload

Synopsis

#include <include/flecs/addons/cpp/entity_view.hpp>

flecs::entity mut(const flecs::world &stage) const

Description

Return mutable entity handle for current stage When an entity handle created from the world is used while the world is in staged mode, it will only allow for readonly operations since structural changes are not allowed on the world while in staged mode.

To do mutations on the entity, this operation provides a handle to the entity that uses the stage instead of the actual world.

Note that staged entity handles should never be stored persistently, in components or elsewhere. An entity handle should always point to the main world.

Also note that this operation is not necessary when doing mutations on an entity outside of a system. It is allowed to do entity operations directly on the world, as long as the world is not in staged mode.

Parameters

stage - The current stage.

Returns
An entity handle that allows for mutations in the current stage.

Source

Lines 68-72 in include/flecs/addons/cpp/mixins/entity/impl.hpp. Line 623 in include/flecs/addons/cpp/entity_view.hpp.

inline flecs::entity entity_view::mut(const flecs::world& stage) const {
    ecs_assert(!stage.is_readonly(), ECS_INVALID_PARAMETER, 
        "cannot use readonly world/stage to create mutable handle");
    return flecs::entity(m_id).set_stage(stage.c_ptr());
}

Synopsis

#include <include/flecs/addons/cpp/entity_view.hpp>

flecs::entity mut(const flecs::iter &it) const

Description

Same as mut(world), but for iterator. This operation allows for the construction of a mutable entity handle from an iterator.

Parameters

it - An iterator that contains a reference to the world or stage.

Returns
An entity handle that allows for mutations in the current stage.

Source

Lines 74-78 in include/flecs/addons/cpp/mixins/entity/impl.hpp. Line 632 in include/flecs/addons/cpp/entity_view.hpp.

inline flecs::entity entity_view::mut(const flecs::iter& it) const {
    ecs_assert(!it.world().is_readonly(), ECS_INVALID_PARAMETER, 
        "cannot use iterator created for readonly world/stage to create mutable handle");
    return flecs::entity(m_id).set_stage(it.world().c_ptr());
}

Synopsis

#include <include/flecs/addons/cpp/entity_view.hpp>

flecs::entity mut(const flecs::entity_view &e) const

Description

Same as mut(world), but for entity. This operation allows for the construction of a mutable entity handle from another entity. This is useful in each() functions, which only provide a handle to the entity being iterated over.

Parameters

e - Another mutable entity.

Returns
An entity handle that allows for mutations in the current stage.

Source

Lines 80-84 in include/flecs/addons/cpp/mixins/entity/impl.hpp. Line 642 in include/flecs/addons/cpp/entity_view.hpp.

inline flecs::entity entity_view::mut(const flecs::entity_view& e) const {
    ecs_assert(!e.world().is_readonly(), ECS_INVALID_PARAMETER, 
        "cannot use entity created for readonly world/stage to create mutable handle");
    return flecs::entity(m_id).set_stage(e.m_world);
}