-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
132 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#pragma once | ||
|
||
#include "CmptPtr.h" | ||
#include "CmptType.h" | ||
#include "CmptTag.h" | ||
|
||
#include <set> | ||
|
||
namespace Ubpa::UECS { | ||
class EntityLocator; | ||
|
||
// use CmptsView::Iterator to read CmptPtr | ||
class CmptsView { | ||
public: | ||
CmptsView(EntityLocator* locator, void** cmpts) | ||
: locator{ locator }, cmpts{ cmpts }{} | ||
|
||
// check AccessMode | ||
CmptPtr GetCmpt(CmptType) const; | ||
|
||
template<typename Cmpt> | ||
LastFrame<Cmpt> GetCmptAsLastFrame() const { | ||
return GetCmpt(CmptType::Of<LastFrame<Cmpt>>).AsLastFrame<Cmpt>(); | ||
} | ||
|
||
template<typename Cmpt> | ||
Write<Cmpt> GetCmptAsWrite() const { | ||
return GetCmpt(CmptType::Of<Write<Cmpt>>).AsWrite<Cmpt>(); | ||
} | ||
|
||
template<typename Cmpt> | ||
Latest<Cmpt> GetCmptAsLatest() const { | ||
return GetCmpt(CmptType::Of<Latest<Cmpt>>).AsLatest<Cmpt>(); | ||
} | ||
|
||
void* const* Components() const noexcept { return cmpts; } | ||
private: | ||
EntityLocator* locator; | ||
void* const* cmpts; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <UECS/CmptsView.h> | ||
|
||
#include <UECS/EntityLocator.h> | ||
|
||
using namespace Ubpa::UECS; | ||
using namespace std; | ||
|
||
CmptPtr CmptsView::GetCmpt(CmptType t) const { | ||
size_t i = 0; | ||
for (auto iter = locator->CmptTypes().begin(); iter != locator->CmptTypes().end(); ++iter, ++i) { | ||
if (*iter == t) { | ||
assert(iter->GetAccessMode() == t.GetAccessMode()); | ||
return CmptPtr(*iter, *(cmpts + i)); | ||
} | ||
} | ||
assert(false); | ||
return CmptPtr(t, nullptr); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.