Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Pixeye committed Mar 10, 2020
1 parent ca46ca2 commit a4b556b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
10 changes: 10 additions & 0 deletions Runtime/LibEcs/CacheEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ public void Add(int type)

componentsIds[componentsAmount++] = (ushort) type;
}

public void CleanMask(int id)
{
for (int i = componentsAmount - 1; i >= 0; i--)
{
var generation = Storage.Generations[componentsIds[i]];
var mask = Storage.Masks[componentsIds[i]];
Entity.GenerationsInstant[id, generation] &= ~mask;
}
}

// public void Remove(int type)
// {
Expand Down
33 changes: 18 additions & 15 deletions Runtime/LibEcs/ent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public void Release()
}
#endif



Entity.entities[id].CleanMask(id);
EntityOperations.Set(this, 0, EntityOperations.Action.Kill);
Entity.entities[id].isAlive = false;
//id = 0; todo: think how to set id to zero from release.
Expand Down Expand Up @@ -114,7 +117,7 @@ static public implicit operator ent(int value)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Has<T>()
{
return (Entity.Generations[id, Storage<T>.Generation] & Storage<T>.ComponentMask) == Storage<T>.ComponentMask;
return (Entity.GenerationsInstant[id, Storage<T>.Generation] & Storage<T>.ComponentMask) == Storage<T>.ComponentMask;
}

[Il2CppSetOption(Option.NullChecks | Option.ArrayBoundsChecks, false)]
Expand All @@ -124,8 +127,8 @@ public bool Has<T, Y>()
var mask = Storage<T>.ComponentMask;
var mask2 = Storage<Y>.ComponentMask;

return (Entity.Generations[id, Storage<T>.Generation] & mask) == mask &&
(Entity.Generations[id, Storage<Y>.Generation] & mask2) == mask2;
return (Entity.GenerationsInstant[id, Storage<T>.Generation] & mask) == mask &&
(Entity.GenerationsInstant[id, Storage<Y>.Generation] & mask2) == mask2;
}

[Il2CppSetOption(Option.NullChecks | Option.ArrayBoundsChecks, false)]
Expand All @@ -136,9 +139,9 @@ public bool Has<T, Y, U>()
var mask2 = Storage<Y>.ComponentMask;
var mask3 = Storage<U>.ComponentMask;

return (Entity.Generations[id, Storage<T>.Generation] & mask) == mask &&
(Entity.Generations[id, Storage<Y>.Generation] & mask2) == mask2 &&
(Entity.Generations[id, Storage<U>.Generation] & mask3) == mask3;
return (Entity.GenerationsInstant[id, Storage<T>.Generation] & mask) == mask &&
(Entity.GenerationsInstant[id, Storage<Y>.Generation] & mask2) == mask2 &&
(Entity.GenerationsInstant[id, Storage<U>.Generation] & mask3) == mask3;
}


Expand All @@ -151,10 +154,10 @@ public bool Has<T, Y, U, I>()
var mask3 = Storage<U>.ComponentMask;
var mask4 = Storage<I>.ComponentMask;

return (Entity.Generations[id, Storage<T>.Generation] & mask) == mask &&
(Entity.Generations[id, Storage<Y>.Generation] & mask2) == mask2 &&
(Entity.Generations[id, Storage<U>.Generation] & mask3) == mask3 &&
(Entity.Generations[id, Storage<I>.Generation] & mask4) == mask4;
return (Entity.GenerationsInstant[id, Storage<T>.Generation] & mask) == mask &&
(Entity.GenerationsInstant[id, Storage<Y>.Generation] & mask2) == mask2 &&
(Entity.GenerationsInstant[id, Storage<U>.Generation] & mask3) == mask3 &&
(Entity.GenerationsInstant[id, Storage<I>.Generation] & mask4) == mask4;
}


Expand All @@ -168,11 +171,11 @@ public bool Has<T, Y, U, I, O>()
var mask4 = Storage<I>.ComponentMask;
var mask5 = Storage<O>.ComponentMask;

return (Entity.Generations[id, Storage<T>.Generation] & mask) == mask &&
(Entity.Generations[id, Storage<Y>.Generation] & mask2) == mask2 &&
(Entity.Generations[id, Storage<U>.Generation] & mask3) == mask3 &&
(Entity.Generations[id, Storage<I>.Generation] & mask4) == mask4 &&
(Entity.Generations[id, Storage<O>.Generation] & mask5) == mask5;
return (Entity.GenerationsInstant[id, Storage<T>.Generation] & mask) == mask &&
(Entity.GenerationsInstant[id, Storage<Y>.Generation] & mask2) == mask2 &&
(Entity.GenerationsInstant[id, Storage<U>.Generation] & mask3) == mask3 &&
(Entity.GenerationsInstant[id, Storage<I>.Generation] & mask4) == mask4 &&
(Entity.GenerationsInstant[id, Storage<O>.Generation] & mask5) == mask5;
}
#if !ACTORS_COMPONENTS_STRUCTS
/// <summary>
Expand Down

0 comments on commit a4b556b

Please sign in to comment.