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