roslynator stuff
parent
5e161e2254
commit
366f9ba03f
|
@ -6,25 +6,25 @@ namespace Encompass
|
||||||
{
|
{
|
||||||
internal class ComponentManager
|
internal class ComponentManager
|
||||||
{
|
{
|
||||||
private DrawLayerManager drawLayerManager;
|
private readonly DrawLayerManager drawLayerManager;
|
||||||
|
|
||||||
private Dictionary<Guid, Type> componentIDToType = new Dictionary<Guid, Type>();
|
private readonly Dictionary<Guid, Type> componentIDToType = new Dictionary<Guid, Type>();
|
||||||
private Dictionary<Guid, IComponent> IDToComponent = new Dictionary<Guid, IComponent>();
|
private readonly Dictionary<Guid, IComponent> IDToComponent = new Dictionary<Guid, IComponent>();
|
||||||
private Dictionary<Guid, List<Guid>> entityIDToComponentIDs = new Dictionary<Guid, List<Guid>>();
|
private readonly Dictionary<Guid, List<Guid>> entityIDToComponentIDs = new Dictionary<Guid, List<Guid>>();
|
||||||
private Dictionary<Guid, Guid> componentIDToEntityID = new Dictionary<Guid, Guid>();
|
private readonly Dictionary<Guid, Guid> componentIDToEntityID = new Dictionary<Guid, Guid>();
|
||||||
|
|
||||||
private Dictionary<Type, List<Guid>> typeToComponentIDs = new Dictionary<Type, List<Guid>>();
|
private readonly Dictionary<Type, List<Guid>> typeToComponentIDs = new Dictionary<Type, List<Guid>>();
|
||||||
|
|
||||||
private List<Guid> activeComponents = new List<Guid>();
|
|
||||||
private List<Guid> inactiveComponents = new List<Guid>();
|
|
||||||
|
|
||||||
private List<Guid> componentsToActivate = new List<Guid>();
|
private readonly List<Guid> activeComponents = new List<Guid>();
|
||||||
private List<Guid> componentsToDeactivate = new List<Guid>();
|
private readonly List<Guid> inactiveComponents = new List<Guid>();
|
||||||
private List<Guid> componentsToRemove = new List<Guid>();
|
|
||||||
|
private readonly List<Guid> componentsToActivate = new List<Guid>();
|
||||||
|
private readonly List<Guid> componentsToDeactivate = new List<Guid>();
|
||||||
|
private readonly List<Guid> componentsToRemove = new List<Guid>();
|
||||||
|
|
||||||
//shared references with EntityManager
|
//shared references with EntityManager
|
||||||
private List<Guid> entitiesWithAddedComponents;
|
private readonly List<Guid> entitiesWithAddedComponents;
|
||||||
private List<Guid> entitiesWithRemovedComponents;
|
private readonly List<Guid> entitiesWithRemovedComponents;
|
||||||
|
|
||||||
public ComponentManager(
|
public ComponentManager(
|
||||||
DrawLayerManager drawLayerManager,
|
DrawLayerManager drawLayerManager,
|
||||||
|
@ -43,7 +43,7 @@ namespace Encompass
|
||||||
|
|
||||||
IDToComponent[componentID] = component;
|
IDToComponent[componentID] = component;
|
||||||
componentIDToType[componentID] = typeof(TComponent);
|
componentIDToType[componentID] = typeof(TComponent);
|
||||||
|
|
||||||
if (!typeToComponentIDs.ContainsKey(typeof(TComponent)))
|
if (!typeToComponentIDs.ContainsKey(typeof(TComponent)))
|
||||||
{
|
{
|
||||||
typeToComponentIDs.Add(typeof(TComponent), new List<Guid>());
|
typeToComponentIDs.Add(typeof(TComponent), new List<Guid>());
|
||||||
|
|
|
@ -6,13 +6,13 @@ namespace Encompass
|
||||||
{
|
{
|
||||||
internal class DrawLayerManager
|
internal class DrawLayerManager
|
||||||
{
|
{
|
||||||
private SortedList<int, int> layerOrder = new SortedList<int, int>();
|
private readonly SortedList<int, int> layerOrder = new SortedList<int, int>();
|
||||||
|
|
||||||
private Dictionary<int, HashSet<Guid>> layerIndexToComponentIDs = new Dictionary<int, HashSet<Guid>>();
|
private readonly Dictionary<int, HashSet<Guid>> layerIndexToComponentIDs = new Dictionary<int, HashSet<Guid>>();
|
||||||
private Dictionary<int, HashSet<GeneralRenderer>> layerIndexToGeneralRenderers = new Dictionary<int, HashSet<GeneralRenderer>>();
|
private readonly Dictionary<int, HashSet<GeneralRenderer>> layerIndexToGeneralRenderers = new Dictionary<int, HashSet<GeneralRenderer>>();
|
||||||
|
|
||||||
|
private readonly Dictionary<Guid, int> componentIDToLayerIndex = new Dictionary<Guid, int>();
|
||||||
|
|
||||||
private Dictionary<Guid, int> componentIDToLayerIndex = new Dictionary<Guid, int>();
|
|
||||||
|
|
||||||
public IEnumerable<int> LayerOrder { get { return layerOrder.Values; } }
|
public IEnumerable<int> LayerOrder { get { return layerOrder.Values; } }
|
||||||
|
|
||||||
public void RegisterGeneralRendererWithLayer(GeneralRenderer renderer, int layer)
|
public void RegisterGeneralRendererWithLayer(GeneralRenderer renderer, int layer)
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Encompass
|
||||||
private ComponentManager componentManager;
|
private ComponentManager componentManager;
|
||||||
private MessageManager messageManager;
|
private MessageManager messageManager;
|
||||||
|
|
||||||
public Engine()
|
protected Engine()
|
||||||
{
|
{
|
||||||
var mutatesAttribute = GetType().GetCustomAttribute<Mutates>(false);
|
var mutatesAttribute = GetType().GetCustomAttribute<Mutates>(false);
|
||||||
if (mutatesAttribute != null)
|
if (mutatesAttribute != null)
|
||||||
|
@ -123,7 +123,7 @@ namespace Encompass
|
||||||
{
|
{
|
||||||
if (readMessageTypes.Contains(typeof(TMessage)))
|
if (readMessageTypes.Contains(typeof(TMessage)))
|
||||||
{
|
{
|
||||||
return messageManager.GetMessagesByType<TMessage>().Count() > 0;
|
return messageManager.GetMessagesByType<TMessage>().Any();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace Encompass
|
||||||
{
|
{
|
||||||
public readonly Guid id;
|
public readonly Guid id;
|
||||||
|
|
||||||
private ComponentManager componentManager;
|
private readonly ComponentManager componentManager;
|
||||||
|
|
||||||
internal Entity(Guid id, ComponentManager componentManager)
|
internal Entity(Guid id, ComponentManager componentManager)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,17 +5,17 @@ namespace Encompass
|
||||||
{
|
{
|
||||||
internal class EntityManager
|
internal class EntityManager
|
||||||
{
|
{
|
||||||
private Dictionary<Guid, Entity> IDToEntity = new Dictionary<Guid, Entity>();
|
private readonly Dictionary<Guid, Entity> IDToEntity = new Dictionary<Guid, Entity>();
|
||||||
|
|
||||||
private List<Guid> entitiesMarkedForDestroy = new List<Guid>();
|
private readonly List<Guid> entitiesMarkedForDestroy = new List<Guid>();
|
||||||
|
|
||||||
private Dictionary<Type, HashSet<IEntityTracker>> componentTypeToEntityTrackers = new Dictionary<Type, HashSet<IEntityTracker>>();
|
private readonly Dictionary<Type, HashSet<IEntityTracker>> componentTypeToEntityTrackers = new Dictionary<Type, HashSet<IEntityTracker>>();
|
||||||
private Dictionary<Guid, HashSet<IEntityTracker>> entityToEntityTrackers = new Dictionary<Guid, HashSet<IEntityTracker>>();
|
private readonly Dictionary<Guid, HashSet<IEntityTracker>> entityToEntityTrackers = new Dictionary<Guid, HashSet<IEntityTracker>>();
|
||||||
|
|
||||||
private List<Guid> entitiesWithAddedComponents;
|
private readonly List<Guid> entitiesWithAddedComponents;
|
||||||
private List<Guid> entitiesWithRemovedComponents;
|
private readonly List<Guid> entitiesWithRemovedComponents;
|
||||||
|
|
||||||
private ComponentManager componentManager;
|
private readonly ComponentManager componentManager;
|
||||||
|
|
||||||
public EntityManager(
|
public EntityManager(
|
||||||
ComponentManager componentManager,
|
ComponentManager componentManager,
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace Encompass
|
||||||
{
|
{
|
||||||
internal class MessageManager
|
internal class MessageManager
|
||||||
{
|
{
|
||||||
private Dictionary<Type, List<IMessage>> messageTypeToMessages = new Dictionary<Type, List<IMessage>>();
|
private readonly Dictionary<Type, List<IMessage>> messageTypeToMessages = new Dictionary<Type, List<IMessage>>();
|
||||||
|
|
||||||
internal void AddMessage<TMessage>(TMessage message) where TMessage : struct, IMessage
|
internal void AddMessage<TMessage>(TMessage message) where TMessage : struct, IMessage
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,14 +3,14 @@ using System.Reflection;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Encompass
|
namespace Encompass
|
||||||
{
|
{
|
||||||
internal class RenderManager
|
internal class RenderManager
|
||||||
{
|
{
|
||||||
private EntityManager entityManager;
|
private readonly EntityManager entityManager;
|
||||||
private ComponentManager componentManager;
|
private readonly ComponentManager componentManager;
|
||||||
private DrawLayerManager drawLayerManager;
|
private readonly DrawLayerManager drawLayerManager;
|
||||||
|
|
||||||
private Dictionary<Type, EntityRenderer> drawComponentTypeToEntityRenderer = new Dictionary<Type, EntityRenderer>();
|
private readonly Dictionary<Type, EntityRenderer> drawComponentTypeToEntityRenderer = new Dictionary<Type, EntityRenderer>();
|
||||||
|
|
||||||
public RenderManager(
|
public RenderManager(
|
||||||
EntityManager entityManager,
|
EntityManager entityManager,
|
||||||
|
|
|
@ -4,11 +4,11 @@ namespace Encompass
|
||||||
{
|
{
|
||||||
public class World
|
public class World
|
||||||
{
|
{
|
||||||
private List<Engine> enginesInOrder;
|
private readonly List<Engine> enginesInOrder;
|
||||||
private EntityManager entityManager;
|
private readonly EntityManager entityManager;
|
||||||
private ComponentManager componentManager;
|
private readonly ComponentManager componentManager;
|
||||||
private MessageManager messageManager;
|
private readonly MessageManager messageManager;
|
||||||
private RenderManager renderManager;
|
private readonly RenderManager renderManager;
|
||||||
|
|
||||||
internal World(
|
internal World(
|
||||||
List<Engine> enginesInOrder,
|
List<Engine> enginesInOrder,
|
||||||
|
|
|
@ -7,17 +7,17 @@ namespace Encompass
|
||||||
{
|
{
|
||||||
public class WorldBuilder
|
public class WorldBuilder
|
||||||
{
|
{
|
||||||
private List<Engine> engines = new List<Engine>();
|
private readonly List<Engine> engines = new List<Engine>();
|
||||||
private DirectedGraph<Engine> engineGraph = new DirectedGraph<Engine>();
|
private readonly DirectedGraph<Engine> engineGraph = new DirectedGraph<Engine>();
|
||||||
|
|
||||||
private ComponentManager componentManager;
|
private readonly ComponentManager componentManager;
|
||||||
private EntityManager entityManager;
|
private readonly EntityManager entityManager;
|
||||||
private MessageManager messageManager;
|
private readonly MessageManager messageManager;
|
||||||
private DrawLayerManager drawLayerManager;
|
private readonly DrawLayerManager drawLayerManager;
|
||||||
private RenderManager renderManager;
|
private readonly RenderManager renderManager;
|
||||||
|
|
||||||
private Dictionary<Type, HashSet<Engine>> messageTypeToEmitters = new Dictionary<Type, HashSet<Engine>>();
|
private readonly Dictionary<Type, HashSet<Engine>> messageTypeToEmitters = new Dictionary<Type, HashSet<Engine>>();
|
||||||
private Dictionary<Type, HashSet<Engine>> messageTypeToReaders = new Dictionary<Type, HashSet<Engine>>();
|
private readonly Dictionary<Type, HashSet<Engine>> messageTypeToReaders = new Dictionary<Type, HashSet<Engine>>();
|
||||||
|
|
||||||
public WorldBuilder()
|
public WorldBuilder()
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace Encompass
|
||||||
{
|
{
|
||||||
public bool Equals(IEnumerable<T> x, IEnumerable<T> y)
|
public bool Equals(IEnumerable<T> x, IEnumerable<T> y)
|
||||||
{
|
{
|
||||||
return Enumerable.SequenceEqual(x, y);
|
return x.SequenceEqual(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetHashCode(IEnumerable<T> obj)
|
public int GetHashCode(IEnumerable<T> obj)
|
||||||
|
@ -132,7 +132,7 @@ namespace Encompass
|
||||||
void dfsHelper(T v)
|
void dfsHelper(T v)
|
||||||
{
|
{
|
||||||
discovered.Add(v);
|
discovered.Add(v);
|
||||||
time += 1;
|
time++;
|
||||||
output[v].Add(SearchSymbol.start, time);
|
output[v].Add(SearchSymbol.start, time);
|
||||||
|
|
||||||
foreach (var neighbor in Neighbors(v))
|
foreach (var neighbor in Neighbors(v))
|
||||||
|
@ -143,9 +143,9 @@ namespace Encompass
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
time += 1;
|
time++;
|
||||||
output[v].Add(SearchSymbol.finish, time);
|
output[v].Add(SearchSymbol.finish, time);
|
||||||
};
|
}
|
||||||
|
|
||||||
foreach (var vertex in Vertices)
|
foreach (var vertex in Vertices)
|
||||||
{
|
{
|
||||||
|
@ -197,7 +197,7 @@ namespace Encompass
|
||||||
var v = queue.Peek();
|
var v = queue.Peek();
|
||||||
if (!preorder.ContainsKey(v))
|
if (!preorder.ContainsKey(v))
|
||||||
{
|
{
|
||||||
preorderCounter += 1;
|
preorderCounter++;
|
||||||
preorder[v] = preorderCounter;
|
preorder[v] = preorderCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,8 +234,10 @@ namespace Encompass
|
||||||
if (lowlink[v] == preorder[v])
|
if (lowlink[v] == preorder[v])
|
||||||
{
|
{
|
||||||
sccFound[v] = true;
|
sccFound[v] = true;
|
||||||
var scc = new List<T>();
|
var scc = new List<T>
|
||||||
scc.Add(v);
|
{
|
||||||
|
v
|
||||||
|
};
|
||||||
while (sccQueue.Count > 0 && preorder[sccQueue.Peek()] > preorder[v])
|
while (sccQueue.Count > 0 && preorder[sccQueue.Peek()] > preorder[v])
|
||||||
{
|
{
|
||||||
var k = sccQueue.Pop();
|
var k = sccQueue.Pop();
|
||||||
|
@ -282,7 +284,7 @@ namespace Encompass
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
List<List<T>> result = new List<List<T>>();
|
List<List<T>> result = new List<List<T>>();
|
||||||
var subGraph = Clone();
|
var subGraph = Clone();
|
||||||
|
@ -299,8 +301,10 @@ namespace Encompass
|
||||||
var startNode = scc.Pop();
|
var startNode = scc.Pop();
|
||||||
var path = new Stack<T>();
|
var path = new Stack<T>();
|
||||||
path.Push(startNode);
|
path.Push(startNode);
|
||||||
var blocked = new HashSet<T>();
|
var blocked = new HashSet<T>
|
||||||
blocked.Add(startNode);
|
{
|
||||||
|
startNode
|
||||||
|
};
|
||||||
var closed = new HashSet<T>();
|
var closed = new HashSet<T>();
|
||||||
var B = new Dictionary<T, HashSet<T>>();
|
var B = new Dictionary<T, HashSet<T>>();
|
||||||
var stack = new Stack<Tuple<T, Stack<T>>>();
|
var stack = new Stack<Tuple<T, Stack<T>>>();
|
||||||
|
|
|
@ -7,14 +7,14 @@ namespace Encompass
|
||||||
public abstract class EntityRenderer : Renderer, IEntityTracker
|
public abstract class EntityRenderer : Renderer, IEntityTracker
|
||||||
{
|
{
|
||||||
private readonly List<Type> componentTypes = new List<Type>();
|
private readonly List<Type> componentTypes = new List<Type>();
|
||||||
private EntityTracker entityTracker = new EntityTracker();
|
private readonly EntityTracker entityTracker = new EntityTracker();
|
||||||
|
|
||||||
public IEnumerable<Type> ComponentTypes { get { return componentTypes; } }
|
public IEnumerable<Type> ComponentTypes { get { return componentTypes; } }
|
||||||
public Type DrawComponentType { get; }
|
public Type DrawComponentType { get; }
|
||||||
|
|
||||||
public abstract void Render(Entity entity);
|
public abstract void Render(Entity entity);
|
||||||
|
|
||||||
public EntityRenderer()
|
protected EntityRenderer()
|
||||||
{
|
{
|
||||||
var rendersAttribute = GetType().GetCustomAttribute<Renders>(false);
|
var rendersAttribute = GetType().GetCustomAttribute<Renders>(false);
|
||||||
if (rendersAttribute != null)
|
if (rendersAttribute != null)
|
||||||
|
@ -47,8 +47,8 @@ namespace Encompass
|
||||||
|
|
||||||
private bool CheckEntity(Entity entity)
|
private bool CheckEntity(Entity entity)
|
||||||
{
|
{
|
||||||
return EntityChecker.CheckEntity(entity, componentTypes) &&
|
return EntityChecker.CheckEntity(entity, componentTypes)
|
||||||
entity.HasComponent(DrawComponentType);
|
&& entity.HasComponent(DrawComponentType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@ namespace Encompass
|
||||||
{
|
{
|
||||||
internal class EntityTracker
|
internal class EntityTracker
|
||||||
{
|
{
|
||||||
private HashSet<Guid> trackedEntityIDs = new HashSet<Guid>();
|
private readonly HashSet<Guid> trackedEntityIDs = new HashSet<Guid>();
|
||||||
private HashSet<Guid> deactivatedEntityIDs = new HashSet<Guid>();
|
private readonly HashSet<Guid> deactivatedEntityIDs = new HashSet<Guid>();
|
||||||
|
|
||||||
public IEnumerable<Guid> TrackedEntityIDs
|
public IEnumerable<Guid> TrackedEntityIDs
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue