diff --git a/Include/Pipe/Core/Optional.h b/Include/Pipe/Core/Optional.h index 3189d485..6b4b4a01 100644 --- a/Include/Pipe/Core/Optional.h +++ b/Include/Pipe/Core/Optional.h @@ -122,6 +122,15 @@ namespace p "use Get(defaultValue) instead."); return value; } + /** @return The optional value; undefined when IsSet() returns false. */ + const Type* TryGet() const + { + return IsSet() ? &value : nullptr; + } + Type* TryGet() + { + return IsSet() ? &value : nullptr; + } const Type& operator*() const { diff --git a/Src/ECS/BasePool.cpp b/Src/ECS/BasePool.cpp index 81b69d6f..aefdfebd 100644 --- a/Src/ECS/BasePool.cpp +++ b/Src/ECS/BasePool.cpp @@ -17,7 +17,7 @@ namespace p::ecs for (i32 i = 0; i < other.Size(); ++i) { const Id id = other.idList[i]; - if (id != ecs::NoId) + if (ecs::GetVersion(id) != ecs::NoVersion) { EmplaceId(id, true); }