SetComponent should not require Reads
parent
d45295ae87
commit
038b3aceee
|
@ -77,11 +77,6 @@ namespace Encompass
|
|||
drawLayerManager.RegisterComponentWithLayer(componentID, component.Layer);
|
||||
}
|
||||
|
||||
internal void ChangeDrawableComponentLayer(Guid componentID, int layer)
|
||||
{
|
||||
drawLayerManager.AdjustComponentLayer(componentID, layer);
|
||||
}
|
||||
|
||||
internal void AddComponent(Entity entity, Type type, Guid componentID, IComponent component)
|
||||
{
|
||||
IDToComponent[componentID] = component;
|
||||
|
|
|
@ -51,6 +51,8 @@ namespace Encompass
|
|||
|
||||
public void RegisterComponentWithLayer(Guid id, int layer)
|
||||
{
|
||||
if (componentIDToLayerIndex.ContainsKey(id)) { UnRegisterComponentWithLayer(id); }
|
||||
|
||||
if (layerIndexToComponentIDs.ContainsKey(layer))
|
||||
{
|
||||
var set = layerIndexToComponentIDs[layer];
|
||||
|
@ -81,12 +83,6 @@ namespace Encompass
|
|||
componentIDToLayerIndex.Remove(id);
|
||||
}
|
||||
|
||||
public void AdjustComponentLayer(Guid id, int layer)
|
||||
{
|
||||
UnRegisterComponentWithLayer(id);
|
||||
RegisterComponentWithLayer(id, layer);
|
||||
}
|
||||
|
||||
public IEnumerable<Guid> ComponentIDsByLayer(int layer)
|
||||
{
|
||||
return layerIndexToComponentIDs.ContainsKey(layer) ?
|
||||
|
|
|
@ -521,21 +521,10 @@ namespace Encompass
|
|||
}
|
||||
|
||||
if (component is IDrawableComponent drawableComponent)
|
||||
{
|
||||
if (HasComponent<TComponent>(entity))
|
||||
{
|
||||
var currentComponent = GetComponent<TComponent>(entity);
|
||||
if (((IDrawableComponent)currentComponent).Layer != drawableComponent.Layer)
|
||||
{
|
||||
componentManager.ChangeDrawableComponentLayer(componentID, drawableComponent.Layer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
componentManager.RegisterDrawableComponent(componentID, drawableComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a Message.
|
||||
|
@ -685,7 +674,8 @@ namespace Encompass
|
|||
{
|
||||
if (!HasComponent<TComponent>(entity)) { return false; }
|
||||
|
||||
var (componentID, _) = GetComponentHelper<TComponent>(entity);
|
||||
var (componentID, component) = GetComponentHelper<TComponent>(entity);
|
||||
|
||||
RemoveComponent(componentID);
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue