sschmid / Entitas

Entitas is a super fast Entity Component System (ECS) Framework specifically made for C# and Unity
MIT License
7.08k stars 1.11k forks source link

New namespace support #943

Closed sschmid closed 1 year ago

sschmid commented 4 years ago

I started working on new approach to namespace support.

My ideas:

  1. Contexts: You can create namespaces for contexts by just declaring it in the Jenny.properties or the Jenny preferences window

Game, Input, MySharedStuff.Common

This should generate

and all of them are wrapped in MySharedStuff namespace.

You can still access the contexts like contexts.game, contexts.mySharedstuffCommon

You can still use the attributes

[MySharedStuff.Common]
public sealed class Position3Int : IComponent
{
    public Vector3Int Value;
}
  1. Components

You can add namespaces to components

namespace Shmup.Core
{
    public sealed class Player : IComponent
    {
    }
}
var e = contexts.game.CreateEntity(); // e is GameEntity
contexts.game.CreateEntity().isPlayer = true;

It's work in progress, I'm currently working on the details and see what works well and what doesn't. I try to keep the api the same, but in some cases it might be necessary to be more explicit to avoid name clashes.

I'll keep you updated and add more examples once it takes shapes more.

sschmid commented 3 years ago

Update: I'm making some progress on this while at the same time tackling one of my favourite issue #307

This requires changes to the current code gen which generates partial classes for entities etc. This will be replaced with C# extension methods. More infos coming soon

sschmid commented 1 year ago

Will close in favour of #1005 You can follow the progress there