fix emitters not being generated for certain component types +rename component message manager
parent
005405512e
commit
8218ada6d1
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Encompass
|
namespace Encompass
|
||||||
{
|
{
|
||||||
|
@ -69,11 +68,6 @@ namespace Encompass
|
||||||
return Lookup<TComponent>().Count > 0;
|
return Lookup<TComponent>().Count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public IEnumerable<TComponent> All<TComponent>() where TComponent : struct, IComponent
|
|
||||||
// {
|
|
||||||
// return Lookup<TComponent>().All<TComponent>();
|
|
||||||
// }
|
|
||||||
|
|
||||||
public IEnumerable<(Entity, Type, IComponent)> AllInterfaceTyped()
|
public IEnumerable<(Entity, Type, IComponent)> AllInterfaceTyped()
|
||||||
{
|
{
|
||||||
foreach (var store in Stores.Values)
|
foreach (var store in Stores.Values)
|
||||||
|
|
|
@ -6,15 +6,15 @@ namespace Encompass
|
||||||
internal class ComponentManager
|
internal class ComponentManager
|
||||||
{
|
{
|
||||||
private readonly DrawLayerManager drawLayerManager;
|
private readonly DrawLayerManager drawLayerManager;
|
||||||
private readonly ComponentMessageManager componentMessageManager;
|
private readonly ComponentUpdateManager componentUpdateManager;
|
||||||
|
|
||||||
private readonly ComponentStore componentStore = new ComponentStore();
|
private readonly ComponentStore componentStore = new ComponentStore();
|
||||||
private readonly HashSet<Entity> entitiesMarkedForRemoval = new HashSet<Entity>();
|
private readonly HashSet<Entity> entitiesMarkedForRemoval = new HashSet<Entity>();
|
||||||
|
|
||||||
public ComponentManager(DrawLayerManager drawLayerManager, ComponentMessageManager componentMessageManager)
|
public ComponentManager(DrawLayerManager drawLayerManager, ComponentUpdateManager componentUpdateManager)
|
||||||
{
|
{
|
||||||
this.drawLayerManager = drawLayerManager;
|
this.drawLayerManager = drawLayerManager;
|
||||||
this.componentMessageManager = componentMessageManager;
|
this.componentUpdateManager = componentUpdateManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void SetComponentStore(ComponentStore componentStore)
|
internal void SetComponentStore(ComponentStore componentStore)
|
||||||
|
@ -29,12 +29,12 @@ namespace Encompass
|
||||||
|
|
||||||
internal void AddComponent<TComponent>(Entity entity, TComponent component) where TComponent : struct, IComponent
|
internal void AddComponent<TComponent>(Entity entity, TComponent component) where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
componentStore.Set<TComponent>(entity, component);
|
componentStore.Set(entity, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void WriteComponents()
|
internal void WriteComponents()
|
||||||
{
|
{
|
||||||
componentStore.SwapWith(componentMessageManager.UpToDateComponentStore);
|
componentStore.SwapWith(componentUpdateManager.UpToDateComponentStore);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal IEnumerable<(TComponent, Entity)> GetComponentsIncludingEntity<TComponent>() where TComponent : struct, IComponent
|
internal IEnumerable<(TComponent, Entity)> GetComponentsIncludingEntity<TComponent>() where TComponent : struct, IComponent
|
||||||
|
@ -80,8 +80,7 @@ namespace Encompass
|
||||||
|
|
||||||
public void Remove<TComponent>(Entity entity) where TComponent : struct, IComponent
|
public void Remove<TComponent>(Entity entity) where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
//componentStore.Remove<TComponent>(entity);
|
componentUpdateManager.Remove<TComponent>(entity);
|
||||||
componentMessageManager.Remove<TComponent>(entity);
|
|
||||||
drawLayerManager.UnRegisterComponentWithLayer<TComponent>(entity);
|
drawLayerManager.UnRegisterComponentWithLayer<TComponent>(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,21 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Encompass.Exceptions;
|
|
||||||
|
|
||||||
namespace Encompass
|
namespace Encompass
|
||||||
{
|
{
|
||||||
class ComponentMessageManager
|
internal class ComponentUpdateManager
|
||||||
{
|
{
|
||||||
private readonly ComponentStore componentStore = new ComponentStore();
|
private readonly ComponentStore existingAndPendingComponentStore = new ComponentStore();
|
||||||
|
|
||||||
private readonly ComponentStore existingComponentStore = new ComponentStore();
|
private readonly ComponentStore existingComponentStore = new ComponentStore();
|
||||||
private readonly ComponentStore pendingComponentStore = new ComponentStore();
|
private readonly ComponentStore pendingComponentStore = new ComponentStore();
|
||||||
private ComponentStore upToDateComponentStore = new ComponentStore();
|
|
||||||
|
|
||||||
private readonly Dictionary<Type, Dictionary<Entity, int>> typeToEntityToPendingComponentPriority = new Dictionary<Type, Dictionary<Entity, int>>(128);
|
private readonly Dictionary<Type, Dictionary<Entity, int>> typeToEntityToPendingComponentPriority = new Dictionary<Type, Dictionary<Entity, int>>(128);
|
||||||
|
|
||||||
public ComponentStore UpToDateComponentStore { get => upToDateComponentStore; }
|
public ComponentStore UpToDateComponentStore { get; private set; } = new ComponentStore();
|
||||||
|
|
||||||
internal void ClearMessages()
|
internal void Clear()
|
||||||
{
|
{
|
||||||
componentStore.ClearAll();
|
existingAndPendingComponentStore.ClearAll();
|
||||||
existingComponentStore.ClearAll();
|
existingComponentStore.ClearAll();
|
||||||
pendingComponentStore.ClearAll();
|
pendingComponentStore.ClearAll();
|
||||||
UpToDateComponentStore.ClearAll();
|
UpToDateComponentStore.ClearAll();
|
||||||
|
@ -32,7 +28,7 @@ namespace Encompass
|
||||||
|
|
||||||
internal void SetStartingComponentStore(ComponentStore componentStore)
|
internal void SetStartingComponentStore(ComponentStore componentStore)
|
||||||
{
|
{
|
||||||
upToDateComponentStore = componentStore;
|
UpToDateComponentStore = componentStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void AddExistingComponent<TComponent>(Entity entity, TComponent component) where TComponent : struct, IComponent
|
internal void AddExistingComponent<TComponent>(Entity entity, TComponent component) where TComponent : struct, IComponent
|
||||||
|
@ -52,20 +48,20 @@ namespace Encompass
|
||||||
|
|
||||||
private void RegisterExistingOrPendingComponentMessage<TComponent>(Entity entity, TComponent component) where TComponent : struct, IComponent
|
private void RegisterExistingOrPendingComponentMessage<TComponent>(Entity entity, TComponent component) where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
componentStore.Set(entity, component);
|
existingAndPendingComponentStore.Set(entity, component);
|
||||||
upToDateComponentStore.Set(entity, component);
|
UpToDateComponentStore.Set(entity, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateComponent<TComponent>(Entity entity, TComponent component, int priority) where TComponent : struct, IComponent
|
public void UpdateComponent<TComponent>(Entity entity, TComponent component, int priority) where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
upToDateComponentStore.Set<TComponent>(entity, component, priority);
|
UpToDateComponentStore.Set<TComponent>(entity, component, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
// general component reads by type
|
// general component reads by type
|
||||||
|
|
||||||
internal IEnumerable<(Entity, TComponent)> ReadExistingAndPendingComponentsByType<TComponent>() where TComponent : struct, IComponent
|
internal IEnumerable<(Entity, TComponent)> ReadExistingAndPendingComponentsByType<TComponent>() where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
return componentStore.All<TComponent>();
|
return existingAndPendingComponentStore.All<TComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal IEnumerable<(Entity, TComponent)> ReadExistingComponentsByType<TComponent>() where TComponent : struct, IComponent
|
internal IEnumerable<(Entity, TComponent)> ReadExistingComponentsByType<TComponent>() where TComponent : struct, IComponent
|
||||||
|
@ -102,7 +98,7 @@ namespace Encompass
|
||||||
|
|
||||||
internal bool SomeExistingOrPendingComponent<TComponent>() where TComponent : struct, IComponent
|
internal bool SomeExistingOrPendingComponent<TComponent>() where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
return componentStore.Any<TComponent>();
|
return existingAndPendingComponentStore.Any<TComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool SomeExistingComponent<TComponent>() where TComponent : struct, IComponent
|
internal bool SomeExistingComponent<TComponent>() where TComponent : struct, IComponent
|
||||||
|
@ -131,12 +127,12 @@ namespace Encompass
|
||||||
|
|
||||||
internal bool HasExistingOrPendingComponent<TComponent>(Entity entity) where TComponent : struct, IComponent
|
internal bool HasExistingOrPendingComponent<TComponent>(Entity entity) where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
return componentStore.Has<TComponent>(entity);
|
return existingAndPendingComponentStore.Has<TComponent>(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool HasExistingOrPendingComponent(Entity entity, Type type)
|
internal bool HasExistingOrPendingComponent(Entity entity, Type type)
|
||||||
{
|
{
|
||||||
return componentStore.Has(type, entity);
|
return existingAndPendingComponentStore.Has(type, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool HasExistingComponent<TComponent>(Entity entity) where TComponent : struct, IComponent
|
internal bool HasExistingComponent<TComponent>(Entity entity) where TComponent : struct, IComponent
|
||||||
|
@ -161,7 +157,7 @@ namespace Encompass
|
||||||
|
|
||||||
internal void Remove<TComponent>(Entity entity) where TComponent : struct, IComponent
|
internal void Remove<TComponent>(Entity entity) where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
upToDateComponentStore.Remove<TComponent>(entity);
|
UpToDateComponentStore.Remove<TComponent>(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -28,14 +28,11 @@ namespace Encompass
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal bool usesTimeDilation = true;
|
internal bool usesTimeDilation = true;
|
||||||
public bool TimeDilationActive { get => usesTimeDilation && timeManager.TimeDilationActive; }
|
public bool TimeDilationActive { get => usesTimeDilation && timeManager.TimeDilationActive; }
|
||||||
/// <summary>
|
|
||||||
/// Used when activating time dilation. Lower priority overrides higher priority.
|
|
||||||
/// </summary>
|
|
||||||
|
|
||||||
private EntityManager entityManager;
|
private EntityManager entityManager;
|
||||||
private MessageManager messageManager;
|
private MessageManager messageManager;
|
||||||
private ComponentManager componentManager;
|
private ComponentManager componentManager;
|
||||||
private ComponentMessageManager componentMessageManager;
|
private ComponentUpdateManager componentUpdateManager;
|
||||||
private TimeManager timeManager;
|
private TimeManager timeManager;
|
||||||
|
|
||||||
protected Engine()
|
protected Engine()
|
||||||
|
@ -81,9 +78,9 @@ namespace Encompass
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (obj is Engine)
|
if (obj is Engine engine)
|
||||||
{
|
{
|
||||||
return this.Equals((Engine)obj);
|
return Equals(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -114,9 +111,9 @@ namespace Encompass
|
||||||
this.messageManager = messageManager;
|
this.messageManager = messageManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void AssignComponentMessageManager(ComponentMessageManager componentMessageManager)
|
internal void AssignComponentUpdateManager(ComponentUpdateManager componentUpdateManager)
|
||||||
{
|
{
|
||||||
this.componentMessageManager = componentMessageManager;
|
this.componentUpdateManager = componentUpdateManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void AssignTimeManager(TimeManager timeManager)
|
internal void AssignTimeManager(TimeManager timeManager)
|
||||||
|
@ -186,15 +183,15 @@ namespace Encompass
|
||||||
var existingRead = readTypes.Contains(typeof(TComponent));
|
var existingRead = readTypes.Contains(typeof(TComponent));
|
||||||
if (existingRead && pendingRead)
|
if (existingRead && pendingRead)
|
||||||
{
|
{
|
||||||
return componentMessageManager.ReadExistingAndPendingComponentsByType<TComponent>();
|
return componentUpdateManager.ReadExistingAndPendingComponentsByType<TComponent>();
|
||||||
}
|
}
|
||||||
else if (existingRead)
|
else if (existingRead)
|
||||||
{
|
{
|
||||||
return componentMessageManager.ReadExistingComponentsByType<TComponent>();
|
return componentUpdateManager.ReadExistingComponentsByType<TComponent>();
|
||||||
}
|
}
|
||||||
else if (pendingRead)
|
else if (pendingRead)
|
||||||
{
|
{
|
||||||
return componentMessageManager.ReadPendingComponentsByType<TComponent>();
|
return componentUpdateManager.ReadPendingComponentsByType<TComponent>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -229,15 +226,15 @@ namespace Encompass
|
||||||
var existingRead = readTypes.Contains(typeof(TComponent));
|
var existingRead = readTypes.Contains(typeof(TComponent));
|
||||||
if (existingRead && pendingRead)
|
if (existingRead && pendingRead)
|
||||||
{
|
{
|
||||||
return componentMessageManager.ReadFirstExistingOrPendingComponentByType<TComponent>();
|
return componentUpdateManager.ReadFirstExistingOrPendingComponentByType<TComponent>();
|
||||||
}
|
}
|
||||||
else if (existingRead)
|
else if (existingRead)
|
||||||
{
|
{
|
||||||
return componentMessageManager.ReadFirstExistingComponentByType<TComponent>();
|
return componentUpdateManager.ReadFirstExistingComponentByType<TComponent>();
|
||||||
}
|
}
|
||||||
else if (pendingRead)
|
else if (pendingRead)
|
||||||
{
|
{
|
||||||
return componentMessageManager.ReadFirstPendingComponentByType<TComponent>();
|
return componentUpdateManager.ReadFirstPendingComponentByType<TComponent>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -271,15 +268,15 @@ namespace Encompass
|
||||||
var existingRead = readTypes.Contains(typeof(TComponent));
|
var existingRead = readTypes.Contains(typeof(TComponent));
|
||||||
if (existingRead && pendingRead)
|
if (existingRead && pendingRead)
|
||||||
{
|
{
|
||||||
return componentMessageManager.SomeExistingOrPendingComponent<TComponent>();
|
return componentUpdateManager.SomeExistingOrPendingComponent<TComponent>();
|
||||||
}
|
}
|
||||||
else if (existingRead)
|
else if (existingRead)
|
||||||
{
|
{
|
||||||
return componentMessageManager.SomeExistingComponent<TComponent>();
|
return componentUpdateManager.SomeExistingComponent<TComponent>();
|
||||||
}
|
}
|
||||||
else if (pendingRead)
|
else if (pendingRead)
|
||||||
{
|
{
|
||||||
return componentMessageManager.SomePendingComponent<TComponent>();
|
return componentUpdateManager.SomePendingComponent<TComponent>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -293,13 +290,13 @@ namespace Encompass
|
||||||
var existingRead = readTypes.Contains(typeof(TComponent));
|
var existingRead = readTypes.Contains(typeof(TComponent));
|
||||||
if (existingRead && pendingRead)
|
if (existingRead && pendingRead)
|
||||||
{
|
{
|
||||||
if (componentMessageManager.HasPendingComponent<TComponent>(entity))
|
if (componentUpdateManager.HasPendingComponent<TComponent>(entity))
|
||||||
{
|
{
|
||||||
return componentMessageManager.ReadPendingComponentByEntityAndType<TComponent>(entity);
|
return componentUpdateManager.ReadPendingComponentByEntityAndType<TComponent>(entity);
|
||||||
}
|
}
|
||||||
else if (componentMessageManager.HasExistingComponent<TComponent>(entity))
|
else if (componentUpdateManager.HasExistingComponent<TComponent>(entity))
|
||||||
{
|
{
|
||||||
return componentMessageManager.ReadExistingComponentByEntityAndType<TComponent>(entity);
|
return componentUpdateManager.ReadExistingComponentByEntityAndType<TComponent>(entity);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -308,11 +305,11 @@ namespace Encompass
|
||||||
}
|
}
|
||||||
else if (existingRead)
|
else if (existingRead)
|
||||||
{
|
{
|
||||||
return componentMessageManager.ReadExistingComponentByEntityAndType<TComponent>(entity);
|
return componentUpdateManager.ReadExistingComponentByEntityAndType<TComponent>(entity);
|
||||||
}
|
}
|
||||||
else if (pendingRead)
|
else if (pendingRead)
|
||||||
{
|
{
|
||||||
return componentMessageManager.ReadPendingComponentByEntityAndType<TComponent>(entity);
|
return componentUpdateManager.ReadPendingComponentByEntityAndType<TComponent>(entity);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -347,15 +344,15 @@ namespace Encompass
|
||||||
|
|
||||||
if (pendingRead && existingRead)
|
if (pendingRead && existingRead)
|
||||||
{
|
{
|
||||||
return componentMessageManager.HasExistingOrPendingComponent<TComponent>(entity);
|
return componentUpdateManager.HasExistingOrPendingComponent<TComponent>(entity);
|
||||||
}
|
}
|
||||||
else if (existingRead)
|
else if (existingRead)
|
||||||
{
|
{
|
||||||
return componentMessageManager.HasExistingComponent<TComponent>(entity);
|
return componentUpdateManager.HasExistingComponent<TComponent>(entity);
|
||||||
}
|
}
|
||||||
else if (pendingRead)
|
else if (pendingRead)
|
||||||
{
|
{
|
||||||
return componentMessageManager.HasPendingComponent<TComponent>(entity);
|
return componentUpdateManager.HasPendingComponent<TComponent>(entity);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -376,15 +373,15 @@ namespace Encompass
|
||||||
|
|
||||||
if (pendingRead && existingRead)
|
if (pendingRead && existingRead)
|
||||||
{
|
{
|
||||||
return componentMessageManager.HasExistingOrPendingComponent(entity, type);
|
return componentUpdateManager.HasExistingOrPendingComponent(entity, type);
|
||||||
}
|
}
|
||||||
else if (existingRead)
|
else if (existingRead)
|
||||||
{
|
{
|
||||||
return componentMessageManager.HasExistingComponent(entity, type);
|
return componentUpdateManager.HasExistingComponent(entity, type);
|
||||||
}
|
}
|
||||||
else if (pendingRead)
|
else if (pendingRead)
|
||||||
{
|
{
|
||||||
return componentMessageManager.HasPendingComponent(entity, type);
|
return componentUpdateManager.HasPendingComponent(entity, type);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -413,7 +410,7 @@ namespace Encompass
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
componentMessageManager.UpdateComponent(entity, component, priority);
|
componentUpdateManager.UpdateComponent(entity, component, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component is IDrawableComponent drawableComponent)
|
if (component is IDrawableComponent drawableComponent)
|
||||||
|
@ -471,12 +468,12 @@ namespace Encompass
|
||||||
|
|
||||||
internal void AddExistingComponent<TComponent>(Entity entity, TComponent component) where TComponent : struct, IComponent
|
internal void AddExistingComponent<TComponent>(Entity entity, TComponent component) where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
componentMessageManager.AddExistingComponent(entity, component);
|
componentUpdateManager.AddExistingComponent(entity, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void AddPendingComponent<TComponent>(Entity entity, TComponent component, int priority) where TComponent : struct, IComponent
|
internal void AddPendingComponent<TComponent>(Entity entity, TComponent component, int priority) where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
componentMessageManager.AddPendingComponent<TComponent>(entity, component, priority);
|
componentUpdateManager.AddPendingComponent<TComponent>(entity, component, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -12,14 +12,14 @@ namespace Encompass
|
||||||
|
|
||||||
internal Entity(Guid id)
|
internal Entity(Guid id)
|
||||||
{
|
{
|
||||||
this.ID = id;
|
ID = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (obj is Entity)
|
if (obj is Entity entity)
|
||||||
{
|
{
|
||||||
return this.Equals((Entity)obj);
|
return Equals(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -5,21 +5,13 @@ namespace Encompass
|
||||||
{
|
{
|
||||||
internal class RenderManager
|
internal class RenderManager
|
||||||
{
|
{
|
||||||
private readonly ComponentManager componentManager;
|
|
||||||
private readonly DrawLayerManager drawLayerManager;
|
private readonly DrawLayerManager drawLayerManager;
|
||||||
private readonly EntityManager entityManager;
|
|
||||||
|
|
||||||
private readonly Dictionary<Type, Action<Entity, IComponent>> drawComponentTypeToOrderedRenderer = new Dictionary<Type, Action<Entity, IComponent>>(256);
|
private readonly Dictionary<Type, Action<Entity, IComponent>> drawComponentTypeToOrderedRenderer = new Dictionary<Type, Action<Entity, IComponent>>(256);
|
||||||
|
|
||||||
public RenderManager(
|
public RenderManager(DrawLayerManager drawLayerManager)
|
||||||
ComponentManager componentManager,
|
|
||||||
DrawLayerManager drawLayerManager,
|
|
||||||
EntityManager entityManager
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
this.componentManager = componentManager;
|
|
||||||
this.drawLayerManager = drawLayerManager;
|
this.drawLayerManager = drawLayerManager;
|
||||||
this.entityManager = entityManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterOrderedRenderer<TComponent>(Action<Entity, IComponent> renderAction) where TComponent : struct, IComponent
|
public void RegisterOrderedRenderer<TComponent>(Action<Entity, IComponent> renderAction) where TComponent : struct, IComponent
|
||||||
|
|
|
@ -14,23 +14,21 @@ namespace Encompass
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
double calculatedFactor = 1;
|
|
||||||
|
|
||||||
if (elapsedTime < easeInTime)
|
if (elapsedTime < easeInTime)
|
||||||
{
|
{
|
||||||
calculatedFactor = easeInFunction(elapsedTime, 1, factor - 1, easeInTime);
|
return easeInFunction(elapsedTime, 1, factor - 1, easeInTime);
|
||||||
}
|
}
|
||||||
else if (elapsedTime < easeInTime + activeTime)
|
else if (elapsedTime < easeInTime + activeTime)
|
||||||
{
|
{
|
||||||
calculatedFactor = factor;
|
return factor;
|
||||||
}
|
}
|
||||||
else if (elapsedTime < easeInTime + activeTime + easeOutTime)
|
else if (elapsedTime < easeInTime + activeTime + easeOutTime)
|
||||||
{
|
{
|
||||||
var elapsedOutTime = elapsedTime - easeInTime - activeTime;
|
var elapsedOutTime = elapsedTime - easeInTime - activeTime;
|
||||||
calculatedFactor = easeOutFunction(elapsedOutTime, factor, 1 - factor, easeOutTime);
|
return easeOutFunction(elapsedOutTime, factor, 1 - factor, easeOutTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
return calculatedFactor;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace Encompass
|
||||||
|
|
||||||
private double Linear(double t, double b, double c, double d)
|
private double Linear(double t, double b, double c, double d)
|
||||||
{
|
{
|
||||||
return c * t / d + b;
|
return (c * t / d) + b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double TimeDilationFactor
|
public double TimeDilationFactor
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace Encompass
|
||||||
private readonly EntityManager entityManager;
|
private readonly EntityManager entityManager;
|
||||||
private readonly ComponentManager componentManager;
|
private readonly ComponentManager componentManager;
|
||||||
private readonly MessageManager messageManager;
|
private readonly MessageManager messageManager;
|
||||||
private readonly ComponentMessageManager componentMessageManager;
|
private readonly ComponentUpdateManager componentUpdateManager;
|
||||||
private readonly TimeManager timeManager;
|
private readonly TimeManager timeManager;
|
||||||
private readonly RenderManager renderManager;
|
private readonly RenderManager renderManager;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ namespace Encompass
|
||||||
EntityManager entityManager,
|
EntityManager entityManager,
|
||||||
ComponentManager componentManager,
|
ComponentManager componentManager,
|
||||||
MessageManager messageManager,
|
MessageManager messageManager,
|
||||||
ComponentMessageManager componentMessageManager,
|
ComponentUpdateManager componentUpdateManager,
|
||||||
TimeManager timeManager,
|
TimeManager timeManager,
|
||||||
RenderManager renderManager
|
RenderManager renderManager
|
||||||
)
|
)
|
||||||
|
@ -29,7 +29,7 @@ namespace Encompass
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
this.componentManager = componentManager;
|
this.componentManager = componentManager;
|
||||||
this.messageManager = messageManager;
|
this.messageManager = messageManager;
|
||||||
this.componentMessageManager = componentMessageManager;
|
this.componentUpdateManager = componentUpdateManager;
|
||||||
this.timeManager = timeManager;
|
this.timeManager = timeManager;
|
||||||
this.renderManager = renderManager;
|
this.renderManager = renderManager;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ namespace Encompass
|
||||||
componentManager.WriteComponents();
|
componentManager.WriteComponents();
|
||||||
componentManager.RemoveMarkedComponents();
|
componentManager.RemoveMarkedComponents();
|
||||||
|
|
||||||
componentMessageManager.ClearMessages();
|
componentUpdateManager.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -21,12 +21,12 @@ namespace Encompass
|
||||||
private readonly List<Engine> engines = new List<Engine>();
|
private readonly List<Engine> engines = new List<Engine>();
|
||||||
private readonly DirectedGraph<Engine, Unit> engineGraph = GraphBuilder.DirectedGraph<Engine>();
|
private readonly DirectedGraph<Engine, Unit> engineGraph = GraphBuilder.DirectedGraph<Engine>();
|
||||||
private readonly ComponentStore startingComponentStoreForComponentManager = new ComponentStore();
|
private readonly ComponentStore startingComponentStoreForComponentManager = new ComponentStore();
|
||||||
private readonly ComponentStore startingComponentStoreForComponentMessageManager = new ComponentStore();
|
private readonly ComponentStore startingComponentStoreForComponentUpdateManager = new ComponentStore();
|
||||||
|
|
||||||
private readonly ComponentManager componentManager;
|
private readonly ComponentManager componentManager;
|
||||||
private readonly EntityManager entityManager;
|
private readonly EntityManager entityManager;
|
||||||
private readonly MessageManager messageManager;
|
private readonly MessageManager messageManager;
|
||||||
private readonly ComponentMessageManager componentMessageManager;
|
private readonly ComponentUpdateManager componentUpdateManager;
|
||||||
private readonly TimeManager timeManager;
|
private readonly TimeManager timeManager;
|
||||||
private readonly DrawLayerManager drawLayerManager;
|
private readonly DrawLayerManager drawLayerManager;
|
||||||
private readonly RenderManager renderManager;
|
private readonly RenderManager renderManager;
|
||||||
|
@ -41,11 +41,11 @@ namespace Encompass
|
||||||
{
|
{
|
||||||
drawLayerManager = new DrawLayerManager();
|
drawLayerManager = new DrawLayerManager();
|
||||||
timeManager = new TimeManager();
|
timeManager = new TimeManager();
|
||||||
componentMessageManager = new ComponentMessageManager();
|
componentUpdateManager = new ComponentUpdateManager();
|
||||||
componentManager = new ComponentManager(drawLayerManager, componentMessageManager);
|
componentManager = new ComponentManager(drawLayerManager, componentUpdateManager);
|
||||||
messageManager = new MessageManager(timeManager);
|
messageManager = new MessageManager(timeManager);
|
||||||
entityManager = new EntityManager(componentManager);
|
entityManager = new EntityManager(componentManager);
|
||||||
renderManager = new RenderManager(componentManager, drawLayerManager, entityManager);
|
renderManager = new RenderManager(drawLayerManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -78,7 +78,9 @@ namespace Encompass
|
||||||
public void SetComponent<TComponent>(Entity entity, TComponent component) where TComponent : struct, IComponent
|
public void SetComponent<TComponent>(Entity entity, TComponent component) where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
startingComponentStoreForComponentManager.Set(entity, component);
|
startingComponentStoreForComponentManager.Set(entity, component);
|
||||||
startingComponentStoreForComponentMessageManager.Set(entity, component);
|
startingComponentStoreForComponentUpdateManager.Set(entity, component);
|
||||||
|
|
||||||
|
RegisterComponent(typeof(TComponent));
|
||||||
|
|
||||||
if (component is IDrawableComponent drawableComponent)
|
if (component is IDrawableComponent drawableComponent)
|
||||||
{
|
{
|
||||||
|
@ -101,7 +103,7 @@ namespace Encompass
|
||||||
engine.AssignEntityManager(entityManager);
|
engine.AssignEntityManager(entityManager);
|
||||||
engine.AssignComponentManager(componentManager);
|
engine.AssignComponentManager(componentManager);
|
||||||
engine.AssignMessageManager(messageManager);
|
engine.AssignMessageManager(messageManager);
|
||||||
engine.AssignComponentMessageManager(componentMessageManager);
|
engine.AssignComponentUpdateManager(componentUpdateManager);
|
||||||
engine.AssignTimeManager(timeManager);
|
engine.AssignTimeManager(timeManager);
|
||||||
|
|
||||||
engines.Add(engine);
|
engines.Add(engine);
|
||||||
|
@ -130,11 +132,11 @@ namespace Encompass
|
||||||
senders.Add(engine);
|
senders.Add(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var readTypes in engine.readTypes)
|
foreach (var componentType in engine.readTypes.Union(engine.writeTypes))
|
||||||
{
|
{
|
||||||
if (!registeredComponentTypes.Contains(readTypes))
|
if (!registeredComponentTypes.Contains(componentType))
|
||||||
{
|
{
|
||||||
RegisterComponent(readTypes);
|
RegisterComponent(componentType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,13 +337,13 @@ namespace Encompass
|
||||||
entityManager,
|
entityManager,
|
||||||
componentManager,
|
componentManager,
|
||||||
messageManager,
|
messageManager,
|
||||||
componentMessageManager,
|
componentUpdateManager,
|
||||||
timeManager,
|
timeManager,
|
||||||
renderManager
|
renderManager
|
||||||
);
|
);
|
||||||
|
|
||||||
|
componentUpdateManager.SetStartingComponentStore(startingComponentStoreForComponentUpdateManager);
|
||||||
componentManager.SetComponentStore(startingComponentStoreForComponentManager);
|
componentManager.SetComponentStore(startingComponentStoreForComponentManager);
|
||||||
componentMessageManager.SetStartingComponentStore(startingComponentStoreForComponentMessageManager);
|
|
||||||
|
|
||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
using System.ComponentModel;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
|
||||||
using Encompass;
|
using Encompass;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using Encompass.Exceptions;
|
|
||||||
|
|
||||||
namespace Tests
|
namespace Tests
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue