diff --git a/Entitas/Entitas.csproj b/Entitas/Entitas.csproj index eedf0cf6c..3dd3f1fdc 100644 --- a/Entitas/Entitas.csproj +++ b/Entitas/Entitas.csproj @@ -39,7 +39,7 @@ - + diff --git a/Entitas/Entitas/EntityCollector.cs b/Entitas/Entitas/Collector.cs similarity index 82% rename from Entitas/Entitas/EntityCollector.cs rename to Entitas/Entitas/Collector.cs index c6c8950cf..0e46dee7b 100644 --- a/Entitas/Entitas/EntityCollector.cs +++ b/Entitas/Entitas/Collector.cs @@ -3,9 +3,9 @@ namespace Entitas { - /// An EntityCollector can observe one or more groups and collects + /// An Collector can observe one or more groups and collects /// changed entities based on the specified eventType. - public class EntityCollector { + public class Collector { /// Returns all collected entities. /// Call collector.ClearCollectedEntities() @@ -21,15 +21,15 @@ public HashSet collectedEntities { string _toStringCache; StringBuilder _toStringBuilder; - /// Creates an EntityCollector and will collect changed entities + /// Creates an Collector and will collect changed entities /// based on the specified eventType. - public EntityCollector(Group group, GroupEventType eventType) + public Collector(Group group, GroupEventType eventType) : this(new [] { group }, new [] { eventType }) { } - /// Creates an EntityCollector and will collect changed entities + /// Creates an Collector and will collect changed entities /// based on the specified eventTypes. - public EntityCollector(Group[] groups, GroupEventType[] eventTypes) { + public Collector(Group[] groups, GroupEventType[] eventTypes) { _groups = groups; _collectedEntities = new HashSet( EntityEqualityComparer.comparer @@ -37,7 +37,7 @@ public EntityCollector(Group[] groups, GroupEventType[] eventTypes) { _eventTypes = eventTypes; if(groups.Length != eventTypes.Length) { - throw new EntityCollectorException( + throw new CollectorException( "Unbalanced count with groups (" + groups.Length + ") and event types (" + eventTypes.Length + ").", "Group and event type count must be equal." @@ -48,8 +48,8 @@ public EntityCollector(Group[] groups, GroupEventType[] eventTypes) { Activate(); } - /// Activates the EntityCollector and will start collecting - /// changed entities. EntityCollectors are activated by default. + /// Activates the Collector and will start collecting + /// changed entities. Collectors are activated by default. public void Activate() { for (int i = 0; i < _groups.Length; i++) { var group = _groups[i]; @@ -69,9 +69,9 @@ public void Activate() { } } - /// Deactivates the EntityCollector. + /// Deactivates the Collector. /// This will also clear all collected entities. - /// EntityCollectors are activated by default. + /// Collectors are activated by default. public void Deactivate() { for (int i = 0; i < _groups.Length; i++) { var group = _groups[i]; @@ -123,13 +123,13 @@ public override string ToString() { return _toStringCache; } - ~EntityCollector () { + ~Collector () { Deactivate(); } } - public class EntityCollectorException : EntitasException { - public EntityCollectorException(string message, string hint) : + public class CollectorException : EntitasException { + public CollectorException(string message, string hint) : base(message, hint) { } } diff --git a/Entitas/Entitas/Extensions/ContextExtension.cs b/Entitas/Entitas/Extensions/ContextExtension.cs index 72ab59d29..7c238982a 100644 --- a/Entitas/Entitas/Extensions/ContextExtension.cs +++ b/Entitas/Entitas/Extensions/ContextExtension.cs @@ -7,9 +7,9 @@ public static Entity[] GetEntities(this Context context, IMatcher matcher) { return context.GetGroup(matcher).GetEntities(); } - /// Creates an EntityCollector. - public static EntityCollector CreateCollector(this Context context, IMatcher matcher, GroupEventType eventType = GroupEventType.OnEntityAdded) { - return new EntityCollector(context.GetGroup(matcher), eventType); + /// Creates an Collector. + public static Collector CreateCollector(this Context context, IMatcher matcher, GroupEventType eventType = GroupEventType.OnEntityAdded) { + return new Collector(context.GetGroup(matcher), eventType); } /// Creates a new entity and adds copies of all diff --git a/Entitas/Entitas/Extensions/GroupExtension.cs b/Entitas/Entitas/Extensions/GroupExtension.cs index 80147747b..b35206bdf 100644 --- a/Entitas/Entitas/Extensions/GroupExtension.cs +++ b/Entitas/Entitas/Extensions/GroupExtension.cs @@ -2,11 +2,11 @@ namespace Entitas { public static class GroupExtension { - /// Creates an EntityCollector for this group. - public static EntityCollector CreateCollector( + /// Creates an Collector for this group. + public static Collector CreateCollector( this Group group, GroupEventType eventType = GroupEventType.OnEntityAdded) { - return new EntityCollector(group, eventType); + return new Collector(group, eventType); } } } diff --git a/Entitas/Entitas/ReactiveSystem.cs b/Entitas/Entitas/ReactiveSystem.cs index 162fe6814..7b95ebad8 100644 --- a/Entitas/Entitas/ReactiveSystem.cs +++ b/Entitas/Entitas/ReactiveSystem.cs @@ -3,17 +3,17 @@ namespace Entitas { /// A ReactiveSystem calls Execute(entities) if there were changes based on - /// the specified EntityCollector and will only pass in changed entities. + /// the specified Collector and will only pass in changed entities. /// A common use-case is to react to changes, e.g. a change of the position /// of an entity to update the gameObject.transform.position /// of the related gameObject. public abstract class ReactiveSystem : IExecuteSystem { - readonly EntityCollector _collector; + readonly Collector _collector; readonly List _buffer; string _toStringCache; - protected ReactiveSystem(EntityCollector collector) { + protected ReactiveSystem(Collector collector) { _collector = collector; _buffer = new List(); } @@ -24,7 +24,7 @@ protected ReactiveSystem(EntityCollector collector) { public abstract void Execute(List entities); /// Activates the ReactiveSystem and starts observing changes - /// based on the specified EntityCollector. + /// based on the specified Collector. /// ReactiveSystem are activated by default. public void Activate() { _collector.Activate(); diff --git a/PerformanceTests/PerformanceTests.csproj b/PerformanceTests/PerformanceTests.csproj index ec0e711de..45dc0e94a 100644 --- a/PerformanceTests/PerformanceTests.csproj +++ b/PerformanceTests/PerformanceTests.csproj @@ -62,7 +62,7 @@ - + @@ -79,7 +79,7 @@ - + diff --git a/PerformanceTests/PerformanceTests/GroupObserver/EntityCollectorActivate.cs b/PerformanceTests/PerformanceTests/GroupObserver/CollectorActivate.cs similarity index 80% rename from PerformanceTests/PerformanceTests/GroupObserver/EntityCollectorActivate.cs rename to PerformanceTests/PerformanceTests/GroupObserver/CollectorActivate.cs index 7fc86f7ef..b3809be6a 100644 --- a/PerformanceTests/PerformanceTests/GroupObserver/EntityCollectorActivate.cs +++ b/PerformanceTests/PerformanceTests/GroupObserver/CollectorActivate.cs @@ -1,9 +1,9 @@ using Entitas; -public class EntityCollectorActivate : IPerformanceTest { +public class CollectorActivate : IPerformanceTest { const int n = 10000; - EntityCollector _collector; + Collector _collector; public void Before() { var context = Helper.CreateContext(); diff --git a/PerformanceTests/PerformanceTests/GroupObserver/EntityCollectorIterateCollectedEntities.cs b/PerformanceTests/PerformanceTests/GroupObserver/CollectorIterateCollectedEntities.cs similarity index 86% rename from PerformanceTests/PerformanceTests/GroupObserver/EntityCollectorIterateCollectedEntities.cs rename to PerformanceTests/PerformanceTests/GroupObserver/CollectorIterateCollectedEntities.cs index 59b64cd6a..b6d5c71c4 100644 --- a/PerformanceTests/PerformanceTests/GroupObserver/EntityCollectorIterateCollectedEntities.cs +++ b/PerformanceTests/PerformanceTests/GroupObserver/CollectorIterateCollectedEntities.cs @@ -1,9 +1,9 @@ using Entitas; -public class EntityCollectorIterateCollectedEntities : IPerformanceTest { +public class CollectorIterateCollectedEntities : IPerformanceTest { const int n = 100000; - EntityCollector _collector; + Collector _collector; public void Before() { var context = Helper.CreateContext(); diff --git a/PerformanceTests/Program.cs b/PerformanceTests/Program.cs index 5c8201a46..9434733a1 100644 --- a/PerformanceTests/Program.cs +++ b/PerformanceTests/Program.cs @@ -41,8 +41,8 @@ public static void Main(string[] args) { run(); run(); - run(); - run(); + run(); + run(); run(); run(); @@ -93,8 +93,8 @@ public static void Main(string[] args) { //ObjectGetProperty: 6 ms - //EntityCollectorIterateCollectedEntities:957 ms - //EntityCollectorActivate: 1 ms + //CollectorIterateCollectedEntities:957 ms + //CollectorActivate: 1 ms //PropertiesCreate: 251 ms //HashSetContainsAdd: 173 ms diff --git a/Readme/Readme.csproj b/Readme/Readme.csproj index a7cc8c010..96073145e 100644 --- a/Readme/Readme.csproj +++ b/Readme/Readme.csproj @@ -68,8 +68,8 @@ Linked Libraries\Entitas\Group.cs - - Linked Libraries\Entitas\EntityCollector.cs + + Linked Libraries\Entitas\Collector.cs Linked Libraries\Entitas\Context.cs diff --git a/Readme/Readme/ReadmeSnippets.cs b/Readme/Readme/ReadmeSnippets.cs index 99fb35502..ce0ac6766 100644 --- a/Readme/Readme/ReadmeSnippets.cs +++ b/Readme/Readme/ReadmeSnippets.cs @@ -88,7 +88,7 @@ static void groupExample(Context context) { }; } - static void entityCollectorExample(Context context) { + static void collectorExample(Context context) { var group = context.GetGroup(Matcher.Position); var collector = group.CreateCollector(GroupEventType.OnEntityAdded); diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 2fa6530b3..499b54b96 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -45,7 +45,7 @@ - + @@ -103,8 +103,8 @@ Linked Libraries\Entitas\Group.cs - - Linked Libraries\Entitas\EntityCollector.cs + + Linked Libraries\Entitas\Collector.cs Linked Libraries\Entitas\Context.cs diff --git a/Tests/Tests/Entitas/Fixtures/Systems/ReactiveSystemSpy.cs b/Tests/Tests/Entitas/Fixtures/Systems/ReactiveSystemSpy.cs index d990b77ac..16ee8b717 100644 --- a/Tests/Tests/Entitas/Fixtures/Systems/ReactiveSystemSpy.cs +++ b/Tests/Tests/Entitas/Fixtures/Systems/ReactiveSystemSpy.cs @@ -28,10 +28,10 @@ public class ReactiveSystemSpy : ReactiveSystem, IReactiveSystemSpy, IInitialize readonly Func _filter; - public ReactiveSystemSpy(EntityCollector collector) : base(collector) { + public ReactiveSystemSpy(Collector collector) : base(collector) { } - public ReactiveSystemSpy(EntityCollector collector, Func filter) : base(collector) { + public ReactiveSystemSpy(Collector collector, Func filter) : base(collector) { _filter = filter; } diff --git a/Tests/Tests/Entitas/describe_EntityCollector.cs b/Tests/Tests/Entitas/describe_Collector.cs similarity index 93% rename from Tests/Tests/Entitas/describe_EntityCollector.cs rename to Tests/Tests/Entitas/describe_Collector.cs index 6f425266e..bb3f0d9ee 100644 --- a/Tests/Tests/Entitas/describe_EntityCollector.cs +++ b/Tests/Tests/Entitas/describe_Collector.cs @@ -1,14 +1,14 @@ using Entitas; using NSpec; -class describe_EntityCollector : nspec { +class describe_Collector : nspec { Context _context; void when_created() { Group groupA = null; - EntityCollector collectorA = null; + Collector collectorA = null; IMatcher matcherA = Matcher.AllOf(CID.ComponentA); @@ -20,7 +20,7 @@ void when_created() { context["when observing with eventType OnEntityAdded"] = () => { before = () => { - collectorA = new EntityCollector(groupA, GroupEventType.OnEntityAdded); + collectorA = new Collector(groupA, GroupEventType.OnEntityAdded); }; it["is empty when nothing happend"] = () => { @@ -125,7 +125,7 @@ void when_created() { context["when observing with eventType OnEntityRemoved"] = () => { before = () => { - collectorA = new EntityCollector(groupA, GroupEventType.OnEntityRemoved); + collectorA = new Collector(groupA, GroupEventType.OnEntityRemoved); }; it["returns collected entities"] = () => { @@ -142,7 +142,7 @@ void when_created() { context["when observing with eventType OnEntityAddedOrRemoved"] = () => { before = () => { - collectorA = new EntityCollector(groupA, GroupEventType.OnEntityAddedOrRemoved); + collectorA = new Collector(groupA, GroupEventType.OnEntityAddedOrRemoved); }; it["returns collected entities"] = () => { @@ -167,8 +167,8 @@ void when_created() { groupB = _context.GetGroup(Matcher.AllOf(CID.ComponentB)); }; - it["throws when group count != eventType count"] = expect(() => { - collectorA = new EntityCollector( + it["throws when group count != eventType count"] = expect(() => { + collectorA = new Collector( new [] { groupA }, new [] { GroupEventType.OnEntityAdded, @@ -180,7 +180,7 @@ void when_created() { context["when observing with eventType OnEntityAdded"] = () => { before = () => { - collectorA = new EntityCollector( + collectorA = new Collector( new [] { groupA, groupB }, new [] { GroupEventType.OnEntityAdded, @@ -207,7 +207,7 @@ void when_created() { context["when observing with eventType OnEntityRemoved"] = () => { before = () => { - collectorA = new EntityCollector( + collectorA = new Collector( new [] { groupA, groupB }, new [] { GroupEventType.OnEntityRemoved, @@ -232,7 +232,7 @@ void when_created() { context["when observing with eventType OnEntityAddedOrRemoved"] = () => { before = () => { - collectorA = new EntityCollector( + collectorA = new Collector( new [] { groupA, groupB }, new [] { GroupEventType.OnEntityAddedOrRemoved, @@ -261,7 +261,7 @@ void when_created() { context["when observing with mixed eventTypes"] = () => { before = () => { - collectorA = new EntityCollector( + collectorA = new Collector( new [] { groupA, groupB }, new [] { GroupEventType.OnEntityAdded, diff --git a/Tests/Tests/Entitas/describe_EntitasErrorMessages.cs b/Tests/Tests/Entitas/describe_EntitasErrorMessages.cs index d9d53725f..da26c514f 100644 --- a/Tests/Tests/Entitas/describe_EntitasErrorMessages.cs +++ b/Tests/Tests/Entitas/describe_EntitasErrorMessages.cs @@ -103,14 +103,14 @@ void when_throwing() { }); }; - context["EntityCollector"] = () => { + context["Collector"] = () => { it["unbalanced goups"] = () => printErrorMessage(() => { var g1 = new Group(Matcher.AllOf(CID.ComponentA)); var g2 = new Group(Matcher.AllOf(CID.ComponentB)); var e1 = GroupEventType.OnEntityAdded; - new EntityCollector(new [] { g1, g2 }, new [] { e1 }); + new Collector(new [] { g1, g2 }, new [] { e1 }); }); }; diff --git a/Tests/Tests/Entitas/describe_ReactiveSystem.cs b/Tests/Tests/Entitas/describe_ReactiveSystem.cs index 753aa4ec2..0cba087e2 100644 --- a/Tests/Tests/Entitas/describe_ReactiveSystem.cs +++ b/Tests/Tests/Entitas/describe_ReactiveSystem.cs @@ -74,7 +74,7 @@ void when_created() { var e = createEntityAB(); var retainCount = e.retainCount; system.Execute(); - retainCount.should_be(3); // retained by context, group and entity collector + retainCount.should_be(3); // retained by context, group and collector e.retainCount.should_be(2); // retained by context and group }; @@ -223,12 +223,12 @@ void when_created() { GroupEventType.OnEntityAdded, GroupEventType.OnEntityRemoved }; - var entityCollector = new EntityCollector(groups, eventTypes); + var collector = new Collector(groups, eventTypes); - system = new ReactiveSystemSpy(entityCollector); + system = new ReactiveSystemSpy(collector); }; - it["executes when a triggered by entityCollector"] = () => { + it["executes when a triggered by collector"] = () => { var eA1 = context1.CreateEntity().AddComponentA(); context2.CreateEntity().AddComponentA(); @@ -266,7 +266,7 @@ void when_created() { var didExecute = 0; system.executeAction = entities => { didExecute += 1; - eAB2.retainCount.should_be(3); // retained by context, group and entity collector + eAB2.retainCount.should_be(3); // retained by context, group and collector }; system.Execute();