Example #1
0
        internal void AddNodeView(Vector2 pos, Node node)
        {
            GraphElement nodeView = null;

            if (node is RootTask rootTask)
            {
                nodeView = new RootTaskView(rootTask, pos);
            }
            else if (node is CompositeTask compositeTask)
            {
                nodeView = new CompositeTaskView(compositeTask, pos);
            }
            else if (node is DecoratorTask decoratorTask)
            {
                nodeView = new DecoratorTaskView(decoratorTask, pos);
            }
            else if (node is Task task)
            {
                nodeView = new TaskNodeView(task, pos);
            }
            else if (node is LogicNode logicNode)
            {
                nodeView = new LogicNodeView(logicNode, pos);
            }

            if (nodeView != null)
            {
                AddElement(nodeView);
            }
        }
Example #2
0
        internal void AddNodeView(Vector2 pos, Type type)
        {
            GraphElement nodeView = null;

            if (type.IsSubclassOf(typeof(RootTask)))
            {
                nodeView = new RootTaskView((RootTask)Activator.CreateInstance(type), pos);
            }
            else if (type.IsSubclassOf(typeof(CompositeTask)))
            {
                nodeView = new CompositeTaskView((CompositeTask)Activator.CreateInstance(type), pos);
            }
            else if (type.IsSubclassOf(typeof(DecoratorTask)))
            {
                nodeView = new DecoratorTaskView((DecoratorTask)Activator.CreateInstance(type), pos);
            }
            else if (type.IsSubclassOf(typeof(Task)))
            {
                nodeView = new TaskNodeView((Task)Activator.CreateInstance(type), pos);
            }
            else if (type.IsSubclassOf(typeof(LogicNode)))
            {
                nodeView = new LogicNodeView((LogicNode)Activator.CreateInstance(type), pos);
            }

            if (nodeView != null)
            {
                AddElement(nodeView);
            }
        }