I'm currently designing a game engine and want to implement my own ECS implementation, so I decided to look around for ideas.
Unity has recently updated their engine and seems to be pushing towards using ECS, instead of their original components-are-systems design.
I noticed that Unity has a method called "GetEntities", a generic method which can do something like this:
public struct SomeComponent : IEntityComponent
{
public string Message = "Hello, World!";
}
public struct Filter
{
SomeComponent someComponent;
}
public MovementSystem : EntitySystem
{
public override Process()
{
// How can I accomplish something like this?
foreach(var entity in GetEntities<Filter>())
{
Console.WriteLine(entity.someComponent.Message);
}
}
}
I like this style of iterating over entities, given a filter for a specific component they need to include. But I'm not sure how to accomplish something like this.
If someone could shed some light on how something like this is even possible in C# that would be great!