Minor fixes/improvements

This commit is contained in:
Stephen Seo 2018-05-19 16:09:31 +09:00
parent 9d914ce10d
commit b9589b909d
2 changed files with 11 additions and 11 deletions

View file

@ -19,7 +19,8 @@ namespace EC
// Note bitset size is sizes of components and tags + 1
// This is to use the last extra bit as the result of a query
// with a Component or Tag not known to the Bitset.
// Those queries will return a false bit every time.
// Those queries should return a false bit every time as long as EC::Manager
// does not change that last bit.
template <typename ComponentsList, typename TagsList>
struct Bitset :
public std::bitset<ComponentsList::size + TagsList::size + 1>
@ -31,7 +32,6 @@ namespace EC
(*this)[Combined::size] = false;
}
// TODO find a better way to handle non-member type in const
template <typename Component>
constexpr auto getComponentBit() const
{
@ -43,7 +43,6 @@ namespace EC
constexpr auto getComponentBit()
{
auto index = EC::Meta::IndexOf<Component, Combined>::value;
(*this)[Combined::size] = false;
return (*this)[index];
}
@ -58,7 +57,6 @@ namespace EC
constexpr auto getTagBit()
{
auto index = EC::Meta::IndexOf<Tag, Combined>::value;
(*this)[Combined::size] = false;
return (*this)[index];
}

View file

@ -389,8 +389,8 @@ namespace EC
template <typename Component, typename... Args>
void addComponent(const std::size_t& entityID, Args&&... args)
{
if(!isAlive(entityID)
|| !EC::Meta::Contains<Component, Components>::value)
if(!EC::Meta::Contains<Component, Components>::value
|| !isAlive(entityID))
{
return;
}
@ -426,7 +426,8 @@ namespace EC
template <typename Component>
void removeComponent(const std::size_t& entityID)
{
if(!isAlive(entityID))
if(!EC::Meta::Contains<Component, Components>::value
|| !isAlive(entityID))
{
return;
}
@ -447,8 +448,8 @@ namespace EC
template <typename Tag>
void addTag(const std::size_t& entityID)
{
if(!isAlive(entityID)
|| !EC::Meta::Contains<Tag, Tags>::value)
if(!EC::Meta::Contains<Tag, Tags>::value
|| !isAlive(entityID))
{
return;
}
@ -471,7 +472,8 @@ namespace EC
template <typename Tag>
void removeTag(const std::size_t& entityID)
{
if(!isAlive(entityID))
if(!EC::Meta::Contains<Tag, Tags>::value
|| !isAlive(entityID))
{
return;
}
@ -1215,7 +1217,7 @@ namespace EC
// generate bitsets for each signature
EC::Meta::forEachWithIndex<SigList>(
[this, &signatureBitsets] (auto signature, const auto index) {
[&signatureBitsets] (auto signature, const auto index) {
signatureBitsets[index] =
BitsetType::template generateBitset
<decltype(signature)>();