Home

Awesome

<p align="center"> <img src="https://i.imgur.com/M5RdOCm.png" alt="NanoECS"> </p> <!---<p align="center"> <img src="https://discordapp.com/assets/f8389ca1a741a115313bede9ac02e2c0.svg" alt="NanoECS" width="40" height="40"> Discord IL#6472 </p>--->

NanoECS - C#/Unity entity-component-system framework

Features

Showcase

The projects below made with NanoECS and Unity:

Mobile strategy Save The Earth

<a href="https://play.google.com/store/apps/details?id=com.gamefirst.free.strategy.save.the.earth"> <img src="https://github.com/SinyavtsevIlya/ShowCaseAssets/blob/main/STE.jpg" alt="Save The Earth" height="285"></a>

(clickable)

Hyper Casual projects:

<p align="left"> <a href="http://www.youtube.com/watch?v=ZAdR9D2l9MI"> <img src="https://github.com/SinyavtsevIlya/ShowCaseAssets/blob/main/HyperRace.jpg" alt="Hyper Race 3D" height="365"></a> <a href="http://www.youtube.com/watch?v=ZGNpU__BdQk"> <img src="https://github.com/SinyavtsevIlya/ShowCaseAssets/blob/main/KnifeAway.jpg" alt="Knife Away" height="365"></a> <a href="http://www.youtube.com/watch?v=IsTCmLSTZBU"> <img src="https://github.com/SinyavtsevIlya/ShowCaseAssets/blob/main/Numio.png" alt="Num.io" height="365"></a> </p>

(clickable)

First look

Entity

Create a new entity:

var player = contexts.Core.CreateEntity()	
    .AddPosition(Vector3.zero)
    .AddHealth(100)
    .AddSkin("Butterfly");

Group

Get entities with "position" and "view" components and without "movable" component:

CoreGroup group = contexts.Core.GetGroup()
    .With.Position
    .With.View
    .Without.Movable;

Usage:

Handle filtered entities:

foreach (e in group) 
{	
	Print(e.Position.Value);
	Print(e.View.Value);
	Print(e.View.IsMovable);
}

Collector

Get all entities with "Speed" and "Position" only when the position value is changed:

CoreCollector collector = contexts.Core.GetGroup()
    .With.Speed
    .With.Position
    .OnPositionChange();

Handle these entities:

foreach (e in collector) 
{	
	Print("My position has changed! : {0}", e.Position.Value);
}
collector.Clear();

Accessing component values

example 1:

e.Position.Value += e.Direction.Value.ToVector3() * e.Speed.Value * delta;

example 2:

foreach (var player in defeatedPlayers)
{
    player.IsDestroyed = true;
    player.DefeatsCounter.Value++;

    if (!player.IsAIDriven)
    {
	contexts.Request.CreateEntity()
	    .AddDelay(0.6f)
	    .IsGameOverRequest = true;
    }
}

Visual Debugging

<p align="left"> <img src="https://github.com/SinyavtsevIlya/ShowCaseAssets/blob/main/NanoEcs_Editor2.gif" alt="entity editor"> </p> <p align="left"> <img src="https://github.com/SinyavtsevIlya/ShowCaseAssets/blob/main/NanoEcs_Editor.gif" alt="entity editor"> </p>

Code Generation

<p align="left"> <img src="https://github.com/SinyavtsevIlya/ShowCaseAssets/blob/main/NanoEcs_Console_p.jpg" alt="entity editor"> </p>

How to use generator?

class Score
{
    int value;
}

Generator will automatically detect changes and create API fow you. You dont need to leave your IDE, just keep writing your code.

A few tips:

NanoEcs Generator sources

If you for some reasons want to edit NanoEcs generator, the sources are available here.

Inspiration and goals

The framework is inspired a lot by such projects as Entitas, Actors, LeoECS.

But I found that Entitas has some design problems to me:

The goal of this project was to make API as much fluent as possible, and keep performance as well.

Documentation

Wiki

How to install

Should I use it?

Before making a decision, pay attention to a few points:

Feedback

If you find a bug, have some suggestions or just want to discuss, let me know:

<!--* <b>discord</b> [![Discord](https://img.shields.io/discord/565885959598768148.svg)](https://discord.gg/u7zrtq) -->