SharperUniverse
SharperUniverse copied to clipboard
Add Initialize() Finalize() Methods in the System
Allow systems to call an Initialize Method and a Finalize Method aside from just having an Update Method.
The initialize method allows you to contain any initialisation requirements within the system instead of when instantiating the system:
EG:
var fooSystem = new FooSystem(gameRunner);
var entity = gameRunner.CreateEntityAsync();
fooSystem.RegisterComponentAsync(entity);
vs
public class FooSystem : BaseSystemInterface
{
//add boilerplate etc...
public async Task Initialize(GameRunner gameRunner)
{
var entity = gameRunner.CreateEntityAsync();
this.RegisterComponentAsync(entity);
}
}
The Finalize Method would allow you setup the system in a way that it can tear itself down of anything that needs to be cleared between new games (ie/start game -> Initialize -> end game -> Finalize -> new game -> Initialize etc..)
Would Initialize()
now just be the constructor in the current iteration of the ECS?
I can see a need for a Finalize()
if things such as state saving needs to happen.