CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
ActionHandler.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 "Action.hpp"
13#include "Entity.hpp"
14
15namespace CeresEngine {
16
18 public:
20 virtual ~AbstractActionHandler() = default;
21 };
22
23 template<typename A> class EntityActionHandler : public AbstractActionHandler {
24 public:
26 using Action = A;
27
29 using ReturnType = typename A::ReturnType;
30
31 public:
35 [[nodiscard]] virtual bool canAct(const Entity& entity, const A& action) noexcept { return true; }
36
40 [[nodiscard]] virtual ReturnType act(Entity& entity, const A& action) = 0;
41 };
42
43} // namespace CeresEngine
Definition ActionHandler.hpp:17
virtual ~AbstractActionHandler()=default
Destroys the AbstractActionHandler.
Definition ActionHandler.hpp:23
virtual bool canAct(const Entity &entity, const A &action) noexcept
Checks if the given handler can act on the given action.
Definition ActionHandler.hpp:35
typename A::ReturnType ReturnType
The return type required by the action type.
Definition ActionHandler.hpp:29
A Action
The action type handled by the handler.
Definition ActionHandler.hpp:26
virtual ReturnType act(Entity &entity, const A &action)=0
Runs an action.
The base entity class.
Definition Entity.hpp:41
Definition Application.hpp:19
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25