fix new hashsets being allocated on each entity create
parent
f69d132a5e
commit
e4131d58f5
|
@ -18,8 +18,14 @@ namespace MoonTools.ECS
|
||||||
public Entity Create()
|
public Entity Create()
|
||||||
{
|
{
|
||||||
var entity = new Entity(NextID());
|
var entity = new Entity(NextID());
|
||||||
EntityToComponentTypeIndices.TryAdd(entity.ID, new HashSet<int>());
|
if (!EntityToComponentTypeIndices.ContainsKey(entity.ID))
|
||||||
EntityToRelationTypeIndices.TryAdd(entity.ID, new HashSet<int>());
|
{
|
||||||
|
EntityToComponentTypeIndices.Add(entity.ID, new HashSet<int>());
|
||||||
|
}
|
||||||
|
if (!EntityToRelationTypeIndices.ContainsKey(entity.ID))
|
||||||
|
{
|
||||||
|
EntityToRelationTypeIndices.Add(entity.ID, new HashSet<int>());
|
||||||
|
}
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue