adds pooled dictionary to componentmanager lookup
parent
062b31dfb8
commit
efb47c2879
|
@ -2,6 +2,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Encompass.Exceptions;
|
using Encompass.Exceptions;
|
||||||
|
using Collections.Pooled;
|
||||||
|
|
||||||
namespace Encompass
|
namespace Encompass
|
||||||
{
|
{
|
||||||
|
@ -14,7 +15,7 @@ namespace Encompass
|
||||||
private readonly Dictionary<Guid, HashSet<Guid>> entityIDToComponentIDs = new Dictionary<Guid, HashSet<Guid>>();
|
private readonly Dictionary<Guid, HashSet<Guid>> entityIDToComponentIDs = new Dictionary<Guid, HashSet<Guid>>();
|
||||||
private readonly Dictionary<Guid, Guid> componentIDToEntityID = new Dictionary<Guid, Guid>();
|
private readonly Dictionary<Guid, Guid> componentIDToEntityID = new Dictionary<Guid, Guid>();
|
||||||
|
|
||||||
private readonly Dictionary<Guid, Dictionary<Type, HashSet<Guid>>> entityIDToComponentTypeToComponentIDs = new Dictionary<Guid, Dictionary<Type, HashSet<Guid>>>();
|
private readonly Dictionary<Guid, PooledDictionary<Type, HashSet<Guid>>> entityIDToComponentTypeToComponentIDs = new Dictionary<Guid, PooledDictionary<Type, HashSet<Guid>>>();
|
||||||
|
|
||||||
private readonly Dictionary<Type, HashSet<Guid>> typeToComponentIDs = new Dictionary<Type, HashSet<Guid>>();
|
private readonly Dictionary<Type, HashSet<Guid>> typeToComponentIDs = new Dictionary<Type, HashSet<Guid>>();
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ namespace Encompass
|
||||||
internal void RegisterEntity(Guid entityID)
|
internal void RegisterEntity(Guid entityID)
|
||||||
{
|
{
|
||||||
entityIDToComponentIDs.Add(entityID, new HashSet<Guid>());
|
entityIDToComponentIDs.Add(entityID, new HashSet<Guid>());
|
||||||
entityIDToComponentTypeToComponentIDs.Add(entityID, new Dictionary<Type, HashSet<Guid>>());
|
entityIDToComponentTypeToComponentIDs.Add(entityID, new PooledDictionary<Type, HashSet<Guid>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Guid NextID()
|
internal Guid NextID()
|
||||||
|
@ -199,6 +200,11 @@ namespace Encompass
|
||||||
public void RegisterDestroyedEntity(Guid entityID)
|
public void RegisterDestroyedEntity(Guid entityID)
|
||||||
{
|
{
|
||||||
entityIDToComponentIDs.Remove(entityID);
|
entityIDToComponentIDs.Remove(entityID);
|
||||||
|
|
||||||
|
foreach (var pooledDictionary in entityIDToComponentTypeToComponentIDs.Values)
|
||||||
|
{
|
||||||
|
pooledDictionary.Dispose();
|
||||||
|
}
|
||||||
entityIDToComponentTypeToComponentIDs.Remove(entityID);
|
entityIDToComponentTypeToComponentIDs.Remove(entityID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,6 @@ namespace Encompass
|
||||||
newComponentMessage.component = component;
|
newComponentMessage.component = component;
|
||||||
SendMessage(newComponentMessage);
|
SendMessage(newComponentMessage);
|
||||||
SendPendingComponentMessage(newComponentMessage);
|
SendPendingComponentMessage(newComponentMessage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return componentID;
|
return componentID;
|
||||||
|
|
Loading…
Reference in New Issue