Computeds
The Computeds within EcsR3 build on top of the ones provided within SystemsR3 and provide higher level conventions that align with the ECS paradigms.
If you haven't already, check out the SystemsR3 Computeds Docs first, which covers the high level blurb about what
Computedsare and the basicComputedtypes/conventions available.
IComputedGroup
IComputedGroupThis is more a convention than an actual Computed type, it just indicates that the Computed implements an IGroup accessor so you know the Computed is constrained by a group.
IComputedEntityGroup
IComputedEntityGroupThe IComputedEntityGroup builds on top of IComputedCollection and computes all Entities within a given Group.
It also exposes observables to represent when an Entity has been added or removed from the underlying computed group.
These are used heavily throughout the framework to maintain resolved groups, such as
Systemswhich will use these to get access to allEntitiesthey should operate on.
You can access these or request your own should you need them via the IComputedEntityGroupRegistry, it will provide you an existing ComputedEntityGroup should you request a Group which has already been setup.
ComputedEntityGroupFromEntityGroup
ComputedEntityGroupFromEntityGroupNow we can all laugh at the name here, but this is basically the same as the previous Computed Entity Group, but it's a virtualized version which allows for further constraining, providing you the underlying IComputedEntityGroup as the DataSource and expecting
For example you may want to take a base
Computed Entity Groupand then restrict it further only returning entities which are for a given faction or low health.
ComputedFromEntityGroup<T>
ComputedFromEntityGroup<T>This provides you with an IComputedEntityGroup as the DataSource then you translate them into whatever you want T to be.
This inherits from the lazy computed line, so it will only refresh its value when you read its
Value(and it has awaiting changes) or you explicitly callForceRefresh.
IComputedComponentGroup
IComputedComponentGroupWhile this is listed as a high level Computed and not a convention, in reality it is a ComputedFromEntityGroup<ReadOnlyMemory<ComponentBatch<...>>> which is a bit of a mouthful, but it provides a really performant way to access components for Entities.
For example if you have a group that requires
ComponentA,ComponentBthen this computed will provideComponentBatch<ComponentA, ComponentB>for each entity, allowing quick lookup and processing, this is whatBatchedSystemsuse under the hood to resolve components.
This inherits from the lazy computed line, so it will only refresh its value when you read its
Value(and it has awaiting changes) or you explicitly callForceRefresh.
ComputedFromComponentGroup<T>
ComputedFromComponentGroup<T>This provides you a IComputedComponentGroup as the DataSource and lets you process it however you want into T.
This inherits from the lazy computed line, so it will only refresh its value when you read its
Value(and it has awaiting changes) or you explicitly callForceRefresh.
Last updated