Developing with other COP framework
Dedicated to who want to build ES tools and who what to use them “properly”.
These comments from my experience working with other Game engine which employ COP and ES. It’s not COP fault I have to say. But our (java game dev) fault who notice it too late, so we don’t have any good tools to help developing it at the momment!
[1] Composing tool and Code tool
Unity SDK (UDK and CrySDK… also) have Composing tool to make a world of entites with its engine predefined components.
[2] Code tool
Custom component/ System are made via Boo Script and C++ … for example, and require underlying processing (hot compiling) to make a useable component in real time.
[3] Scripting
Because it’s hard trade off to make COP type-safe as in OOP term. Even more difficult while scripting usually employ duck -typing. The Script almost resulted in run-time errors from time to time.
[4] Debuging: can be consider easy with GUI tool. As value change appear in the GUI; and because of beat nature theorically the game can be start,stop,pause at any momment without interupt in the middle of something. So this provide more than a way (Java way) to debug the game.
[5] Profiling: can be consider easy because of COP nature of arranged data, and ES has regular workload.
[6] AssetMaking: if Input and output are well setup. Assets are all in good format, output are well defined, workflow and routines are fixed. You are good to go! If not, or you have to change your assets to suite the spliting of components, you are doom!
Realworld problems: Split & Asset(Re)Sampling & Re-link
Real Example:
You have 10000 of car, each car with 4 wheels, each will be processed/ served as an entity or a Component of the PhysicSystem.
Approach 1: as Entites [normal approach]
- You have to split your model to 4 separate wheels and body 3d Models.
- Make 5 entities!
- Then link them by ad-hoc script define entites relationship. May be in the System.
- After that copy to ten thousand instance link to a single parent Prefab of 5 entities.-> 50000 entities!
Approach 2: as Components [ugly as hell, but good for script]
- You have to split your model to a separate wheel and body 3d Models.
- Make 1 entity!
- Then has BodyComponent; 2 MeshComponent point to the Wheel, and Body; 1 FourWheelCarPhysicComponent; or 4 WheelCarPhysicComponent
- Then ad-hoc script define Components relationship.
- After that copy to ten thousand instance of a single Prefab of single entity.
In approach 1, System process entites and consider their relationship in meaningful way. Script spread ad-hoc relationship between entities, which will suffer re-link problem later.
In approach 2, System process entites and consider their component relationship in meaningful way. Script spread ad-hoc relationship between components, and terminate pure-data specification. But the script work intuitive per entity, re-link is avoided because the script added in Prefab.
In this example, first you can see the Split and DuplicatedComponent problem because ES naturally denide Component relationships, and the split sometimes unclear.
Asset(Re)Sampling problem happen:
when you change the car to 5 wheels, and have openable windows.
You have to:
- Split the Windows in 3D Model.
- Change your script/ code to re-define the relationships again.
Remember the root reason is your Data (real data) is sampling by your component description, and in addition, no Class concept existed. And this is a strict contract. So it result in 1-1 change per entity!!!
Also notice, the same situation is not strict in OOP world, so may be n-1, 1-n, m-n,… but usually if you change your whole class than your every Car (10000 of them) is good!
In Unity for example, they have Prefab concept to ease out the Class concept. Almost everytime, Prefab can replace Class.
But when the Prefab relationship is lost, eg: add the openable windows to 5000 of instance, not in other 5000 after their position is inplace. Even we can make 2 prefabs for each kind of car, we can not solve the top-down (one direction) relationship between Prefab and instance again at this momment. This called the Re-link problem. So you end up re-do 5000 of cars with a new Prefab. The same frustrations happen in almost non-predefined component.
You can also see a lot of these kind of problems in a database modeler’s everyday life. Modeling, resample, remodeling, imigration can cause frustrations if there is no OOP built-in support!
That all being said, I can only agree that often you still introduce OOP patterns and thus ES errors in the design and logic. Often you have a problem that does seem to be nearly unsolvable with an Es untill you take a short break think about and see a fundamental erro in your component composition/design (Eg storing Spatials/Physicobjects or similar there).
Spatials/Physic objects…So where you save them anyway?
In Unity, they have a Assets singleton where save a serilized version of the objects with a “hash index” to look up them when need, resemble our AssetManager but more Meta-type and directory (tree) fashion. So technically, they not save the object in the Component but just a link to its source!
In fact, not too much people have this mistake because almost every engine have sostiphicated way to manage their assets, their also just save a link.
Enteprise playground: AKKA and Scala
Have some same points with ES but borned in OOP world. AKKA and Scala trying to solve the problem “Java OOP can not be enteprise” in elegent way. [Groovy and GPars as candidate]
-
Trail terminate BLOB anti-patternm but type safe!! .[But not other problem] Read: http://gamedev.stackexchange.com/questions/33062/doesnt-multiple-inheritance-solve-all-problems-that-entity-systems-do
A Tour of Scala: Traits | The Scala Programming Language
Learning Scala part seven - Traits -
Blame Java for not being dynamic, verbose , Scala is dynamic and concise
-
Actor defeat ES in “not just real-time” enviroment
-
Sequence/ cache processing still can be done right!
-
Other than Big table Data solutions
-
RPC framework
-
Let it crash! idiom
-
And all the OOP goods available.
What about AKKA vs other home-grown solution. Yeah… you can see its for Enteprise, like big simmulation with large scale of everything. Its have IDE support, much more type-safe, sercurable, unit test… You get the point. Read more because I don’t into doing free advertisment for AKKA here.
P/s:
@Empire Phoenix: How can I name your ES? do you want to bring it to the comparasion table, now in GoogleDoc but will be posted in public Wiki soon?
@toolforger: Feel free to add your points of concerns to the GoogleDoc table. I see your knowledge of wide range topics will help other a lot… Thank