Giter Club home page Giter Club logo

mix's Issues

The component type Id's are not consistent throughout different executions

execution 1:
auto e = world.CreateEntity();
e.AddComponent(100, 100); - ID = 0
e.AddComponent(10, 10); - ID = 1

execution 2:
auto e = world.CreateEntity();
e.AddComponent(10, 10); - ID = 0 // different from the last time
e.AddComponent(100, 100); - ID = 1 // different from the last time

This may cause problems if something like serialization of the entities and pools takes place. Though it can be worked around.

You can map the type_index to the runtime generated ones, but the type_index hash function returns a size_t type which is not consistent on 32 bit and 64 bit architectures.
My suggestion is some kind of consistent uint32_t hash on the component's type name but that would require some dependency on a rtti/reflection library. Your call :). Though a really nice library :)

Maybe think of some way to get components through base component type

struct PhysicsBodyComponent
{
// some general data
};
struct RigidBodyComponent : public PhysicsBodyComponent
{
// some specific data
};
struct SoftBodyComponent : public PhysicsBodyComponent
{
// some specific data
};
auto e = world.CreateEntity();
e.AddComponent();

// somewhere else maybe a system's requirements
RequireComponent();
auto& component = e.GetComponent();

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.