private GraphNode AddNewNode(ActionGraphNodeBase node)
        {
            AssetDatabaseUtils.AddToAsset(Asset, node);

            switch (node)
            {
            case ActionGraphNode asAction:
            {
                Asset.Nodes.Add(asAction);
                break;
            }

            case AnyEntry asAnyEntry:
            {
                Asset.AnyEntryNode = asAnyEntry;
                break;
            }

            case EventEntry asEntry:
            {
                Asset.NamedEventEntries.Add(asEntry);
                break;
            }

            default:
            {
                Debug.LogError($"Unknown node {node}!");
                break;
            }
            }

            return(View.OnNodeAdded(Asset, node));
        }
Пример #2
0
        public ActionGraphEditorEntryBase(ActionGraph graph, ActionGraphNodeBase node, ActionGraphPresenter presenter)
            : base(graph, node, presenter)
        {
            var builder = new PathBuilder <AnyEntry>();

            ConditionPropertyPath = builder
                                    .ByListOf <AnyEntry.EntryInfo>(t => nameof(t.Entries))
                                    .Path();

            if (ActionNode)
            {
                ActionNode.Notifiers.Add(this);
            }
        }
Пример #3
0
        private System.Type FindNodeEditor(ActionGraphNodeBase node)
        {
            return(NodeEditors.FirstOrDefault(t => t.CustomAttributes.Any(
                                                  a =>
            {
                if (a.AttributeType == typeof(CustomActionEditor) &&
                    a.ConstructorArguments.Count >= 1)
                {
                    return a.ConstructorArguments[0].Value == node.GetType();
                }

                return false;
            })));
        }
        public ActionGraphEditorNode(ActionGraph graph, ActionGraphNodeBase node, ActionGraphPresenter presenter)
        {
            Graph      = graph;
            ActionNode = node;
            Presenter  = presenter;

            Size     = new Vector2(164, 64);
            Position = ActionNode.EditorPosition;

            if (!Inputs.Any())
            {
                Inputs.Add(new Slot(this, SlotType.Input));
            }

            ActionNode.ValidationSubscribe(OnTargetChanged);
        }
        public ActionGraphEditorState(ActionGraph graph, ActionGraphNodeBase node, ActionGraphPresenter presenter)
            : base(graph, node, presenter)
        {
            var connection_builder = new PathBuilder <ActionState>();

            connection_builder.ByListOf <ActionState.ConnectionInfo>(l => nameof(State.ConnectionInfos));
            ToConnectionInfos = connection_builder.Path();

            var child_builder = new PathBuilder <ActionState>();

            child_builder.ByListOf <ActionGraphNode>(l => nameof(State.Connections));
            ToChildren = child_builder.Path();

            if (ActionNode)
            {
                ActionNode.Notifiers.Add(this);
            }
        }
Пример #6
0
        private ActionGraphEditorNode CreateNodeEditor(ActionGraphNodeBase node, ActionGraph graph)
        {
            var editorNodeType = FindNodeEditor(node);

            ActionGraphEditorNode editorNode = null;

            if (editorNodeType != null)
            {
                editorNode = Activator.CreateInstance(editorNodeType, graph, node, Presenter)
                             as ActionGraphEditorNode;
            }
            else
            {
                editorNode = new ActionGraphEditorNode(graph, node, Presenter);
            }

            NodeLookup[node] = editorNode;
            Nodes.AddNode(editorNode);

            return(editorNode);
        }