godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.87k stars 21.02k forks source link

AshelyCPP for game entities #2311

Closed ghost closed 8 years ago

ghost commented 9 years ago

Hey everyone.

While using LibGDX I have played around with a very unique and simple entity framework called Ashley. It makes adding entities to the game much more simple and straightforward. See here https://github.com/libgdx/ashley and here https://github.com/libgdx/ashley/wiki/Framework-overview and here as well https://github.com/libgdx/ashley/wiki/How-to-use-Ashley

I find Ashley fits very well with Godot's modular approach. Ashley makes it easier to add actors and items (objects) to the game.

There is a port of Ashley for C++ here https://github.com/SgtCoDFish/AshleyCPP

Would be nice to add AshleyCPP into Godot. You could add an Ashley class to Godot and make it usable from GDScript. The normal way is to code each unit individually but with Ashley you only code unique properties (called components) and assign those properties to an entity. You could even add an Entity node in the engine that you can tag it with properties you defined. You can also update properties dynamically making all affected entities update as well rather than iterating trough entities. You get much more control and more streamlined code. You can also create entity families like races, factions, classes etc.

I guess I'm thinking this more of a plugin than a core feature.

reduz commented 9 years ago

Doesn''t seem very useful given the way Godot works, but if you feel this can benefit someone feel free to make a module

On Tue, Jul 28, 2015 at 4:17 AM, trollworkout notifications@github.com wrote:

Hey everyone.

While using LibGDX I have played around with a very unique and simple entity framework called Ashley. It makes adding entities to the game much more simple and straightforward. See here https://github.com/libgdx/ashley

I find Ashley fits very well with Godot's modular approach. Ashley makes it easier to add actors and items (objects) to the game.

There is a port of Ashley for C++ here https://github.com/SgtCoDFish/AshleyCPP

Would be nice to add AshleyCPP into Godot and make it much more easy to create things in the game. You could add an Ashley class to Godot and make it usable from GDScript. The normal way is to code each unit individually but with Ashley you only code unique properties and assign those properties to an entity. You could even add an Entity node in the engine that you can tag it with properties you defined.

— Reply to this email directly or view it on GitHub https://github.com/okamstudio/godot/issues/2311.

ghost commented 9 years ago

I'm gonna try to play around with it see if I can make a module or plugin.

robertdhernandez commented 9 years ago

Godot already has an entity component system, so this seems pretty redundant to have.

OvermindDL1 commented 9 years ago

Godot does? I have not seen it, how do you use it to added a new component to a node and how do you make a system to acquire all components of a certain type to operate over them?

reduz commented 9 years ago

I guess you should read the docs or tutorials, I have the feeling you don't quite grasp the way godot works On Aug 2, 2015 8:15 PM, "OvermindDL1" notifications@github.com wrote:

Godot does? I have not seen it, how do you use it to added a new component to a node and how do you make a system to acquire all components of a certain type to operate over them?

— Reply to this email directly or view it on GitHub https://github.com/okamstudio/godot/issues/2311#issuecomment-127082955.

godotengine commented 9 years ago

I guess we should make a godot for unity users tutorial On Aug 2, 2015 10:13 PM, "Juan Linietsky" notifications@github.com wrote:

I guess you should read the docs or tutorials, I have the feeling you don't quite grasp the way godot works On Aug 2, 2015 8:15 PM, "OvermindDL1" notifications@github.com wrote:

Godot does? I have not seen it, how do you use it to added a new component to a node and how do you make a system to acquire all components of a certain type to operate over them?

— Reply to this email directly or view it on GitHub <https://github.com/okamstudio/godot/issues/2311#issuecomment-127082955 .

— Reply to this email directly or view it on GitHub https://github.com/okamstudio/godot/issues/2311#issuecomment-127093964.

OvermindDL1 commented 9 years ago

Never used unity myself, just made a multitude of component entity systems in the past. I am curious as to the design of Godot however since above states it is of that style since as far as I have seen and used it I have thought that it was a normal scenegraph style engine with heavy nodes that do their own processing, not an uncommon style, I am just more preferring a standard entity/component data-driven style with dumb data components and functional Systems that operate over them, but I have not seen that through Godot yet, although I have only seen the scripting side of it as I am assisting a group on one of their projects and not using it for my own work, but if you can point me to a standard data driven entity style system in it then I would be highly curious about it as that was one of my big reservations in recommending Godot to them initially. Thus far I have ended up building a data driven entity system in gdscript for them with dumb data components and externally running systems as it has provided a much needed speed boost for a few of their setups that were rather heavy in node count previously...

OvermindDL1 commented 9 years ago

Looked over the source, not finding anything representing dataflow at all, seems to be a fairly generic class overuse structure, way too much inheritance, nothing dataflow found?

reduz commented 9 years ago

Godot is not entity component. It is not exactly scenegraph either even if it can work as such. It's much more similar to the way Qt works than anything else. You can, however, emulate the entity-component workflow using empty child nodes with scripts. I really dislike that approach because it's too programmer centric, so it will never be implemented in Godot.

On Sun, Aug 2, 2015 at 10:55 PM, OvermindDL1 notifications@github.com wrote:

Never used unity myself, just made a multitude of component entity systems in the past. I am curious as to the design of Godot however since above states it is of that style since as far as I have seen and used it I have thought that it was a normal scenegraph style engine with heavy nodes that do their own processing, not an uncommon style, I am just more preferring a standard entity/component data-driven style with dumb data components and functional Systems that operate over them, but I have not seen that through Godot yet, although I have only seen the scripting side of it as I am assisting a group on one of their projects and not using it for my own work, but if you can point me to a standard data driven entity style system in it then I would be highly curious about it as that was one of my big reservations in recommending Godot to them initially. Thus far I have ended up building a data driven entity system in gdscript for them with dumb data components and externally runn ing systems as it has provided a much needed speed boost for a few of their setups that were rather heavy in node count previously...

— Reply to this email directly or view it on GitHub https://github.com/okamstudio/godot/issues/2311#issuecomment-127097775.

godotengine commented 9 years ago

Nope, you will not find what you are looking for. As said before, Godot is a very visual tool and all the design is focused on presenting a clear view of what scenes do functionally at a glance. The entity/component architecture goes against this. The whole idea of Godot is that programmers contribute, don't design or command.

On Sun, Aug 2, 2015 at 11:14 PM, Juan Linietsky notifications@github.com wrote:

Godot is not entity component. It is not exactly scenegraph either even if it can work as such. It's much more similar to the way Qt works than anything else. You can, however, emulate the entity-component workflow using empty child nodes with scripts. I really dislike that approach because it's too programmer centric, so it will never be implemented in Godot.

On Sun, Aug 2, 2015 at 10:55 PM, OvermindDL1 notifications@github.com wrote:

Never used unity myself, just made a multitude of component entity systems in the past. I am curious as to the design of Godot however since above states it is of that style since as far as I have seen and used it I have thought that it was a normal scenegraph style engine with heavy nodes that do their own processing, not an uncommon style, I am just more preferring a standard entity/component data-driven style with dumb data components and functional Systems that operate over them, but I have not seen that through Godot yet, although I have only seen the scripting side of it as I am assisting a group on one of their projects and not using it for my own work, but if you can point me to a standard data driven entity style system in it then I would be highly curious about it as that was one of my big reservations in recommending Godot to them initially. Thus far I have ended up building a data driven entity system in gdscript for them with dumb data components and externally runn ing systems as it has provided a much needed speed boost for a few of their setups that were rather heavy in node count previously...

— Reply to this email directly or view it on GitHub <https://github.com/okamstudio/godot/issues/2311#issuecomment-127097775 .

— Reply to this email directly or view it on GitHub https://github.com/okamstudio/godot/issues/2311#issuecomment-127099631.

OkamStudio

OvermindDL1 commented 9 years ago

I thought so, that artist centric is why I recommended it to that other group, they picked it up fast, and they can add dummy nodes of mine to other nodes to add functionality I programmed for them so I do rather little work comparatively. I am still curious what KillerJaguar meant by Godot having an entity/component system as I still do not see it. And what is it that reduz meant by my not understanding the archetype as what he described seems to be precisely what I have considered Godot to be, yet he said I am not grasping how it works so I am curious what I am missing as there seems to be contradictory information here:

And I think you all miss the point of a good dataflow system, which is to minimize programming and maximise artist decisions. From what I have heard of Unity it is not such a system but some rather nasty amalgamation that combines the components and systems into one very heavy, very non reusable...thing...

Regardless, as long as it is not a class-splosion (which Godot is admittedly getting very close to, the nodes being individually scriptable is holding off the big issues with this style) then generally it is fine as that style is beyond difficult for the programmers and entirely unusable for artists...

robertdhernandez commented 9 years ago

I misunderstood

kubecz3k commented 9 years ago

Yeah it need to be said loudly and clearly: Unity DON'T use any kind of proper Component/Entity System, it should not be mistaken. Also from my very little experience with Unity I can say it would be a lot easier to implement such system in Godot than in Unity and in fact everyone can do this, so don't see any need to bother main developers :)

Also to clarify what are component entity system here are couple sources: http://t-machine.org/index.php/2007/09/03/entity-systems-are-the-future-of-mmog-development-part-1/ http://entity-systems-wiki.t-machine.org/ Well the first bullet point feature of these system is (quote from one of the sources): No programmer required for designers to modify game logic

OvermindDL1 commented 9 years ago

Indeed, Component/Entity is a subtype of dataflow, meaning a streamed data pipeline, absolutely great for cache, speed, and great dynamic connections that requires no programmer control. The t-machine articles are good but they still miss a little, not enough dataflow focus.

ghost commented 9 years ago

Ashley is one possible solution but there are plenty of other similar libraries that do the same thing. These libraries provide a clean and simple and unified API for entities so you don't have to repeat code or you don't have to repeat entity properties. For example you define Strength, Agility, Speed, Attack Speed etc once for all entities.

Here is a wiki article about the concept of an entity system https://en.wikipedia.org/wiki/Entity_component_system

ghost commented 9 years ago

All i am saying is Godot to provide an ECS out of the box that can be used to create any type of game much more effectively by providing a clean code/game scripting structure so you don't have to think about how to organize code but just start scripting.

reduz commented 9 years ago

Godot will never officially ship with ECS, it uses a different type of architecture which works fine, and you can replicate ECS using empty child nodes if you so much want to.

On Tue, Aug 4, 2015 at 4:04 PM, trollworkout notifications@github.com wrote:

All i am saying is Godot to provide an ECS out of the box that can be used to create any type of game much more effectively by providing a clean code/game scripting structure so you don't have to think about how to organize code but just start scripting.

— Reply to this email directly or view it on GitHub https://github.com/okamstudio/godot/issues/2311#issuecomment-127720665.

ghost commented 9 years ago

thank you reduz. i still want to play around with ashley or perhaps another ecs as a module or plugin see if it can be useful at all.

OvermindDL1 commented 9 years ago

Yeah, like I said above it was not too hard to replicate it in gdscript, though the node count increases message times on my tests, fairly significantly in some cases, that needs some optimizing, but otherwise it works fine, just have your component nodes register and unregister themselves to a global context or so.

kubecz3k commented 9 years ago

@OvermindDL1 I guess the performance would increase a lot if you would create your CES in c++ not gdscript

OvermindDL1 commented 9 years ago

Not my game, I tend to use raw ogl in C++ myself, this is for a few people who are not versed in programming. That does not seem like a gdscript issue though, rather that issue seemed to be inefficiencies in how messages are handled, especially in regards to input it seemed.

kubecz3k commented 9 years ago

@trollworkout I'm curious have you succeeded with bringing Ashley to Godot land?

reduz commented 8 years ago

not going to happen officially, so closing