mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-17 17:34:36 +08:00
update MetaID.CollisionList
This commit is contained in:
parent
9078b8da32
commit
88328d354c
@ -160,6 +160,8 @@ namespace DCFApixels.DragonECS
|
||||
private Entry[] _entries;
|
||||
private int _collisionsCount;
|
||||
private int _listsCount;
|
||||
private HashSet<string> _collidingIDs;
|
||||
|
||||
public int CollisionsCount
|
||||
{
|
||||
get { return _collisionsCount; }
|
||||
@ -181,6 +183,15 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsCollidingID(string id)
|
||||
{
|
||||
if(_collidingIDs== null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return _collidingIDs.Contains(id);
|
||||
}
|
||||
|
||||
public CollisionList(IEnumerable<TypeMeta> metas)
|
||||
{
|
||||
var metasCount = metas.Count();
|
||||
@ -223,6 +234,7 @@ namespace DCFApixels.DragonECS
|
||||
|
||||
if (hasCollision)
|
||||
{
|
||||
_collidingIDs = new HashSet<string>();
|
||||
for (int i = 0; i < _listsCount; i++)
|
||||
{
|
||||
ref var list = ref _linkedLists[i];
|
||||
@ -231,6 +243,10 @@ namespace DCFApixels.DragonECS
|
||||
_linkedLists[i--] = _linkedLists[--_listsCount];
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < _listsCount; i++)
|
||||
{
|
||||
_collidingIDs.Add(this[i].MetaID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user