CORGI
An open source project by FPL.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
entity_common.h
Go to the documentation of this file.
1 // Copyright 2015 Google Inc. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <stddef.h>
16 #include <stdint.h>
17 
18 #ifndef CORGI_ENTITY_COMMON_H_
19 #define CORGI_ENTITY_COMMON_H_
20 
21 namespace corgi {
22 
23 /// @file
24 /// @addtogroup corgi_entity
25 /// @{
26 ///
27 
28 /// @var ComponentId
29 ///
30 /// @brief This represents the ID of a Component.
31 ///
32 /// @note Depending on kMaxComponentCount, this value is either an uint8_t,
33 /// uint16_t, or uint32_t. (However, if you need an uint32_t, you are
34 /// probably doing something odd.)
35 /// @{
36 typedef uint16_t ComponentId;
37 /// @}
38 
39 /// @var kInvalidComponent
40 ///
41 /// @brief A sentinel value to represent an invalid Component.
42 ///
43 /// @note Component IDs start at 1.
44 const ComponentId kInvalidComponent = static_cast<ComponentId>(-1);
45 
46 /// @typedef WorldTime
47 ///
48 /// @brief A typedef that represents time in the game.
49 typedef int WorldTime;
50 
51 /// @cond CORGI_INTERNAL
52 const int kMillisecondsPerSecond = 1000;
53 /// @endcond
54 
55 /// @typedef ComponentIndex
56 ///
57 /// @brief A ComponentIndex is a value used to represent the location of a piece
58 /// of ComponentData, normally inside of a VectorPool.
59 typedef uint16_t ComponentIndex;
60 
61 /// @var kUnusedComponentIndex
62 ///
63 /// @brief A sentinel value to represent an invalid Component.
64 ///
65 /// Since all Entities contain an array corresponding to every
66 /// Component in the system, this value is used as a default value
67 /// to indicate that a specific Component is not registered with
68 /// a given Entity.
69 static const ComponentIndex kInvalidComponentIndex =
70  static_cast<ComponentIndex>(-1);
71 
72 /// @typedef EntityIdType
73 ///
74 /// @brief A EntityIdType is a value used to uniquely represent an entity
75 /// in various internal structures. In general, CORGI users should avoid
76 /// using this directly, and should instead refer to entities via EntityRefs.
77 typedef uint16_t EntityIdType;
78 
79 /// @var kInvalidEntityId
80 ///
81 /// @brief A sentinel value to represent an invalid entity.
82 ///
83 /// Entities have a unique ID that is used reference them internally. This
84 /// value represents an invalid entity. It is usually either used for
85 /// uninitialized values, or to indicate a null return value.
86 static const EntityIdType kInvalidEntityId = static_cast<EntityIdType>(-1);
87 
88 
89 
90 /// @}
91 
92 } // corgi
93 
94 #endif // CORGI_ENTITY_COMMON_H_
uint16_t EntityIdType
A EntityIdType is a value used to uniquely represent an entity in various internal structures...
Definition: entity_common.h:77
int WorldTime
A typedef that represents time in the game.
Definition: entity_common.h:49
const ComponentId kInvalidComponent
A sentinel value to represent an invalid Component.
Definition: entity_common.h:44
static const EntityIdType kInvalidEntityId
A sentinel value to represent an invalid entity.
Definition: entity_common.h:86
uint16_t ComponentIndex
A ComponentIndex is a value used to represent the location of a piece of ComponentData, normally inside of a VectorPool.
Definition: entity_common.h:59
uint16_t ComponentId
This represents the ID of a Component.
Definition: entity_common.h:36