Browse Source

- Add Dispatcher without extra parameters

tags/Rel1
sebas77 8 years ago
parent
commit
bf5678569a
2 changed files with 25 additions and 8 deletions
  1. +20
    -0
      ECS/Dispatcher/Dispatcher.cs
  2. +5
    -8
      ECS/EnginesRoot.cs

+ 20
- 0
ECS/Dispatcher/Dispatcher.cs View File

@@ -17,3 +17,23 @@ public class Dispatcher<S, T>

readonly S _sender;
}

public class Dispatcher<S>
{
public event System.Action<S> subscribers;

private Dispatcher() { }

public Dispatcher(S sender)
{
_sender = sender;
}

public void Dispatch()
{
if (subscribers != null)
subscribers(_sender);
}

readonly S _sender;
}

+ 5
- 8
ECS/EnginesRoot.cs View File

@@ -8,9 +8,6 @@ namespace Svelto.ES
{
public sealed class EnginesRoot: IEnginesRoot, IEndOfFrameTickable, IEntityFactory
{
const int _INITIAL_SIZE = 100;
const int _INITIAL_INTERNAL_SIZE = 10;

public EnginesRoot(ITicker ticker)
{
ticker.Add(this);
@@ -19,10 +16,10 @@ namespace Svelto.ES
_engineRootWeakReference = new WeakReference<EnginesRoot>(this);
_otherEnginesReferences = new FasterList<IEngine>();
_nodesDB = new Dictionary<Type, FasterList<INode>>(_INITIAL_SIZE);
_nodesDBdic = new Dictionary<Type, Dictionary<int, INode>>(_INITIAL_SIZE);
_nodesDB = new Dictionary<Type, FasterList<INode>>();
_nodesDBdic = new Dictionary<Type, Dictionary<int, INode>>();

_nodesToAdd = new Queue<INode>(_INITIAL_SIZE);
_nodesToAdd = new Queue<INode>();
}

public void EndOfFrameTick(float deltaSec)
@@ -107,7 +104,7 @@ namespace Svelto.ES
{
FasterList<INode> nodes;
if (_nodesDB.TryGetValue(nodeType, out nodes) == false)
nodes = _nodesDB[nodeType] = new FasterList<INode>(_INITIAL_INTERNAL_SIZE);
nodes = _nodesDB[nodeType] = new FasterList<INode>();

nodes.Add(node);

@@ -115,7 +112,7 @@ namespace Svelto.ES
{
Dictionary<int, INode> nodesDic;
if (_nodesDBdic.TryGetValue(nodeType, out nodesDic) == false)
nodesDic = _nodesDBdic[nodeType] = new Dictionary<int, INode>(_INITIAL_INTERNAL_SIZE);
nodesDic = _nodesDBdic[nodeType] = new Dictionary<int, INode>();
nodesDic[(node as NodeWithID).ID] = node;
}


Loading…
Cancel
Save