Mirror of Svelto.ECS because we're a fan of it
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Sebastiano Mandalà 537bbfba74
Set theme jekyll-theme-dinky
2 years ago
.github Update nuget-release.yml 2 years ago
com.sebaslab.svelto.common @ 3e3a02d49f update readme 2 years ago
com.sebaslab.svelto.ecs update readme 2 years ago
.gitignore Svelto.ECS 3.2.3 - fixed bugs and improved code 2 years ago
.gitmodules rename common folder 2 years ago
LICENSE Update LICENSE 4 years ago
Makefile fixed nuget publishing pipeline 2 years ago
README.md Update README.md 2 years ago
Svelto.ECS.sln rename folders to match the other projects 2 years ago
_config.yml Set theme jekyll-theme-dinky 2 years ago

README.md

Svelto.ECS C# Entity Component System framework

Real ECS framework for c#. Enables to write encapsulated, decoupled, maintainable, highly efficient, data oriented, cache friendly, code without pain. Although the framework is platform agnostic (compatible with c# 7 and above and .net standard 2.0 and above), it comes with several Unity extensions.

Svelto.ECS in pills

Svelto.ECS is easy to start with, but full of tricks for expert users. The hardest problem to overcome is usually to shift mentality from OOP programming to ECS programming more than using the framework itself. If you want to read an ECS faq, you can check this article: https://github.com/SanderMertens/ecs-faq

Svelto.ECS at glance:

    public class SimpleContext
    {
        public static ExclusiveGroup group0 = new ExclusiveGroup(); //the group where the entity will be built in

        public SimpleContext()
        {
            var simpleSubmissionEntityViewScheduler = new SimpleEntitiesSubmissionScheduler();
            //Build Svelto Entities and Engines container, called EnginesRoot
            _enginesRoot = new EnginesRoot(simpleSubmissionEntityViewScheduler);

            var entityFactory   = _enginesRoot.GenerateEntityFactory();
            var entityFunctions = _enginesRoot.GenerateEntityFunctions();

            //Add an Engine to the enginesRoot to manage the SimpleEntities
            var behaviourForEntityClassEngine = new BehaviourForEntityClassEngine(entityFunctions);
            _enginesRoot.AddEngine(behaviourForEntityClassEngine);

            //build a new Entity with ID 0 in group0
            entityFactory.BuildEntity<SimpleEntityDescriptor>(new EGID(0, ExclusiveGroups.group0));

            //submit the previously built entities to the Svelto database
            simpleSubmissionEntityViewScheduler.SubmitEntities();

            //as Svelto doesn't provide an engine ticking system, it's the user's responsibility to
            //update engines 
            behaviourForEntityClassEngine.Update();
        }
        
        readonly EnginesRoot _enginesRoot;
   }

your first entity descriptor:

    public struct EntityComponent : IEntityComponent
    {
        public int  counter;
    }

    class SimpleEntityDescriptor : GenericEntityDescriptor<EntityComponent>
    {}

your first engine to apply behaviours to entities:

    public class BehaviourForEntityClassEngine : IQueryingEntitiesEngine
    {
        public BehaviourForEntityClassEngine(IEntityFunctions entityFunctions)
        {
            _entityFunctions = entityFunctions;
        }

        public EntitiesDB entitiesDB { get; set; }

        public void Ready() { }

        public void Update()
        {
            var (components, count) = entitiesDB.QueryEntities<EntityComponent>(ExclusiveGroups.group0);

            for (var i = 0; i < count; i++)
                components[i].counter++;
        }
        
        readonly IEntityFunctions _entityFunctions;
    }

learn more about svelto on the Wiki page: https://github.com/sebas77/Svelto.ECS/wiki

Why using Svelto.ECS with Unity?

Svelto.ECS wasn't born just from the needs of a large team, but also as a result of years of reasoning behind software engineering applied to game development. Svelto.ECS hasn't been written just to develop faster code, it has been designed to help develop better code. Performance gains is just one of the benefits in using Svelto.ECS, as ECS is a great way to write cache-friendly code. Svelto.ECS has been developed with the idea of ECS being a paradigm and not just a pattern, letting the user shift completely away from Object Oriented Programming with consequent improvements of the code design and code maintainability. Svelto.ECS is the result of years of iteration of the ECS paradigm applied to real game development with the intent to be as foolproof as possible. Svelto.ECS has been designed to be used by a medium-size/large team working on long term projects where the cost of maintainability is relevant.

Svelto.ECS is fully compatible with DOTS Burst and Jobs.

Svelto.ECS is compatible with Unity 2019.3.x cycle as long as it's not used with DOTS ECS. Svelto.ECS is also designed to use DOTS ECS as engine library, using the SveltoOnDOTS wrapper. This wrapper is designed to take advantage of DOTS for engine related operations, like rendering, physics and so on. When DOTS ECS integration is necessary, Svelto.ECS will always target the last stable unity version with the most up to date DOTS package.

Why using Svelto.ECS without Unity?

The question is just for fun! There are so many c# game engines out there (Stride, Monogame, FlatRedBall, WaveEngine, UnrealCLR, UniEngine just to mention some) and Svelto.ECS is compatible with all of them!

If you decide to use Svelto.ECS

Svelto.ECS is an Open Source Project provided as it is, no support is guaranteed other than the help given on the Svelto Discord channel. Issues will be fixed when possible. If you decide to adopt Svelto.ECS, it's assumed you are willing to partecipate to the development of the product if necessary.

How to clone the repository:

The folders Svelto.ECS and Svelto.Common, where present, are submodules pointing to the relative repositories. If you find them empty, you need to update them through the submodule command. Check some instructions here: https://github.com/sebas77/Svelto.ECS.Vanilla.Example/wiki

Svelto distributed as Unity Package through OpenUPM openupm

or just install the package that comes from the link https://package-installer.glitch.me/v1/installer/OpenUPM/com.sebaslab.svelto.ecs?registry=https%3A%2F%2Fpackage.openupm.com

Note on the System.Runtime.CompilerServices.Unsafe.dll dependency and the bit of a mess that Unity Package Dependency System is:

Unity Package System has a big deficiency when it comes to dll dependency solving: two packages cannot point to the same dependency from different sources. For this reason I decided to let my packages to point to the unsafe dll distribution from openUPM

to solve the unsafe dependency you need to add the following scopedRegistries in manifest.json:

  {
    "scopedRegistries": [
        {
            "name": "package.openupm.com",
            "url": "https://package.openupm.com",
            "scopes": [
                "com.sebaslab.svelto.common",
                "com.sebaslab.svelto.ecs",
                "org.nuget.system.runtime.compilerservices.unsafe"
            ]
        }
    ],
    "dependencies": {
        "com.sebaslab.svelto.ecs": "3.2.6"
    }
}

this is shown in this example too: https://github.com/sebas77/Svelto.MiniExamples/tree/master/UPM-Integration/UPM

Svelto distributed as Nuget

I am not a Nuget expert, but thanks to our contributors, Svelto.ECS can be found at https://www.nuget.org/packages/Svelto.ECS/

the Hello World example uses the nuget package directly: https://github.com/sebas77/Svelto.MiniExamples/tree/master/Example5-Net-HelloWorld

Official Examples (A.K.A. where is the documentation?)

Svelto doesn't have official documentation. The reason is that documentation is costly to mantain and...I reckon people don't need it, thanks to the highly documented and simple mini-examples. Please check and study them all regardless the platform you intend to use Svelto with.

* Mini Examples: https://github.com/sebas77/Svelto.MiniExamples (including articles)

After that, you can get all the help you need from the official chat:

Official Discord Server (join to get help from me for free!)

Official Articles

Framework articles:

Theory related articles (from the most recent to the oldest, read from the oldest if you are new to it):

Practical articles

Note: I included the IoC articles just to show how I shifted over the years from using an IoC container to use an ECS framework and the rationale behind its adoption.

Users Generated Content (I removed all the outdated articles, so this is a call for new ones!)

Svelto Extensions

In case of bugs

Best option is to fork and clone https://github.com/sebas77/Svelto.ECS.Tests, add new tests to reproduce the problem and request a pull. I will then fix the issue. Also feel free to contact me on Discord.

I like the project, how can I help?

Hey, thanks a lot for considering this. You can help in several ways. The simplest is to talk about Svelto.ECS and spread the word, the more we are, the better it is for the community. Then you can help with the documentation, updating the wiki or writing your own articles. Svelto.ECS has all the features needed to make a game with the ECS pattern, but some areas are lacking: A visual debugger and more unit tests are needed. Other platforms other than Unity could get some love too: Stride Game, Godot, monogame, FNA or whatever supports c#. Porting to other languages, especially c++, would be awesome but probably pointless. Please check the lane dedicated to the community tasks list here: https://github.com/users/sebas77/projects/3 and let me know if you want to take something on!

Svelto Framework is used to develop the following products(*):

image Gamecraft Robocraft Infinity Cardlife

*If you want your products made with Svelto here, just send me an email or whatever, I'll be super happy to add them.

Note: Dear Svelto Users : Although I am committed to help you and write articles as much as I can, I will never be able to keep all the documentation up to date. If you are a happy svelto user and you want to contribute, please feel free to update the github wiki! 🙏👊