using System.Collections.Generic;
|
|
|
|
|
|
namespace Smoll {
|
|
public class Engine {
|
|
public Engine() {
|
|
modules = new List<IEngineModule>();
|
|
layers = new List<Layer>();
|
|
}
|
|
|
|
List<Layer> layers;
|
|
public List<IEngineModule> modules;
|
|
|
|
public void AttachLayer(Layer layer) {
|
|
layers.Add(layer);
|
|
layer.attachedEngine = this;
|
|
}
|
|
public void AttachModule(IEngineModule module) {
|
|
modules.Add(module);
|
|
}
|
|
|
|
public void Update() {
|
|
foreach (var layer in layers)
|
|
{
|
|
layer.Update();
|
|
}
|
|
}
|
|
|
|
public void Draw() {
|
|
foreach (var layer in layers)
|
|
{
|
|
layer.Draw();
|
|
}
|
|
}
|
|
|
|
public T? GetModule<T>() where T : class {
|
|
// TODO: Fix this *where* clause
|
|
var module = modules.Find((IEngineModule a) => a is T);
|
|
if(module == null) return null;
|
|
return module as T;
|
|
}
|
|
}
|
|
}
|