A Smoll game engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.0 KiB

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;
}
}
}