arvidsson / mix Goto Github PK
View Code? Open in Web Editor NEWC++ minimal entity-component system single header library
License: MIT License
C++ minimal entity-component system single header library
License: MIT License
To something less generic than "entity"
Thus we don't really need to expose World to the System
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 :)
I'm thinking of making the library single-header for ease of use in projects, similar to how https://github.com/vurtun/nuklear does it.
Any thoughts?
i.e. no assertions but rather return invalid entities
Currently an entity is added/removed to/from a system only when it is created/destroyed. It should also be added/removed when a component matching the requirements is added/removed to the entity(maybe at a later point of the entity's existance).
With inspiration from https://github.com/libgdx/ashley
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();
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.