mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-22 21:43:35 +00:00
documentation and cleanup
This commit is contained in:
parent
179f0cf32d
commit
eab57e4022
@ -1,7 +1,13 @@
|
||||
set(gcc_like_cxx "$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,Clang,GNU,LCC>")
|
||||
set(msvc_cxx "$<COMPILE_LANG_AND_ID:CXX,MSVC>")
|
||||
|
||||
add_library(dECS STATIC
|
||||
"Core.h"
|
||||
"Core.cpp"
|
||||
"Core.h"
|
||||
"Core.cpp"
|
||||
)
|
||||
target_include_directories(dECS PUBLIC .)
|
||||
target_link_libraries(dECS PRIVATE dCommon magic_enum::magic_enum)
|
||||
target_compile_options(dECS PRIVATE "-Wall")
|
||||
target_compile_options(dECS PRIVATE
|
||||
"$<${gcc_like_cxx}:$<BUILD_INTERFACE:-Wall;-Wextra>>"
|
||||
"$<${msvc_cxx}:$<BUILD_INTERFACE:/W3>>"
|
||||
)
|
||||
|
@ -23,10 +23,10 @@ namespace dECS {
|
||||
|
||||
void* Entity::AddComponent(const eReplicaComponentType kind, const StorageConstructor storageConstructor) {
|
||||
if (auto w = m_World.lock()) {
|
||||
// add to kind signature
|
||||
// Add to kind signature
|
||||
w->map[m_Id].set(kind, true);
|
||||
|
||||
// get or add storage
|
||||
// Get or add storage
|
||||
auto storageIt = w->data.find(kind);
|
||||
if (storageIt == w->data.cend()) {
|
||||
bool inserted = false;
|
||||
@ -35,7 +35,7 @@ namespace dECS {
|
||||
}
|
||||
auto& storage = *storageIt->second;
|
||||
|
||||
// return reference if already mapped, otherwise add component
|
||||
// Return reference if already mapped, otherwise add component
|
||||
auto compIt = storage.rowMap.find(m_Id);
|
||||
if (compIt == storage.rowMap.cend()) {
|
||||
const auto curSize = storage.rowMap.size();
|
||||
@ -50,13 +50,13 @@ namespace dECS {
|
||||
|
||||
const void* Entity::GetComponent(const eReplicaComponentType kind) const {
|
||||
if (auto const w = m_World.lock()) {
|
||||
const auto& compSig = w->map.at(m_Id);
|
||||
if (!compSig.test(kind)) return nullptr;
|
||||
// Check that the entity has this component
|
||||
if (!w->map[m_Id].test(kind)) return nullptr;
|
||||
|
||||
// Get the location where it's stored
|
||||
const auto& storage = *w->data.at(kind);
|
||||
const auto it = storage.rowMap.find(m_Id);
|
||||
if (it == storage.rowMap.cend()) return nullptr;
|
||||
|
||||
const auto row = it->second;
|
||||
return storage.at(row);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ TEST(ECSTest, WorldScope) {
|
||||
ASSERT_NE(cPtr, nullptr);
|
||||
}
|
||||
|
||||
// Attempting to access this component now that the world has gone
|
||||
// out of scope should return nullptr
|
||||
// Attempting to access this component should return nullptr
|
||||
// now that the world has gone out of scope
|
||||
ASSERT_EQ(e->GetComponent<TestComponent>(), nullptr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user