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