pointcache / JECSu

Just another ecs for unity
54 stars 6 forks source link

Tested on Unity 5.4.0f3       License MIT

Logo

This was my experiment, its superseeded by URSA https://github.com/pointcache/URSA , which i currently use in http://www.produktgame.com/ as a core. JECSU is half baked and can be used as case study, but its not even remotely production ready.

Just another ECS for Unity

What is ECS and what are the use cases:

ECS stands for Entity-Component-System, they are 3 separate concepts, not like this is a "system" that just has entities and components, instead it is a framework that has

These 3 concepts allow for a very special way to decouple data from implementation, in a way mvc and other oop concepts can't. ECS is one of the most sophisticated architectures in software development finding it's use in many mmos and big games. In ECS all the data is represented as components on entities, where entity is empty object(or even less than that- an ID) that doesnt perform any actions. All inheritance problems with class hierarchy must be solved by Composition. https://en.wikipedia.org/wiki/Composition_over_inheritance This causes fundamental shift in thinking process and simplifies writing manageable code.

When components are data, and entities are compositions of components, systems represent concrete implementation(business logic). Systems may iterate over components, and perform work on them based on their current state, they may query for specific component arrangement, and do pretty much the same you would expect from encapsulated work object.

The real benefit comes when you realize that all the data in the game is represented by a flat list of entities and separate lists of components of the same type, that are static and by themselves don't perform any job, they become alive only when the system modifies them. It's a heart of a data driven approach, where the logic has a bird eye view on a sea of data.

There are many resources you could read about ECS and data driven approach: http://scottbilas.com/files/2002/gdc_san_jose/game_objects_slides.pdf http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/

This particular ECS is being designed with several use cases in mind:

This prototype ECS was made as exercise and attempt to better grasp Entity systems. It uses mixed concepts from various places (like Entitas framework) but has several decisions:

What currently exists and how it works:

concepts:

Concrete classes:

Additional things

License:

Project is released under MIT license Copyright (c) 2016 Alexander Antonov (pointcache) and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.