Arch
                                
                                
                                
                                    Arch copied to clipboard
                            
                            
                            
                        Entity Templates
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");
                                    
                                    
                                    
                                
Is this feature available ?
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
Svelto Ecs has interesting implementation, called Entity Descriptor's. Very robust and boilerplate (like many features in Svelto).
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 ^^