using System; using System.Collections.Generic; using System.Linq; using Assets.AnnotationPass; using Assets.Common; using Assets.GridGenerator; namespace Assets { class MapGenerator { private IGridGenerator _gridGenerator; private ICollection _annotationPasses = new List(); private Map _result; public IEnumerable AnnotationPasses => _annotationPasses.AsEnumerable(); public Map Result => _result; public bool IsDone => _result != null; public MapGenerator(IGridGenerator gridGenerator) { _gridGenerator = gridGenerator; } public void AddAnnotationPass(IAnnotationPass pass) { _annotationPasses.Add(pass); } public Map Generate(double width, double height) { if (_result != null) return _result; _result = _gridGenerator.CreateGrid(width, height); foreach (var pass in _annotationPasses) pass.Annotate(_result); return _result; } } }