NodeTreeBuilder.cs 779 B

1234567891011121314151617181920212223
  1. using System;
  2. using XGame.Framework.Map;
  3. using XGame.Framework.Quality;
  4. using XGame.Framework.Time;
  5. using XGame.Framework.UI;
  6. namespace XGame.Framework.Nodes
  7. {
  8. public class NodeTreeBuilder
  9. {
  10. public INodeTree Product { get; private set; }
  11. public void Build(IQualityModule qualityModule, ITimeModule timeModule, IUIModule uiModule, IMapModule mapModule, Type appNodeType)
  12. {
  13. var context = new NodeContext(qualityModule, timeModule, uiModule, mapModule);
  14. var root = Activator.CreateInstance(appNodeType) as INode;
  15. (root as Node)?.Init(context);
  16. var nodeTree = new NodeTree(context, root);
  17. (context as INodeTreeSetter).NodeTree = nodeTree;
  18. Product = nodeTree;
  19. }
  20. }
  21. }