aboutsummaryrefslogtreecommitdiffstats
path: root/yage/entity/space.h
blob: ed867534d69ab0eccc74081d433f98ba5063a640 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/** ---------------------------------------------------------------------------
 * @file: space.h
 *
 * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
 * MIT License, see LICENSE file for more details.
 * ----------------------------------------------------------------------------
 */

#pragma once

#include <vector>
#include <memory>

#include "entity.h"
#include "system.h"

struct Movement {
    
};

namespace yage
{

class System;

/**
 * Space that keeps track of all the entities, componenets and runs
 * the systems on the data to update them. There can be multiple
 * instances of a space, which can be used, for example, for different
 * levels in the game that can be loaded separately, or a game menu
 * that can be loaded above the other spaces when the user presses on
 * pause.
 */
class Space
{
public:
    /**
     * Default instance for a space.
     */
    Space();

    /**
     * Create an entity that will belong to this space, and return the
     * handle to the user. The Entity class itself should not be
     * visible to the user, as the user only needs to worry about the
     * handle when referring to the Entity and changing it.
     */
    Entity createEntity();

    /**
     * Update all the systems.
     */
    void update();

private:
    /**
     * The systems of the Space that act on the data and on their
     * respective component. These are specific to the Space, as other
     * spaces might have different Systems and not act on the same
     * entities.
     */
    std::vector<std::unique_ptr<System>> systems_;

    /**
     * Manages all the entities in the system, can create them for the
     * current space.
     */
    EntityManager em_;

    /**
     * Manages all the components
     */
    // ComponentManager cm_;
};

} // namespace yage