|
|
@@ -6,7 +6,7 @@ Real ECS framework for c\#. Enables to write encapsulated, decoupled, maintainab |
|
|
|
## 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. |
|
|
|
|
|
|
|
### Svelto.ECS at glance |
|
|
|
### Svelto.ECS at glance: |
|
|
|
```csharp |
|
|
|
public class SimpleContext |
|
|
|
{ |
|
|
@@ -40,6 +40,46 @@ Svelto.ECS is easy to start with, but full of tricks for expert users. The harde |
|
|
|
} |
|
|
|
``` |
|
|
|
|
|
|
|
your first entity descriptor: |
|
|
|
|
|
|
|
```csharp |
|
|
|
public struct EntityComponent : IEntityComponent |
|
|
|
{ |
|
|
|
public int counter; |
|
|
|
} |
|
|
|
|
|
|
|
class SimpleEntityDescriptor : GenericEntityDescriptor<EntityComponent> |
|
|
|
{} |
|
|
|
``` |
|
|
|
|
|
|
|
your first engine to apply behaviours to entities: |
|
|
|
|
|
|
|
```csharp |
|
|
|
public class BehaviourForEntityClassEngine : IQueryingEntitiesEngine |
|
|
|
{ |
|
|
|
public BehaviourForEntityClassEngine(IEntityFunctions entityFunctions) |
|
|
|
{ |
|
|
|
_entityFunctions = entityFunctions; |
|
|
|
} |
|
|
|
|
|
|
|
public EntitiesDB entitiesDB { get; set; } |
|
|
|
|
|
|
|
public void Ready() { } |
|
|
|
|
|
|
|
public void Update() |
|
|
|
{ |
|
|
|
var (entityViews, count) = entitiesDB.QueryEntities<EntityComponent>(ExclusiveGroups.group1); |
|
|
|
|
|
|
|
for (var i = 0; i < count; i++) |
|
|
|
entityViews[i].counter++; |
|
|
|
|
|
|
|
Console.Log("Entity Struct engine executed"); |
|
|
|
} |
|
|
|
|
|
|
|
readonly IEntityFunctions _entityFunctions; |
|
|
|
} |
|
|
|
``` |
|
|
|
|
|
|
|
## 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. |
|
|
|
|
|
|
|