MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / EntityPool

Method EntityPool

Source/Entity/Entity.cpp:24–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22class EntityPool : public NonCopyable {
23public:
24 EntityPool() {
25 SharedDirector.getPostScheduler()->schedule([this](double deltaTime) {
26 DORA_UNUSED_PARAM(deltaTime);
27 for (auto& nextValue : nextValues) {
28 NextId nid;
29 nid.value = nextValue.first;
30 NextEvent event = s_cast<NextEvent>(nid.id.event);
31 Entity* entity = entities[nid.id.entity];
32 if (entity) {
33 switch (event) {
34 case NextEvent::Add:
35 entity->registerAddEvent(nid.id.component);
36 break;
37 case NextEvent::Update:
38 entity->registerUpdateEvent(nid.id.component, std::move(nextValue.second));
39 break;
40 case NextEvent::Remove:
41 entity->registerRemoveEvent(nid.id.component, std::move(nextValue.second));
42 break;
43 }
44 }
45 }
46 nextValues.clear();
47 triggers.erase(std::remove_if(triggers.begin(), triggers.end(), [](const auto& trigger) {
48 return trigger();
49 }),
50 triggers.end());
51 for (auto& it : observers) {
52 it.second->clear();
53 }
54 for (Entity* entity : updatedEntities) {
55 if (entity) {
56 entity->clearOldComs();
57 }
58 }
59 updatedEntities.clear();
60 return false;
61 });
62 SharedApplication.quitHandler += [this]() {
63 clear();
64 };
65 }
66 virtual ~EntityPool() { }
67 int tryGetIndex(String name) const {
68 auto it = comIndices.find(name);

Callers

nothing calls this directly

Calls 12

moveFunction · 0.85
registerAddEventMethod · 0.80
registerUpdateEventMethod · 0.80
registerRemoveEventMethod · 0.80
clearOldComsMethod · 0.80
clearMethod · 0.65
clearFunction · 0.50
scheduleMethod · 0.45
getPostSchedulerMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected