1#ifndef GAME_EDITOR_COMPONENT_H
2#define GAME_EDITOR_COMPONENT_H
3
4#include <engine/input.h>
5
6#include <game/client/ui_rect.h>
7#include <game/editor/editor_object.h>
8
9#include <functional>
10#include <vector>
11
12class CEditorComponent : public CEditorObject
13{
14public:
15 /**
16 * Initialize the component and interface pointers.
17 * Needs to be the first function that is called.
18 * The default implementation also resets the component.
19 */
20 void OnInit(CEditor *pEditor) override;
21
22 virtual void OnReset();
23
24 virtual void OnMapLoad();
25
26 /**
27 * Should return `true` if the event was consumed.
28 */
29 virtual bool OnInput(const IInput::CEvent &Event);
30
31 virtual void OnUpdate();
32
33 /**
34 * Initialize all registered subcomponents.
35 * Needs to be called after the interfaces have been initialized.
36 */
37 void InitSubComponents();
38
39 // Register a new subcomponent.
40 void RegisterSubComponent(CEditorComponent &Component);
41
42private:
43 std::vector<std::reference_wrapper<CEditorComponent>> m_vSubComponents;
44};
45
46#endif
47