Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
AotCommands.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
20#pragma once
21
22#include <cstdint>
23#include <span>
24
28
29namespace esengine::aot {
30
38inline std::uint32_t applyCommands(ecs::Registry& registry, std::span<const EsCmd> cmds) {
39 std::uint32_t unknown = 0;
40 for (const EsCmd& cmd : cmds) {
41 switch (cmd.kind) {
42 case ES_CMD_DESPAWN:
43 // `a` is the raw entity, as every address-free record carries it.
44 registry.destroy(Entity::fromRaw(cmd.a));
45 break;
46 default:
47 ++unknown;
48 break;
49 }
50 }
51 return unknown;
52}
53
54} // namespace esengine::aot
Entity utilities for the ECS system.
Central ECS registry for entity and component management.
Central container for all entities and components.
Definition Registry.hpp:73
void destroy(Entity entity)
Destroys an entity and removes all its components.
Definition Registry.hpp:449
#define ES_CMD_DESPAWN
Definition estella_abi.h:62
std::uint32_t applyCommands(ecs::Registry &registry, std::span< const EsCmd > cmds)
static constexpr Entity fromRaw(u32 v)
Reconstructs an Entity from a raw packed value.
Definition Types.hpp:162