diff --git a/src/EntityStorage.cs b/src/EntityStorage.cs index d2f912d..b0a7b3e 100644 --- a/src/EntityStorage.cs +++ b/src/EntityStorage.cs @@ -18,8 +18,14 @@ namespace MoonTools.ECS public Entity Create() { var entity = new Entity(NextID()); - EntityToComponentTypeIndices.TryAdd(entity.ID, new HashSet()); - EntityToRelationTypeIndices.TryAdd(entity.ID, new HashSet()); + if (!EntityToComponentTypeIndices.ContainsKey(entity.ID)) + { + EntityToComponentTypeIndices.Add(entity.ID, new HashSet()); + } + if (!EntityToRelationTypeIndices.ContainsKey(entity.ID)) + { + EntityToRelationTypeIndices.Add(entity.ID, new HashSet()); + } return entity; }