aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/Component.h
blob: ee795f4d77b7418d6a7dd103745d75bb86a8275b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once

#include "types.h"

#include <cstdint>

namespace crepe {

class ComponentManager;

/**
 * \brief Base class for all components
 * 
 * This class is the base class for all components. It provides a common
 * interface for all components.
 */
class Component {
protected:
	//! Only the ComponentManager can create components
	friend class crepe::ComponentManager;
	/**
	 * \param id The id of the GameObject this component belongs to
	 */
	Component(game_object_id_t id);

public:
	virtual ~Component() = default;
	/**
	 * \brief Get the maximum number of instances for this component
	 *
	 * This method returns -1 by default, which means that there is no limit
	 * for the number of instances. Concrete components can override this method
	 * to set a limit.
	 *
	 * \return The maximum number of instances for this component
	 */
	virtual int get_instances_max() const { return -1; }

public:
	//! The id of the GameObject this component belongs to
	const game_object_id_t GAME_OBJECT_ID;
	//! Whether the component is active
	bool active = true;
};

} // namespace crepe