Пример #1
0
    // -----------------------------------------------------------------------------------------

    /// <summary>
    /// Generates a new Tranzmit Node
    /// </summary>
    /// <param name="nodeName">The displayed name of the node.</param>
    /// <returns>The generated Node</returns>
    private Tranzmit_Node GenerateTranzmitNode(string nodeName)
    {
        var node = new Tranzmit_Node
        {
            title    = nodeName,
            Dialogue = nodeName,
            GUID     = Guid.NewGuid().ToString()
        };

        var button = new Button(clickEvent: () => { SelectObject(Tranzmit); });

        button.text = "Find Tranzmit";
        node.mainContainer.Add(button);

        var button2 = new Button(clickEvent: () => { SelectObject(TranzmitDebug); });

        button2.text = "Find Tranzmit Debug";
        node.mainContainer.Add(button2);

        node.SetPosition(TranzmitCorePosition);

        AddElement(node);

        return(node);
    }
Пример #2
0
    // -----------------------------------------------------------------------------------------

    /// <summary>
    /// Adds an Event Type Out port on the Core Node
    /// </summary>
    /// <param name="node">The Node to which the Port will be attached to</param>
    /// <returns>The Generated Port</returns>
    private Port Port_Add_Event_Type_Node(Tranzmit_Node node)
    {
        var port = Port_Generate_EVENT_TYPE(node, Direction.Output);

        port.portName  = "";
        port.portColor = SilentColor.PropertyValue;
        node.inputContainer.Add(port);

        return(port);
    }
Пример #3
0
    // -----------------------------------------------------------------------------------------

    /// <summary>
    /// Adds an Out port on the Tranzmit Node
    /// </summary>
    /// <param name="node">The Tranzmit Node</param>
    /// <param name="eventName">The associated event</param>
    /// <returns>The Generated Port</returns>
    private Port Port_Add_Tranzmit_IN(Tranzmit_Node node, Tranzmit.EventNames eventName)
    {
        // IN
        var inPort = Port_Generate_TRANZMIT_In(node, Direction.Input);

        inPort.portName  = eventName.ToString();;
        inPort.portColor = SilentColor.PropertyValue;
        node.inputContainer.Add(inPort);

        return(inPort);
    }
Пример #4
0
    // -----------------------------------------------------------------------------------------

    // Adds an Event Type Out port on the Core Node
    /// <summary>
    /// Adds an In port on the Tranzmit Node
    /// </summary>
    /// <param name="node">The Tranzmit Node</param>
    /// <param name="eventName">The associated event</param>
    /// <returns>The Generated Port</returns>
    private Port Port_Add_Tranzmit_OUT(Tranzmit_Node node, Tranzmit.EventNames eventName)
    {
        // OUT
        var outPort = Port_Generate_TRANZMIT_Out(node, Direction.Output);

        outPort.portName  = eventName.ToString();;
        outPort.portColor = SilentColor.PropertyValue;
        node.outputContainer.Add(outPort);

        return(outPort);
    }
Пример #5
0
    // -----------------------------------------------------------------------------------------

    /// <summary>
    /// Creates the ports on the Subscriber Nodes.
    /// </summary>
    /// <param name="subscriberNode">The Node to which we want to attach this port to.</param>
    /// <param name="tranzmitEvent">The Event that will be associated with this port.</param>
    /// <returns>The created port</returns>
    private Port GenerateTranzmitSubscriberInputPorts(Tranzmit_Node subscriberNode, Tranzmit.EventData tranzmitEvent)
    {
        var inputPort = Port_Generate_SUBSCRIBER(subscriberNode, Direction.Input, Port.Capacity.Single);

        inputPort.portName  = tranzmitEvent.Info.EventName.ToString();
        inputPort.portColor = SilentColor.PropertyValue;
        subscriberNode.inputContainer.Add(inputPort);
        subscriberNode.RefreshExpandedState();
        subscriberNode.RefreshPorts();

        return(inputPort);
    }
Пример #6
0
    // -----------------------------------------------------------------------------------------

    /// <summary>
    /// Generates a new Broadcaster Node
    /// </summary>
    /// <param name="nodeName">The displayed name of the node.</param>
    /// <returns>The generated Node</returns>
    private Tranzmit_Node GenerateTranzmitBoroadcasterNode(string nodeName)
    {
        var node = new Tranzmit_Node
        {
            title    = nodeName,
            Dialogue = nodeName,
            GUID     = Guid.NewGuid().ToString()
        };

        node.SetPosition(TranzmitBroadcastBasePosition);

        AddElement(node);

        return(node);
    }
Пример #7
0
    // -----------------------------------------------------------------------------------------

    /// <summary>
    /// Generates ALL Subscriber Nodes
    /// </summary>
    /// <param name="tranzmitNode">The Tanzmit Node to connect to</param>
    /// <param name="coreNodePort">The Tanzmit Port to connect to</param>
    /// <param name="tranzmitEvent">The associated event</param>
    private void Generate_Nodes_Subscriber(Tranzmit_Node tranzmitNode, Port coreNodePort, Tranzmit.EventData tranzmitEvent)
    {
        if (tranzmitEvent != null)
        {
            // Iterate Subscribers in the Event
            foreach (Delegate subscriber in tranzmitEvent.GetSubscribers())
            {
                bool found = false;

                // Iterate through our list of generated Subscriber Nodes
                foreach (SubscriberNodeData subNode in SubscriberNodes)
                {
                    // Check if the subscription objects are the same
                    if (subscriber.Target == subNode.Subscriber)
                    {
                        found = true;

                        // We just add a port onto the existing graph node
                        var SubscriberPort = GenerateTranzmitSubscriberInputPorts(subNode.Node, tranzmitEvent);
                        var edge           = SubscriberPort.ConnectTo(coreNodePort);
                        SubscriberPort.edgeConnector.target.Add(edge);

                        subNode.PortEdgeEvent.Add(new PortEdgeEventData()
                        {
                            SubscriberPort = SubscriberPort, TranzmitPort = coreNodePort, Edge = edge, EventName = tranzmitEvent.Info.EventName
                        });
                    }
                }

                // No graph node exists for the Subscription object so we create it and add / connect the edge.
                if (found == false)
                {
                    var subscriberNode = GenerateTranzmitSubscriberNode(subscriber.Target.ToString());

                    SubscriberNodeData newSubscriberNode = new SubscriberNodeData();
                    newSubscriberNode.Node       = subscriberNode;
                    newSubscriberNode.Subscriber = subscriber.Target;

                    var button = new Button(clickEvent: () => { SelectObject(subscriber.Target); });
                    button.text = "Find";
                    newSubscriberNode.Node.mainContainer.Add(button);


                    // Connect Ports
                    var SubscriberPort = GenerateTranzmitSubscriberInputPorts(subscriberNode, tranzmitEvent);

                    // Build Edge
                    var edge = SubscriberPort.ConnectTo(coreNodePort);
                    SubscriberPort.edgeConnector.target.Add(edge);

                    // Add connected port to new entry
                    newSubscriberNode.PortEdgeEvent.Add(new PortEdgeEventData()
                    {
                        SubscriberPort = SubscriberPort, TranzmitPort = coreNodePort, Edge = edge, EventName = tranzmitEvent.Info.EventName
                    });

                    // Add Entry
                    SubscriberNodes.Add(newSubscriberNode);
                }
            }

            // Update the node when we are done with it
            tranzmitNode.RefreshExpandedState();
            tranzmitNode.RefreshPorts();
        }
        else
        {
            Debug.Log("No subscribers were found!");
        }
    }
Пример #8
0
    // -----------------------------------------------------------------------------------------

    // EVENT TYPE NODE Port Generation
    private Port Port_Generate_EVENT_TYPE(Tranzmit_Node node, Direction portDirection, Port.Capacity capacity = Port.Capacity.Single)
    {
        return(node.InstantiatePort(Orientation.Horizontal, portDirection, capacity, typeof(int)));
    }
Пример #9
0
    // -----------------------------------------------------------------------------------------

    // TRANZMIT NODE OUT Port Generation
    private Port Port_Generate_TRANZMIT_Out(Tranzmit_Node node, Direction portDirection, Port.Capacity capacity = Port.Capacity.Multi)
    {
        return(node.InstantiatePort(Orientation.Horizontal, portDirection, capacity, typeof(int)));
    }