using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SpriteCompiler.AI { public class DepthLimitedNodeExpander : NodeExpanderDelegator where T : ISearchNode where C : ICost, new() { private readonly INodeLimiter limit; private bool cutoffOccured = false; public DepthLimitedNodeExpander(INodeExpander expander, INodeLimiter limit) : base(expander) { this.limit = limit; } public bool CutoffOccured { get { return cutoffOccured; } } public override IEnumerable Expand(ISearchProblem problem, T node) { if (limit.Cutoff(node)) { cutoffOccured = true; return Enumerable.Empty(); } return base.Expand(problem, node); } } }