Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity Templates #21

Open
genaray opened this issue Nov 27, 2022 · 4 comments
Open

Entity Templates #21

genaray opened this issue Nov 27, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@genaray
Copy link
Owner

genaray commented Nov 27, 2022

Background

Would be pretty neat if we could clone entities and its components based on a template which defines its values.
Basically a way to create entities with set values. Has many advantages, can be serialized easily and is more effective in many ways.

Idea

Either:

var template = new Template(
   new Position(10,10),
   new Mesh(5, Mode.Batched),
   ...
);

var clone = world.Create(template);

Or using source generation:

[Template]
public struct PlayerTemplate{

   public Transform Transform;
   public Velocity Velocity;
   public Model Modell;
   public ...
   ....
}

var template = new PlayerTemplate(whateverData);
var clone = world.Create(template);

When we choose source generators we could even build more cool constructs around this. Like an extremely efficient identifier mechanic to clone certain templates:

[TemplateStorage]
public struct Templates{

   [Identifier("1:1")]  // Or raw ints e.g. for networking? 
   public PlayerTemplate playerTemplate;

   [Identifier("1:2")]
   public MobTemplate mobTemplate;

   [Identifier("2:1")]
   public FireGolemTemplate fireGolemTemplate;
}

var cloneByIdentifier = world.Create("1:1");
var fireGolem = world.Create("2:1");
@mastertnt
Copy link

Is this feature available ?

@genaray
Copy link
Owner Author

genaray commented Sep 14, 2023

Is this feature available ?

Not yet, but its still on the roadmap :)
Will probably be part of Arch.Extended with its own source-generator and persistence integration ^^

However that could still take a while (need to do query caching first), so if anyone wanna contribute... feel free to :p

@skelitheprogrammer
Copy link
Contributor

skelitheprogrammer commented Feb 29, 2024

Svelto Ecs has interesting implementation, called Entity Descriptor's. Very robust and boilerplate (like many features in Svelto).

@genaray
Copy link
Owner Author

genaray commented Mar 13, 2024

Svelto Ecs has interesting implementation, called Entity Descriptor's. Very robust and boilerplate (like many features in Svelto).

It could look similar for Arch. But with less boilerplate code of course ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

3 participants