Entitas icon indicating copy to clipboard operation
Entitas copied to clipboard

New namespace support

Open sschmid opened this issue 4 years ago • 1 comments

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

  • CommonAttribute
  • CommonComponentsLookup
  • CommonContext
  • CommonEntity
  • CommonMatcher etc.

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 avatar Jun 18 '20 09:06 sschmid

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 avatar Sep 25 '20 13:09 sschmid

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

sschmid avatar Jul 03 '23 13:07 sschmid