package ecs.core;

import res.display.FrameBuffer;

class System {
	public final components:Array<Class<Component>>;

	final entities:Array<Entity> = [];

	public var updatable = true;
	public var renderable = true;
	public var enabled = true;

	@:allow(ecs)
	private var engine:Engine;

	public function new(...components:Class<Component>) {
		this.components = components.toArray();
	}

	public function add(entity:Entity) {
		entities.push(entity);
	}

	public function has(entity:Entity):Bool {
		return entities.indexOf(entity) != -1;
	}

	public function remove(entity:Entity) {
		entities.remove(entity);
	}

	function updateEntity(entity:Entity, dt:Float) {}

	public function update(dt:Float) {
		for (entity in entities)
			updateEntity(entity, dt);
	}

	public function render(frameBuffer:FrameBuffer) {}
}
