ImagoEngine
A C++ 2D game engine built on a sparse-set ECS, with scenes, scheduled systems, events, and action-based input
Loading...
Searching...
No Matches
SparseSetBase.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <vector> // for the dense, sparse, and entity arrays
9
10#include "Imago/ECS/Entity.hpp"
11
12namespace Imago::ECS
13{
14
22 public:
23
24 // virtual destructor
25 virtual ~SparseSetBase() = default;
26
31 virtual void remove(Entity e) = 0;
32
39 virtual bool has(Entity e) const = 0;
40
45 virtual size_t get_size() const = 0;
46
51 virtual const std::vector<Entity>& get_entities() const = 0;
52
57 virtual size_t get_index(Entity e) const = 0;
58
64 virtual void swap_entities(Entity e1, Entity e2) = 0;
65 };
66}
Defines the Entity alias and the free functions used to pack and unpack it.
uint32_t Entity
A packed identifier: 20 bits of index, 12 bits of generation.
Definition Entity.hpp:20
Type-erased interface for SparseSet<T>.
Definition SparseSetBase.hpp:21
virtual void swap_entities(Entity e1, Entity e2)=0
Swaps e1 with e2 in _dense, _entities, and _sparse.
virtual size_t get_size() const =0
return the number of Entities currently stored in this pool
virtual const std::vector< Entity > & get_entities() const =0
returns the dense array of entities currently stored in this pool
virtual size_t get_index(Entity e) const =0
Returns the index of the specified Entity.
virtual bool has(Entity e) const =0
checks whether an Entity currently has a component stored in this pool
virtual void remove(Entity e)=0
removes an Entity's component from this pool, if it is currently present