2024-04-22 16:34:44 +08:00
|
|
|
namespace DCFApixels.DragonECS
|
|
|
|
{
|
|
|
|
public interface ITemplateNode
|
|
|
|
{
|
2024-04-22 17:00:30 +08:00
|
|
|
void Apply(short worldID, int entityID);
|
2024-04-22 16:34:44 +08:00
|
|
|
}
|
|
|
|
public static class ITemplateNodeExtensions
|
|
|
|
{
|
|
|
|
public static int NewEntity(this EcsWorld world, ITemplateNode template)
|
|
|
|
{
|
|
|
|
int e = world.NewEntity();
|
2024-10-31 16:27:53 +08:00
|
|
|
template.Apply(world.ID, e);
|
2024-04-22 16:34:44 +08:00
|
|
|
return e;
|
|
|
|
}
|
|
|
|
public static entlong NewEntityLong(this EcsWorld world, ITemplateNode template)
|
|
|
|
{
|
|
|
|
entlong e = world.NewEntityLong();
|
2024-10-31 16:27:53 +08:00
|
|
|
template.Apply(world.ID, e.ID);
|
2024-04-22 16:34:44 +08:00
|
|
|
return e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|