Minor fixes/improvements
This commit is contained in:
parent
9d914ce10d
commit
b9589b909d
2 changed files with 11 additions and 11 deletions
|
@ -19,7 +19,8 @@ namespace EC
|
||||||
// Note bitset size is sizes of components and tags + 1
|
// Note bitset size is sizes of components and tags + 1
|
||||||
// This is to use the last extra bit as the result of a query
|
// This is to use the last extra bit as the result of a query
|
||||||
// with a Component or Tag not known to the Bitset.
|
// 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>
|
template <typename ComponentsList, typename TagsList>
|
||||||
struct Bitset :
|
struct Bitset :
|
||||||
public std::bitset<ComponentsList::size + TagsList::size + 1>
|
public std::bitset<ComponentsList::size + TagsList::size + 1>
|
||||||
|
@ -31,7 +32,6 @@ namespace EC
|
||||||
(*this)[Combined::size] = false;
|
(*this)[Combined::size] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO find a better way to handle non-member type in const
|
|
||||||
template <typename Component>
|
template <typename Component>
|
||||||
constexpr auto getComponentBit() const
|
constexpr auto getComponentBit() const
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,6 @@ namespace EC
|
||||||
constexpr auto getComponentBit()
|
constexpr auto getComponentBit()
|
||||||
{
|
{
|
||||||
auto index = EC::Meta::IndexOf<Component, Combined>::value;
|
auto index = EC::Meta::IndexOf<Component, Combined>::value;
|
||||||
(*this)[Combined::size] = false;
|
|
||||||
return (*this)[index];
|
return (*this)[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +57,6 @@ namespace EC
|
||||||
constexpr auto getTagBit()
|
constexpr auto getTagBit()
|
||||||
{
|
{
|
||||||
auto index = EC::Meta::IndexOf<Tag, Combined>::value;
|
auto index = EC::Meta::IndexOf<Tag, Combined>::value;
|
||||||
(*this)[Combined::size] = false;
|
|
||||||
return (*this)[index];
|
return (*this)[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -389,8 +389,8 @@ namespace EC
|
||||||
template <typename Component, typename... Args>
|
template <typename Component, typename... Args>
|
||||||
void addComponent(const std::size_t& entityID, Args&&... args)
|
void addComponent(const std::size_t& entityID, Args&&... args)
|
||||||
{
|
{
|
||||||
if(!isAlive(entityID)
|
if(!EC::Meta::Contains<Component, Components>::value
|
||||||
|| !EC::Meta::Contains<Component, Components>::value)
|
|| !isAlive(entityID))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -426,7 +426,8 @@ namespace EC
|
||||||
template <typename Component>
|
template <typename Component>
|
||||||
void removeComponent(const std::size_t& entityID)
|
void removeComponent(const std::size_t& entityID)
|
||||||
{
|
{
|
||||||
if(!isAlive(entityID))
|
if(!EC::Meta::Contains<Component, Components>::value
|
||||||
|
|| !isAlive(entityID))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -447,8 +448,8 @@ namespace EC
|
||||||
template <typename Tag>
|
template <typename Tag>
|
||||||
void addTag(const std::size_t& entityID)
|
void addTag(const std::size_t& entityID)
|
||||||
{
|
{
|
||||||
if(!isAlive(entityID)
|
if(!EC::Meta::Contains<Tag, Tags>::value
|
||||||
|| !EC::Meta::Contains<Tag, Tags>::value)
|
|| !isAlive(entityID))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -471,7 +472,8 @@ namespace EC
|
||||||
template <typename Tag>
|
template <typename Tag>
|
||||||
void removeTag(const std::size_t& entityID)
|
void removeTag(const std::size_t& entityID)
|
||||||
{
|
{
|
||||||
if(!isAlive(entityID))
|
if(!EC::Meta::Contains<Tag, Tags>::value
|
||||||
|
|| !isAlive(entityID))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1215,7 +1217,7 @@ namespace EC
|
||||||
|
|
||||||
// generate bitsets for each signature
|
// generate bitsets for each signature
|
||||||
EC::Meta::forEachWithIndex<SigList>(
|
EC::Meta::forEachWithIndex<SigList>(
|
||||||
[this, &signatureBitsets] (auto signature, const auto index) {
|
[&signatureBitsets] (auto signature, const auto index) {
|
||||||
signatureBitsets[index] =
|
signatureBitsets[index] =
|
||||||
BitsetType::template generateBitset
|
BitsetType::template generateBitset
|
||||||
<decltype(signature)>();
|
<decltype(signature)>();
|
||||||
|
|
Loading…
Reference in a new issue