KisaragiLibrary
 
読み取り中…
検索中…
一致する文字列を見つけられません
Entity.hpp
[詳解]
1#pragma once
2
3#include "vector"
4
5
6namespace ECS
7{
8 //型宣言
9 using EntityID = unsigned int;
10 using Version = unsigned int;
11
12
13 /// <summary>
14 /// Objectの識別子となるクラス
15 /// </summary>
16 class Entity
17 {
18 //変数宣言
21
22 public:
23 Entity() :id{ 0 }, ver{ 0 }
24 {
25 }
26
27 Entity(EntityID _id) :id{ _id }, ver{ 0 }
28 {
29 }
30
31 Entity(EntityID _id, Version _ver) :id{ _id }, ver{ _ver }
32 {
33 }
34
35#pragma region オペレーター
36 //indexで使うよう
37 operator const EntityID& ()
38 {
39 return id;
40 }
41
42 //非同期処理でver違いのエラーが起きないように
43 bool operator ==(const Entity& _entity)
44 {
45 return (id == _entity.id && ver == _entity.ver);
46 }
47
48 bool operator !=(const Entity& _entity)
49 {
50 return !(*this == _entity);
51 }
52
53#pragma region バージョン更新
55 {
56 return ver++;
57 }
58
59 const Version& operator ++(int)
60 {
61 return ++ver;
62 }
63
64#pragma endregion
65
66#pragma endregion
67
68 };
69}
bool operator==(const Entity &_entity)
Definition Entity.hpp:43
Entity(EntityID _id)
Definition Entity.hpp:27
Entity()
Definition Entity.hpp:23
Entity(EntityID _id, Version _ver)
Definition Entity.hpp:31
Version ver
Definition Entity.hpp:20
EntityID id
Definition Entity.hpp:19
bool operator!=(const Entity &_entity)
Definition Entity.hpp:48
const Version & operator++()
Definition Entity.hpp:54
Definition Entity.hpp:7
unsigned int Version
Definition Entity.hpp:10
unsigned int EntityID
Definition Entity.hpp:9