system for changing drawable component layer
parent
d53bf043db
commit
83b180fadb
|
@ -72,18 +72,16 @@ namespace Encompass
|
|||
return id;
|
||||
}
|
||||
|
||||
internal Guid MarkDrawComponentForWrite<TComponent>(Entity entity, TComponent component, int priority, int layer = 0) where TComponent : struct, IComponent
|
||||
{
|
||||
var id = MarkComponentForWrite(entity, component, priority);
|
||||
drawLayerManager.RegisterComponentWithLayer(id, layer);
|
||||
return id;
|
||||
}
|
||||
|
||||
internal void RegisterDrawableComponent<TComponent>(Guid componentID, TComponent component) where TComponent : IDrawableComponent
|
||||
{
|
||||
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;
|
||||
|
|
|
@ -506,7 +506,18 @@ namespace Encompass
|
|||
|
||||
if (component is IDrawableComponent drawableComponent)
|
||||
{
|
||||
componentManager.RegisterDrawableComponent(componentID, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue