@pspeed:
I also thought that I not very clear about Entity System.
Also I really dont know how to escape from the idea of Entity System is a bad no, not really good design pattern.
As in the T-Machine post, he did metion the good of Entity System is to devide thing into smaller things to some how have a “Manager” to roll several “type of things” at once time. Yes
In theory, it a really good example of “not classify at all” but tell me in the end what is “type of things”
is it == class???
Now, not talking about how good my life can be with an Entity System, I just put here few things should be pretty damn hard to do with an Entity System in my hand:
Every in-game item has multiple facets, or aspects, that explain what it is and how it interacts with the world. A bicycle, for instance, is:
Made of metal
Can be used by a human
A means of transportation
Something that can be bought and sold
A popular birthday present
Man-made
At this point, please note: OOP does not have this concept of multiple aspects; it hard-codes all the aspects into one glob, and declares that the set of behaviours and values of data to be the single-aspected Class of an Object.
1) How can I find a criteria to divide things into Component.
As in OOP, classify is divide but as T-Machine said, it also link things together, and mixed logic, which acording to the article has a lot of bad effects for a MMORPG game and a real-time game.
But tell me is it always ovibous to divide things? No link at all, really..........
I think he just put "batch processing" in a high priority place, and said it 's the only algorithm for all real time game! Which I can not agree.
2) Components are just data but if your "real" data (models, asset, texture, ...) is bad orginized , and various type, and you have to work to transform "real" data to Components then Entity System is bad!!
3) Let think about how managers in an Entity system doing work in piece of information that a component give them.Because component don't think, they are data. So we must have manager to deal with them.
Eg: manager for Renderable. But there are
- textured model, which link to texture.
- and not textured model, not link to texture
- Also, there is Skybox, which in other bucket... so on
The component has to be separated, because they should know nothing about the other.
Then the manager have to separated too. So we have a lot of managers.
Let think about of a social with many cops, and cops have to know everythings about the people by "how familiar they look and behave".
It's bad because the system has to make all the work be cause it's citizen don't know anything.
Yes, in OOP, Object not really just a paper to display information, but its self a independent things to solve its own problem. So a piece of data and a piece of logic, then other solve the link and the interactive between thems.
=====================================================================================
"Some-how" same thing which "so-call" evolution of J2EE (Spring?), in which a service know everything and handle a lot of "easy to read and plain data" bean.
Now, I think a lot of web developers sometime want their bean to some how know each other behavior, not to route all the information and processing to service and let it take care. Why? Because web != large scale , it can be really small too, involve a lot of technique just for 2 reasons:
absolute 100% decoupling and just have to learn to config your data ( another 100% hard work)
In the end it's not that fasinated idea. Decoupling in 85% may work better and a lot easier to understand and to maintain. but 85% is still in OOP.
@harton : As read throgh the post I think you just start with JME and want to know a good pattern to implement a RPG game. Now I not 100% I can offer you one but I'm working on a framework for JME game (based on the work of other contributors and MonkeyZone) for easy extend to several of game genre (including RPG) .
You can check it here : http://hub.jmonkeyengine.org/groups/free-announcements/forum/topic/rpg-game-making-tutorials-series-by-atomix/
As in the Atom framework, there are several kind of State and they are in different level so dont be coffusion one with the other:
Please remember that the most important idea to divide and application into state is to some-how split it into phrase by the different of action, behavior in that phrase. So the State has to be pretty contrast with another!
An AppState (which is official JME AppState class) combine some actions in Application phrases (Start,Loading,Menu,End) to one unit. So without any knowledge of how the game should be (RPG or FPS ...), an Appliaction should pretty sure have those States.
An GameState (only in Atom) combine Game actions into state, it depend a lot in what gameplay, which game genre of the game. Say : Fighting_GameState, InDialogue_GameState. And it control every action which happen in that state:
Exploring: pathFinding, enemyApproach,
Fighting : there are explosion, particle
InDialogure: cinematic, character facial, ...
In Atom framework, NPC and character has state two if we using FSM (Finite state machine) to simulate character AI. Other technique can be use are Scripting in Groovy and DecisionTree. So for a specific game character, there are some common State and some special States:
RunState, animation="Run", speed ="10"
WalkState, animation="Walk",speed ="5"
IdleState, animation="Idle",speed="0"
DieState, animation="Die",speed="0" -> FSM finished.
As you can see we divide the logic into several level and then in one level, several separated block to easy to write, read and maintain. One more thing is : State is the behavior of the object, an object need to receive a Trigger or an Event from the System to notify in to change or to "think" from step to step.
So let make it short, devide you State in to level, and also make an EventSystem.