示例#1
0
        /// <summary>
        /// Handle the user attempting to remove a node.
        /// </summary>
        /// <param name="n">The node that is being removed.</param>
        private void OnRemoveNode(NodeGraphWindowBaseNode n)
        {
            // Delete the asset, but allow it to be undone.
            mCachedDialogAsset.RemoveNode_Editor(n.associatedNode);

            // Reinitialize because this might've caused connections to be deleted too.
            InitializeFromCharacter();
        }
示例#2
0
        /// <summary>
        /// Attempt to add a new connection between the provided node and whichever is under the mouse.
        /// </summary>
        /// <param name="startNode">The node we are drawing the connection FROM</param>
        /// <param name="mousePosition">The current mouse position.</param>
        /// <returns>True if this was successful, otherwise false.</returns>
        private bool OnTryAddConnection(NodeGraphWindowBaseNode startNode, Vector2 mousePosition)
        {
            NodeGraphWindowBaseNode target = mNodes.LastOrDefault(x => x.associatedNode.rect.Contains(mousePosition) && x != startNode);

            // If target is null, or we already have a connection to it, "fail" this connection.
            if (target == null || startNode.associatedNode.outConnections.Any(x => x.outNode == target.associatedNode))
            {
                return(false);
            }

            // Create a new connection
            BaseConnection connection = mCachedDialogAsset.AddConnection_Editor(startNode.associatedNode, target.associatedNode);

            mConnections.Add(new NodeGraphWindowBaseConnection(connection, OnRemoveConnection));

            return(true);
        }