KisaragiLibrary
 
読み取り中…
検索中…
一致する文字列を見つけられません
EntityContainer.hpp
[詳解]
1#pragma once
2
3#include "vector"
4#include "Entity.hpp"
5
6
7namespace ECS
8{
9 /*
10 Entityはuno_mapで
11 */
12
13
14 /// <summary>
15 /// ワールドが所有するEntityのコンテナ
16 /// </summary>
18 {
20
21 ////activeなentity
22 std::vector<Entity> active;
23
24 ////次に割り当てられるエンティティ
26
27 //解放されたエンティティ
28 std::vector<Entity> free;
29
30 //TODO EntityToActiveIndex
31
32 public:
33
34 /// <summary>
35 /// Entityを生成する
36 /// </summary>
37 /// <returns></returns>
38 const Entity& Create()
39 {
40 if (!free.empty())
41 {
42 free.back()++; //バージョン更新
43 active.push_back(free.back()); //追加
44 free.pop_back(); //freeから除外
45 }
46 else
47 {
48 active.push_back(Entity{ next });
49 next++;
50 }
51
52 return active.back();
53 }
54
55 void Remove(const Entity& _entity)
56 {
57 free.push_back(_entity);
58 //TODO
59 }
60
61
62 };
63}
EntityID next
Definition EntityContainer.hpp:25
EntityContainer()
Definition EntityContainer.hpp:19
const Entity & Create()
Entityを生成する
Definition EntityContainer.hpp:38
void Remove(const Entity &_entity)
Definition EntityContainer.hpp:55
std::vector< Entity > free
Definition EntityContainer.hpp:28
std::vector< Entity > active
Definition EntityContainer.hpp:22
Objectの識別子となるクラス
Definition Entity.hpp:17
Definition Entity.hpp:7
unsigned int EntityID
Definition Entity.hpp:9