Skip to content

Commit a4b556b

Browse files
author
Pixeye
committed
update
1 parent ca46ca2 commit a4b556b

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

Runtime/LibEcs/CacheEntity.cs

+10
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ public void Add(int type)
4747

4848
componentsIds[componentsAmount++] = (ushort) type;
4949
}
50+
51+
public void CleanMask(int id)
52+
{
53+
for (int i = componentsAmount - 1; i >= 0; i--)
54+
{
55+
var generation = Storage.Generations[componentsIds[i]];
56+
var mask = Storage.Masks[componentsIds[i]];
57+
Entity.GenerationsInstant[id, generation] &= ~mask;
58+
}
59+
}
5060

5161
// public void Remove(int type)
5262
// {

Runtime/LibEcs/ent.cs

+18-15
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public void Release()
7171
}
7272
#endif
7373

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

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

127-
return (Entity.Generations[id, Storage<T>.Generation] & mask) == mask &&
128-
(Entity.Generations[id, Storage<Y>.Generation] & mask2) == mask2;
130+
return (Entity.GenerationsInstant[id, Storage<T>.Generation] & mask) == mask &&
131+
(Entity.GenerationsInstant[id, Storage<Y>.Generation] & mask2) == mask2;
129132
}
130133

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

139-
return (Entity.Generations[id, Storage<T>.Generation] & mask) == mask &&
140-
(Entity.Generations[id, Storage<Y>.Generation] & mask2) == mask2 &&
141-
(Entity.Generations[id, Storage<U>.Generation] & mask3) == mask3;
142+
return (Entity.GenerationsInstant[id, Storage<T>.Generation] & mask) == mask &&
143+
(Entity.GenerationsInstant[id, Storage<Y>.Generation] & mask2) == mask2 &&
144+
(Entity.GenerationsInstant[id, Storage<U>.Generation] & mask3) == mask3;
142145
}
143146

144147

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

154-
return (Entity.Generations[id, Storage<T>.Generation] & mask) == mask &&
155-
(Entity.Generations[id, Storage<Y>.Generation] & mask2) == mask2 &&
156-
(Entity.Generations[id, Storage<U>.Generation] & mask3) == mask3 &&
157-
(Entity.Generations[id, Storage<I>.Generation] & mask4) == mask4;
157+
return (Entity.GenerationsInstant[id, Storage<T>.Generation] & mask) == mask &&
158+
(Entity.GenerationsInstant[id, Storage<Y>.Generation] & mask2) == mask2 &&
159+
(Entity.GenerationsInstant[id, Storage<U>.Generation] & mask3) == mask3 &&
160+
(Entity.GenerationsInstant[id, Storage<I>.Generation] & mask4) == mask4;
158161
}
159162

160163

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

171-
return (Entity.Generations[id, Storage<T>.Generation] & mask) == mask &&
172-
(Entity.Generations[id, Storage<Y>.Generation] & mask2) == mask2 &&
173-
(Entity.Generations[id, Storage<U>.Generation] & mask3) == mask3 &&
174-
(Entity.Generations[id, Storage<I>.Generation] & mask4) == mask4 &&
175-
(Entity.Generations[id, Storage<O>.Generation] & mask5) == mask5;
174+
return (Entity.GenerationsInstant[id, Storage<T>.Generation] & mask) == mask &&
175+
(Entity.GenerationsInstant[id, Storage<Y>.Generation] & mask2) == mask2 &&
176+
(Entity.GenerationsInstant[id, Storage<U>.Generation] & mask3) == mask3 &&
177+
(Entity.GenerationsInstant[id, Storage<I>.Generation] & mask4) == mask4 &&
178+
(Entity.GenerationsInstant[id, Storage<O>.Generation] & mask5) == mask5;
176179
}
177180
#if !ACTORS_COMPONENTS_STRUCTS
178181
/// <summary>

0 commit comments

Comments
 (0)