Permalink
Browse files

Fixing typo

  • Loading branch information...
1 parent 2b89ac3 commit 172a6d2a7cd1517f0b365a79da854ead4c5e443c @thelinuxlich thelinuxlich committed Apr 26, 2012
@@ -5,9 +5,9 @@
namespace Artemis
{
- public abstract class HybridQueueSystemProcessing : EntityProcessingSystem
+ public abstract class HybridQueueProcessingSystem : EntityProcessingSystem
{
- public HybridQueueSystemProcessing(Type requiredType, params Type[] otherTypes)
+ public HybridQueueProcessingSystem(Type requiredType, params Type[] otherTypes)
: base(requiredType, otherTypes)
{
foreach (var item in GetMergedTypes(requiredType, otherTypes))
@@ -5,9 +5,9 @@
namespace Artemis
{
- public class QueueSystemProcessing : EntitySystem
+ public class QueueProcessingSystem : EntitySystem
{
- public QueueSystemProcessing()
+ public QueueProcessingSystem()
: base()
{
}
@@ -11,12 +11,12 @@ class QueueManager
{
public QueueManager()
{
- this.AquireLock();
+ this.AcquireLock();
refCount++;
this.ReleaseLock();
}
- public void AquireLock()
+ public void AcquireLock()
{
Monitor.Enter(lockobj);
}
@@ -32,9 +32,9 @@ public void ReleaseLock()
public static int EntitiesToProcessEachFrame = 50;
}
- public abstract class QueueSystemProcessingThreadSafe : EntitySystem
+ public abstract class QueueProcessingSystemThreadSafe : EntitySystem
{
- public QueueSystemProcessingThreadSafe()
+ public QueueProcessingSystemThreadSafe()
: base()
{
Id = this.GetType();
@@ -50,10 +50,10 @@ public QueueSystemProcessingThreadSafe()
}
}
- ~QueueSystemProcessingThreadSafe()
+ ~QueueProcessingSystemThreadSafe()
{
QueueManager QueueManager = queuesManager[Id];
- QueueManager.AquireLock();
+ QueueManager.AcquireLock();
QueueManager.refCount--;
if (QueueManager.refCount == 0)
queuesManager.Remove(Id);
@@ -68,7 +68,7 @@ public static void SetQueueProcessingLimit(int limit, Type EntitySystemType)
{
QueueManager QueueManager = queuesManager[EntitySystemType];
- QueueManager.AquireLock();
+ QueueManager.AcquireLock();
QueueManager.EntitiesToProcessEachFrame = limit;
QueueManager.ReleaseLock();
@@ -77,7 +77,7 @@ public static void SetQueueProcessingLimit(int limit, Type EntitySystemType)
public static int GetQueueProcessingLimit(Type EntitySystemType)
{
QueueManager QueueManager = queuesManager[EntitySystemType];
- QueueManager.AquireLock();
+ QueueManager.AcquireLock();
int val = QueueManager.EntitiesToProcessEachFrame;
QueueManager.ReleaseLock();
return val;
@@ -87,7 +87,7 @@ public static int GetQueueProcessingLimit(Type EntitySystemType)
public static void AddToQueue(Entity ent, Type EntitySystemType)
{
QueueManager QueueManager = queuesManager[EntitySystemType];
- QueueManager.AquireLock();
+ QueueManager.AcquireLock();
QueueManager.queue.Enqueue(ent);
QueueManager.ReleaseLock();
}
@@ -105,7 +105,7 @@ public static int QueueCount(Type EntitySystemType)
private static Entity DeQueue(Type EntitySystemType)
{
QueueManager QueueManager = queuesManager[EntitySystemType];
- QueueManager.AquireLock();
+ QueueManager.AcquireLock();
Entity e = QueueManager.queue.Dequeue();
QueueManager.ReleaseLock();
return e;
@@ -119,7 +119,7 @@ public override void Process()
{
Entity[] entities;
QueueManager QueueManager = queuesManager[Id];
- QueueManager.AquireLock();
+ QueueManager.AcquireLock();
{
int count = QueueManager.queue.Count;
if (count > QueueManager.EntitiesToProcessEachFrame)
@@ -7,7 +7,7 @@
namespace ArtemisTest
{
- public class HybridQueueSystemTest : Artemis.HybridQueueSystemProcessing
+ public class HybridQueueSystemTest : Artemis.HybridQueueProcessingSystem
{
public HybridQueueSystemTest()
: base(typeof(Health))
@@ -32,9 +32,9 @@ public void ReleaseLock()
public int EntitiesToProcessEachFrame = 50;
}
- public abstract class QueueSystemProcessingThreadSafe : EntitySystem
+ public abstract class QueueProcessingSystemThreadSafe : EntitySystem
{
- public QueueSystemProcessingThreadSafe()
+ public QueueProcessingSystemThreadSafe()
: base()
{
Id = this.GetType();
@@ -50,7 +50,7 @@ public QueueSystemProcessingThreadSafe()
}
}
- ~QueueSystemProcessingThreadSafe()
+ ~QueueProcessingSystemThreadSafe()
{
QueueManager QueueManager = queuesManager[Id];
QueueManager.AcquireLock();
@@ -7,7 +7,7 @@
namespace ArtemisTest
{
- public class QueueSystemTest : Artemis.QueueSystemProcessingThreadSafe
+ public class QueueSystemTest : Artemis.QueueProcessingSystemThreadSafe
{
public QueueSystemTest() : base()
{
@@ -7,7 +7,7 @@
namespace ArtemisTest
{
- public class QueueSystemTest2 : Artemis.QueueSystemProcessingThreadSafe
+ public class QueueSystemTest2 : Artemis.QueueProcessingSystemThreadSafe
{
public QueueSystemTest2() : base(){}
public override void Process(Entity Entity)
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Artemis
+{
+ public abstract class HybridQueueProcessingSystem : EntityProcessingSystem
+ {
+ public HybridQueueProcessingSystem(Type requiredType, params Type[] otherTypes)
+ : base(requiredType, otherTypes)
+ {
+ foreach (var item in GetMergedTypes(requiredType, otherTypes))
+ {
+ compTypes.Add(ComponentTypeManager.GetTypeFor(item));
+ }
+ }
+ List<ComponentType> compTypes = new List<ComponentType>();
+ public int EntitiesToProcessEachFrame = 50;
+ Queue<Entity> queue = new Queue<Entity>();
+
+ public void AddToQueue(Entity ent)
+ {
+ foreach (var item in compTypes)
+ {
+ if (ent.GetComponent(item) == null)
+ {
+ throw new Exception("You need to have the " + item + " Component to be able to use this queue" );
+ }
+ }
+ queue.Enqueue(ent);
+ }
+
+ public int QueueCount
+ {
+ get
+ {
+ return queue.Count;
+ }
+ }
+
+ protected override void ProcessEntities(Dictionary<int, Entity> entities)
+ {
+ if (!enabled)
+ return;
+
+ int size = queue.Count > EntitiesToProcessEachFrame ? EntitiesToProcessEachFrame : queue.Count;
+ for (int i = 0; i < size; i++)
+ {
+ Process(queue.Dequeue());
+ }
+ base.ProcessEntities(entities);
+ }
+
+ }
+}
@@ -0,0 +1,72 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Artemis
+{
+ public class QueueProcessingSystem : EntitySystem
+ {
+ public QueueProcessingSystem()
+ : base()
+ {
+ }
+
+ public int EntitiesToProcessEachFrame = 50;
+ Queue<Entity> queue = new Queue<Entity>();
+
+ public void AddToQueue(Entity ent)
+ {
+ queue.Enqueue(ent);
+ }
+
+ public int QueueCount
+ {
+ get
+ {
+ return queue.Count;
+ }
+ }
+
+
+ private Entity DeQueue()
+ {
+ if(queue.Count > 0)
+ {
+ return queue.Dequeue();
+ }
+ return null;
+ }
+
+ public virtual void Process(Entity Entity)
+ {
+ }
+
+ public override void Process()
+ {
+ if (!enabled)
+ return;
+ int size = queue.Count > EntitiesToProcessEachFrame ? EntitiesToProcessEachFrame : queue.Count;
+ for (int i = 0; i < size; i++)
+ {
+ Process(queue.Dequeue());
+ }
+ }
+
+ public override void Initialize()
+ {
+ }
+
+ public override void Change(Entity e)
+ {
+ }
+
+ public override void Removed(Entity e)
+ {
+ }
+
+ public override void Added(Entity e)
+ {
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 172a6d2

Please sign in to comment.