Giter Club home page Giter Club logo

Comments (5)

Donaut avatar Donaut commented on May 18, 2024 1

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.

genaray avatar genaray commented on May 18, 2024

Thanks! :) Haven't seen that one. I will take a look at it.

from arch.

genaray avatar genaray commented on May 18, 2024

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.

Donaut avatar Donaut commented on May 18, 2024

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.

genaray avatar genaray commented on May 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.