Comments (5)
Hello, I have good news :). The idea works like a charm. Below is a sample code of how it looks.
var world = new World();
// Approach 1: Builders
var builder = new ArcheTypeInfo.Builder();
builder.AddComponent<int>();
builder.AddComponent<ulong>();
var archeTypeInfo = builder.Build(); // We want to avoid creating new ArcheTypes every time so we need a way to locate already existing ArcheTypes. ArcheTypeInfo is a struct that is used as a dictionary key for locating already existing ArcheTypes.
var entity = world.CreateEntity(archeTypeInfo);
// Approach 2: Generic methods that use the builder internally.
// world.CreateEntity<T0..T9>(in T0..T9) If we dont want to use the builder approach. It's a little bit slower than the builder approach.
// Set method with multiple generics so we can quickly assign data for each component type.
entity.Set<T0..T9>(in T0..T9);
from arch.
Thanks! :) Haven't seen that one. I will take a look at it.
from arch.
Thats great! :)
Just some questions:
- do you have a working version somewhere?
- Can the builder be made a struct?
- Is it still compatible with 'Type's? E.g. getting a ComponentType by Type
However i think the .create call with generics should stay aswell since thats a nice api for quick prototyping, it also sets the values in the same step which is also quite nice :)
from arch.
Currently, I don't have a fully working sample. There is no concept of ComponenTypes. A Type is just converted into an index, which is then used to place them inside an array. The more components there is the bigger the array.
from arch.
There is no concept of ComponenTypes
Well this is a problem, i think such an approach does not exclude the concept of componenttypes however. ComponentTypes are pretty important for the underlying chunks and store meta data such as byte size and in the future if the component is managed or not ^^ But if a type can be converted to an index, it can also be converted to the componenttype with that approach i guess.
from arch.
Related Issues (20)
- Unity support HOT 13
- Integrate preprocessor into event call methods for better code readability
- Entity relations
- Duplicated results in query HOT 16
- `Debug.Assert` for operations on entities and dead entities. HOT 2
- Refactor `World.Add<T>` and `Archetype` to capsulate Edge creation
- Bug: World destruction leads to invalid indexing HOT 4
- Recommended way to query specific entities? HOT 3
- [bug] Creating Worlds in parallel can result in worlds with duplicate Ids HOT 3
- Outsource features to `Arch.Extended`
- Replace Dictionary EntityInfo with a simple array. HOT 8
- Non-github contact details/discussion area? HOT 3
- Possible reference issue? HOT 5
- macOS arm64 support HOT 3
- `WithNone<Component>()` doesn't remove those entities from the query HOT 5
- Add `World.Create(object[])` HOT 2
- How can I make a sorted query ? HOT 2
- Entity creation and add of components while iterating a query HOT 14
- Add instance receivers for `EventBus`
- New QueryDescription magically erases entities of unrelated types HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arch.