CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
EventManager.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "Forward.hpp"
11
12#include "EntityID.hpp"
13#include "Event.hpp"
14
16
21
22namespace CeresEngine {
23
25 private:
28
29 public:
32
34 EntityEventManager& operator=(const EntityEventManager&) = delete;
36 EntityEventManager& operator=(EntityEventManager&&) = delete;
37
39
40 public:
47 template<CEntityEvent E, typename... Args> inline void emit(Entity entity, Args&&... args) const;
48
49 public:
50 template<CEntityEvent E, typename Subscriber> inline WeakEventConnection subscribe(Subscriber&& subscriber);
51
52 template<CEntityEvent E, typename Subscriber> inline WeakEventConnection subscribe(EntityID entityID, Subscriber&& subscriber);
53
54 private:
55 friend class EntityManager;
56 void remove(EntityID entityID);
57
58 private:
59 template<CEntityEvent E> [[nodiscard]] inline EntityEventDispatcher<E>& eventDispatcher();
60
61 template<CEntityEvent E> [[nodiscard]] inline const EntityEventDispatcher<E>* eventDispatcher() const;
62
63 template<CEntityEvent E> [[nodiscard]] inline EntityEventDispatcher<E>& eventDispatcher(EntityID entityID);
64
65 template<CEntityEvent E> [[nodiscard]] inline const EntityEventDispatcher<E>* eventDispatcher(EntityID entityID) const;
66 };
67
68} // namespace CeresEngine
69
70#include "EventManager.inl"
#define CE_SCRIPT_EXPORT(...)
The CE_SCRIPT_EXPORT macro marks a class or method as exportable and available in scripting environme...
Definition Macros.hpp:247
A type-safe event dispatcher implementation for events of type E.
Definition EventDispatcher.hpp:28
Definition EventManager.hpp:24
Vector< UPtr< AbstractEntityEventDispatcher > > mEventDispatchers
Definition EventManager.hpp:26
Map< EntityIndex, Vector< UPtr< AbstractEntityEventDispatcher > > > mEntityEventDispatchers
Definition EventManager.hpp:27
The base entity class.
Definition Entity.hpp:41
Definition EntityManager.hpp:49
Connection class.
Definition Event.hpp:44
Definition Event.hpp:73
Definition Application.hpp:19
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
std::map< Key, T, Compare, ScopedAllocatorAdaptor< StdAllocator< Pair< const Key, T >, RawAllocator > > > Map
Map is a sorted associative container that contains key-value pairs with unique keys.
Definition Map.hpp:24
Definition EntityID.hpp:25