Skip to content

Commit 4bc2572

Browse files
committed
Updated readme
Also added some more helpers for DI
1 parent f566be7 commit 4bc2572

File tree

22 files changed

+204
-59
lines changed

22 files changed

+204
-59
lines changed

docs/architecture/entity-collections.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ So taking the above example again, if you were to partition your collections so
1818
1919
## Where do they live?
2020

21-
So there is an `EntityCollectionManager` which acts as the container for all the entity collections
21+
So there is an `EntityDatabase` which acts as the container for all the entity collections

docs/breaking-changes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Breaking Changes
22

3+
## 3.9.0 -> 3.10.0
4+
5+
- IEntityCollectionManager no longer contains EntityCollections its now within `IEntityDatabase`, which is within there
6+
37
## 3.8.0 -> 3.9.0
48

59
- `IObservableScheduler` is now known as `IUpdateScheduler` and uses an `ElapsedTime` object not `TimeSpan`

docs/framework/blueprints.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ how they wish to implement blueprints, as you can add as much configurable prope
66

77
Here is an example of a blueprint:
88

9-
```
9+
```csharp
1010
public class PlayerBlueprint : IBlueprint
1111
{
1212
public string Name {get;set;}
@@ -27,7 +27,7 @@ public class PlayerBlueprint : IBlueprint
2727
Pools are aware of blueprints and you can create an entity with a blueprint to save you the time of having to create the entity
2828
then manually applying all the components, which would look like:
2929

30-
```
30+
```csharp
3131
var hanSoloEntity = somePool.createEntity(new PlayerBlueprint{
3232
Name = "Han Solo",
3333
Class = "Smuggler",
@@ -40,7 +40,7 @@ You have 2 options of applying blueprints to entities, one would be to just new
4040
`Apply` method passing in the entity, or you could use the available extension methods to apply directly from the entity,
4141
this is also chainable so you are able to apply multiple blueprints to the same entity if you wanted, like so:
4242

43-
```
43+
```csharp
4444
entity.ApplyBlueprint(new DefaultActorBlueprint())
4545
.ApplyBlueprint(new DefaultEquipmentBlueprint())
4646
.ApplyBlueprint(new SetupNetworkingBlueprint());

docs/framework/entities.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@ As mentioned entities are created within collections and you can have many entit
1212

1313
### From `IEntityCollectionManager`
1414

15-
- `myCollectionManager.CreateObservableGroup(myGroup, optionalPoolName)`
15+
- `myCollectionManager.GetObservableGroup(myGroup, idsForCollectionsToCheck)`
1616

1717
This is probably the most common approach, you get your `IEntityCollectionManager` instance (usually injected in to your class) and you call `CreateObservableGroup`, this will create or return an existing observable group for you which internally contains the `Entities` that match the group for you to query on further. This is often a better approach than accessing entities directly. (read more on this in querying/filtration docs)
1818

19-
- `myCollectionManager.GetEntitiesFor(myGroup, optionalPoolName)`
19+
- `myCollectionManager.EntityDatabase.*`
20+
21+
The entity collection manager exposes the entity database which can be queried for more info
22+
23+
### From `IEntityDatabase`
24+
25+
- `entityDatabase.GetEntitiesFor(myGroup, idsForCollectionsToCheck)`
2026

2127
This is not used often but is there for convenience, it allows you to just get back an `IEnumerable<IEntity>` collection which contains all entities which match the group, so it you can query on the matching entities further however you want.
2228

docs/framework/groups.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ There are a few different ways to create a group, here are some of the common wa
1818

1919
There is a `Group` class which implements `IGroup`, this can be instantiated and passed any of the components you want to target, like so:
2020

21-
```c#
21+
```csharp
2222
var group = new Group(typeof(SomeComponent));
2323
```
2424

2525
There are also some helper methods here so you can add component types if needed via extension methods, like so:
2626

27-
```c#
27+
```csharp
2828
var group = new Group()
2929
.WithComponent<SomeComponent>()
3030
.WithoutComponent<SomeOtherComponent();
@@ -36,7 +36,7 @@ This is a halfway house between the builder approach and the instantiation appro
3636

3737
So there is also a `GroupBuilder` class which can simplify making complex groups, it is easy to use and allows you to express complex group setups in a fluent manner, like so:
3838

39-
```c#
39+
```csharp
4040
var group = new GroupBuilder()
4141
.WithComponent<SomeComponent>()
4242
.WithComponent<SomeOtherComponent>()
@@ -49,7 +49,7 @@ So if you are going to be using the same groupings a lot, it would probably make
4949

5050
It is quite simple to make your own group, you just need to implement the 2 getters:
5151

52-
```c#
52+
```csharp
5353
public class MyGroup : IGroup
5454
{
5555
public IEnumerable<Type> RequiredComponents {get;} = return new[] { typeof(SomeComponent), typeof(SomeOtherComponent) };

docs/framework/observable-groups.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ So now you know what entities are and how you can get hold of them, its worth go
55
## Filtration Flow
66

77
```
8-
IEntityCollectionManager <- This contains all collections, which in turn contains ALL entities
8+
IEntityCollectionManager <- This contains the database which contains all collections, which in turn contains ALL entities
99
|
1010
|
1111
IObservableGroup <- This filters all entities down to only ones which are within the group
@@ -15,7 +15,7 @@ IComputedGroup <- This acts as another layer of filtration on an IObse
1515
i.e Top 5 entities with PlayerComponent sorted by Score
1616
```
1717

18-
## IEntityCollectionManager
18+
## IEntityCollectionManager || IEntityDatabase
1919

2020
The entity collection manager is the root most point where all entity queries should originate from.
2121

docs/framework/systems.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This is a niche system for when you want to carry out some logic outside the sco
1616
more fine grained control over how you deal with the entities matched.
1717

1818
Rather than the `SystemExecutor` doing most of the work for you and managing the subscriptions and entity interactions
19-
this just provides you the `GroupAccessor` for the entities targetted and its up to you to control how they are
19+
this just provides you the `GroupAccessor` for the entities targeted and its up to you to control how they are
2020
dealt with.
2121

2222
The `StartSystem` method will be triggered when the system has been added to the executor, and the `StopSystem`
@@ -30,4 +30,4 @@ So by default (with the default implementation of `ISystemExecutor`) systems wil
3030
2. Implementations of `IReactToEntitySystem`
3131
3. Other Systems
3232

33-
However within those groupings it will load the systems in whatever order Zenject (assuming you are using it) provides them, however there is a way to enforce some level of priority by applying the `[Priority(1)]` attribute, this allows you to specify the priority of how systems should be loaded. The ordering will be from lowest to highest so if you have a priority of 1 it will load before a system with a priority of 10.
33+
However within those groupings it will load the systems in whatever order Zenject/Extenject (assuming you are using it) provides them, however there is a way to enforce some level of priority by applying the `[Priority(1)]` attribute, this allows you to specify the priority of how systems should be loaded. The ordering will be from lowest to highest so if you have a priority of 1 it will load before a system with a priority of 10.

docs/infrastructure/dependency-injection-abstraction.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ If you want to configure how a binding should work, you can pass into the `Bind`
3333
### AsSingleton: `bool`
3434

3535
Setting this to `true` will mean that only one instance of this binding should exist, so if you were to do:
36-
```c#
36+
```csharp
3737
Bind<IEventSystem, EventSystem>(new BindingConfiguration{AsSingleton = true});
3838
```
3939
Then resolve `IEventSystem` in multiple places you will always get back the same instance, which is extremely handy for infrastructure style objects which should act as singletons. If you provide `false` as the value it will return a new instance for every resolve request.
@@ -46,7 +46,7 @@ This will allow you to give the binding a name for resolving via name.
4646

4747
This allows you to bind to an actual instance of an object rather than a type, which is useful if you need to manually setup something yourself.
4848

49-
```c#
49+
```csharp
5050
var someInstance = new Something(foo, bar);
5151
Bind<ISomething>(new BindingConfiguration{ToInstance = someInstance});
5252
```
@@ -55,7 +55,7 @@ Bind<ISomething>(new BindingConfiguration{ToInstance = someInstance});
5555

5656
This allows you to lazy bind something to a method rather than an instance/type, which is useful if you want to setup something in a custom way once all DI configuration has been processed.
5757

58-
```c#
58+
```csharp
5959
var bindingConfiguration = new BindingConfiguration({
6060
ToMethod: container =>
6161
{
@@ -85,7 +85,7 @@ The configuration object is simple but can be unsightly for larger configuration
8585

8686
There is a builder pattern helper which lets you setup your binding config via a builder rather than an instance of `BindingConfiguration`, this can be used by just creating a lambda within the bind method like so:
8787

88-
```c#
88+
```csharp
8989
Bind<ISomething>(config => config
9090
.AsSingleton()
9191
.WithName("something-1")
@@ -95,7 +95,7 @@ Bind<ISomething>(config => config
9595

9696
This lets you setup the configuration in a nice way, it also has type safety so you can setup instances and methods using it like so:
9797

98-
```c#
98+
```csharp
9999
// With instance
100100
Bind<ISomething>(config => config
101101
.ToInstance(new InstanceOfISomething())
@@ -120,7 +120,7 @@ Bind<ISomething>(config => config
120120

121121
There is also another helper which allows you to get an `IObservableGroup` directly from the container, this internally gets the instance of the `IEntityCollectionManager` and requests an observable group of a given type like so:
122122

123-
```c#
123+
```csharp
124124
// By group
125125
var observableGroup = container.ResolveObservableGroup(new MyGroup());
126126
// By required components

docs/introduction/setup.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,18 @@ public abstract class EcsRxApplication
6767
// For creating entities, collections, observable groups and managing Ids
6868
var entityFactory = new DefaultEntityFactory(new IdPool(), componentRepository);
6969
var entityCollectionFactory = new DefaultEntityCollectionFactory(entityFactory);
70+
var entityDatabase = new EntityDatabase(entityFactory);
7071
var observableGroupFactory = new DefaultObservableObservableGroupFactory();
71-
EntityCollectionManager = new EntityCollectionManager(entityCollectionFactory, observableGroupFactory, componentLookup);
72+
EntityCollectionManager = new EntityCollectionManager(observableGroupFactory, entityDatabase, componentLookup);
7273

7374
// All system handlers for the system types you want to support
7475
var manualSystemHandler = new ManualSystemHandler(EntityCollectionManager);
76+
var basicSystemHandler = new BasicSystemHandler(EntityCollectionManager);
7577

7678
var conventionalSystems = new List<IConventionalSystemHandler>
7779
{
78-
manualSystemHandler
80+
manualSystemHandler,
81+
basicSystemHandler
7982
};
8083

8184
// The main executor which manages how systems are given information

docs/performance/component-type-lookups.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ So if you are happy to provide a type index/id with your call it will bypass the
88

99
So this change means **YOU** have to tell EcsRx ahead of time what indexes/ids to use for your components and provide that data to the rest of your codebase, its easiest to do this by making a class with static int properties like so:
1010

11-
```c#
11+
```csharp
1212
public static class ComponentLookupTypes
1313
{
1414
public static int NameComponentId = 0;
@@ -19,7 +19,7 @@ public static class ComponentLookupTypes
1919

2020
Then you can just reference these types anywhere which satisfies the telling of the entity the index, and you then just need to make sure when the application is created it uses these explicit lookups rather than auto generating them, generally done by making your own module and loading it like so:
2121

22-
```c#
22+
```csharp
2323
public class CustomComponentLookupsModule : IDependencyModule
2424
{
2525
public void Setup(IDependencyContainer container)

0 commit comments

Comments
 (0)