CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
NetworkSystem.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 "NetworkAction.hpp"
11#include "NetworkEntity.hpp"
12
14
18
21
22namespace CeresEngine {
23
25 : public System<NetworkSystem, EntityObjectSet<>, ComponentSet<NetworkEntityComponent>, EntityActionSet<TransferAuthority, HasAuthorityQuery>> {
26 template<typename A> friend class NetworkActionHandler;
27
28 private:
31
32 public:
36
37 NetworkSystem(const NetworkSystem&) = delete;
38 NetworkSystem& operator=(const NetworkSystem&) = delete;
39
41 ~NetworkSystem() override;
42
43 public:
45 void update(double time) final;
46
47 public: // Network Actions
57 template<typename A> void addNetworkAction();
58
64 template<typename A> void removeNetworkAction();
65
66 template<typename A, typename... Args> [[nodiscard]] typename NetworkAction<A>::ReturnType remoteAct(Entity& entity, Args&&... args);
67
72 Async<Any> remoteAct(const Entity& entity, const AbstractNetworkAction& action);
73
74 protected: // Action handler
76 void act(Entity& entity, const TransferAuthority& action) final;
77
79 bool act(Entity& entity, const HasAuthorityQuery& action) final;
80 };
81
82 template<typename A> class NetworkActionHandler : public EntityActionHandler<NetworkAction<A>> {
85
89 typename NetworkAction<A>::ReturnType act(Entity& entity, const NetworkAction<A>& action) final;
90
91 public:
92 explicit NetworkActionHandler(NetworkSystem* system) : system(system) {}
93 };
94
95} // namespace CeresEngine
96
97#include "NetworkSystem.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
Definition Any.hpp:13
Definition ActionHandler.hpp:23
The base entity class.
Definition Entity.hpp:41
Definition NetworkSystem.hpp:82
NetworkActionHandler(NetworkSystem *system)
Definition NetworkSystem.hpp:92
NetworkAction< A >::ReturnType act(Entity &entity, const NetworkAction< A > &action) final
Runs an action.
NetworkSystem * system
The attached network system.
Definition NetworkSystem.hpp:84
Definition NetworkSystem.hpp:25
Vector< UPtr< CeresEngine::AbstractActionHandler > > networkActionHandlers
A vector of the attached network action handlers.
Definition NetworkSystem.hpp:30
A system is a special kind of service that is managed internally by the SystemManager.
Definition System.hpp:168
Definition Application.hpp:19
cti::continuable< Args... > Async
Defines a non-copyable continuation type which uses the function2 backend for type erasure.
Definition Async.hpp:22
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
Definition NetworkAction.hpp:20
std::conditional_t< std::is_same_v< A::ReturnType, void >, Async<>, Async< A::ReturnType > > ReturnType
Definition Action.hpp:36
Definition NetworkEntity.hpp:141
The NetworkAction is a special type of action that can be performed remotely on the server.
Definition NetworkAction.hpp:35
Definition NetworkEntity.hpp:140