adds read check to HasComponent and HasComponent and SomeComponent to Renderer
parent
4c82337362
commit
949c3aa26d
|
@ -166,6 +166,11 @@ namespace Encompass
|
|||
|
||||
protected bool HasComponent<TComponent>(Entity entity) where TComponent : struct, IComponent
|
||||
{
|
||||
if (!readTypes.Contains(typeof(TComponent)))
|
||||
{
|
||||
throw new IllegalReadException("Engine {0} tried to read undeclared Component {1}", this.GetType().Name, typeof(TComponent).Name);
|
||||
}
|
||||
|
||||
return componentManager.EntityHasComponentOfType<TComponent>(entity.ID);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,5 +58,15 @@ namespace Encompass
|
|||
{
|
||||
return GetComponents<TComponent>(entity).First();
|
||||
}
|
||||
|
||||
protected bool HasComponent<TComponent>(Entity entity) where TComponent : struct, IComponent
|
||||
{
|
||||
return componentManager.EntityHasComponentOfType<TComponent>(entity.ID);
|
||||
}
|
||||
|
||||
protected bool SomeComponent<TComponent>() where TComponent : struct, IComponent
|
||||
{
|
||||
return componentManager.GetActiveComponentsByType<TComponent>().Any();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ namespace Tests
|
|||
public Entity entity;
|
||||
}
|
||||
|
||||
[Reads(typeof(HasComponentWhenInactiveTestMessage))]
|
||||
[Reads(typeof(HasComponentWhenInactiveTestMessage), typeof(MockComponent))]
|
||||
class HasComponentWhenInactiveTestEngine : Engine
|
||||
{
|
||||
public override void Update(double dt)
|
||||
|
@ -290,7 +290,7 @@ namespace Tests
|
|||
public Guid componentID;
|
||||
}
|
||||
|
||||
[Reads(typeof(ActivateComponentMessage))]
|
||||
[Reads(typeof(ActivateComponentMessage), typeof(MockComponent))]
|
||||
[Writes(typeof(MockComponent))]
|
||||
class ActivateComponentEngine : Engine
|
||||
{
|
||||
|
@ -336,7 +336,7 @@ namespace Tests
|
|||
public Guid componentID;
|
||||
}
|
||||
|
||||
[Reads(typeof(DeactivateComponentMessage))]
|
||||
[Reads(typeof(DeactivateComponentMessage), typeof(MockComponent))]
|
||||
[Writes(typeof(MockComponent))]
|
||||
class DeactivateComponentEngine : Engine
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue