public QQ_Node(int id, QQ_NodeType type, float x = 0, float y = 0) { ID = id; Type = type; Window.x = x; Window.y = y; }
public QQ_ConnectionRule(QQ_NodeType inputType, int inputID, QQ_NodeType outputType, int outputID) { InputType = inputType; InputID = inputID; OutputType = outputType; OutputID = outputID; }
/// <summary> /// The function called to modify the node's data whenever a node disconnects. /// </summary> /// <param name="quest">The quest data.</param> /// <param name="connectionType">The type of the connecting node.</param> /// <param name="connectionID">The id of the connected node.</param> public void OnDisconnect(QQ_QuestSO quest, QQ_NodeType connectionType, int connectionID) { if (NextTasks.Contains(connectionID)) { NextTasks.Remove(connectionID); } }
/// <summary> /// Returns whether or not a connection is allowed. Used before connecting. /// </summary> /// <param name="knobType">The knob type being connected to on this node.</param> /// <param name="knobID">The id of the knob being connected to on this node.</param> /// <param name="otherNodeType">The node type being connected to on the other node.</param> /// <param name="otherKnobType">The knob type being connected to on the other node.</param> /// <param name="otherKnobID">The id of the knob being connected to on the other node.</param> /// <returns></returns> public bool CanConnect(QQ_KnobType knobType, int knobID, QQ_NodeType otherNodeType, QQ_KnobType otherKnobType, int otherKnobID) { bool canConnect = false; if (knobType == QQ_KnobType.Input) { foreach (var rule in AllowedInputs) { if (rule.InputType == Type && rule.InputID == knobID && rule.OutputType == otherNodeType && otherKnobType == QQ_KnobType.Output && rule.OutputID == otherKnobID) { canConnect = true; break; } } } else if (knobType == QQ_KnobType.Output) { foreach (var rule in AllowedOutputs) { if (rule.OutputType == Type && rule.OutputID == knobID && rule.InputType == otherNodeType && otherKnobType == QQ_KnobType.Input && rule.InputID == otherKnobID) { canConnect = true; break; } } } return(canConnect); }
/// <summary> /// The function called to modify the node's data whenever a node disconnects. /// </summary> /// <param name="quest">The quest data.</param> /// <param name="connectionType">The type of the connecting node.</param> /// <param name="connectionID">The id of the connected node.</param> /// <param name="knobID">The id of the knob.</param> /// <param name="knobType">The type of the knob.</param> public void OnDisconnect(QQ_QuestSO quest, QQ_NodeType connectionType, int connectionID, int knobID, QQ_KnobType knobType) { if (knobType == QQ_KnobType.Input) { } else if (knobType == QQ_KnobType.Output) { FirstTasks.Remove(connectionID); } }
/// <summary> /// The function called to modify the node's data whenever a node disconnects. /// </summary> /// <param name="quest">The quest data.</param> /// <param name="connectionType">The type of the connecting node.</param> /// <param name="connectionID">The id of the connected node.</param> /// <param name="connectionKnobID">The id of the connected knob.</param> /// <param name="knobID">The id of the knob.</param> /// <param name="knobType">The type of the knob.</param> public virtual void OnDisconnect(QQ_QuestSO quest, QQ_NodeType connectionType, int connectionID, int connectionKnobID, int knobID, QQ_KnobType knobType) { if (Type == QQ_NodeType.Quest) { QQ_QuestEditor.db.GetQuestNode(ID).OnDisconnect(quest, connectionType, connectionID, connectionKnobID, knobID, knobType); } else if (Type == QQ_NodeType.Task) { QQ_QuestEditor.db.GetTaskNode(ID).OnDisconnect(quest, connectionType, connectionID, connectionKnobID, knobID, knobType); } }
/// <summary> /// The function called to modify the node's data whenever a node connects. /// </summary> /// <param name="quest">The quest data.</param> /// <param name="connectionType">The type of the connecting node.</param> /// <param name="connectionID">The id of the connecting node.</param> /// <param name="connectionKnobID">The id of the connecting knob.</param> /// <param name="knobID">The id of this node's knob.</param> /// <param name="knobType">The type of this node's knob.</param> public void OnConnect(QQ_QuestSO quest, QQ_NodeType connectionType, int connectionID, int connectionKnobID, int knobID, QQ_KnobType knobType) { if (knobType == QQ_KnobType.Input) { } else if (knobType == QQ_KnobType.Output) { if (!NextTasks.Contains(connectionID)) { NextTasks.Add(connectionID); } } }
/// <summary> /// Creates a new node of the given type at the given position. /// </summary> /// <param name="type"></param> /// <param name="position"></param> public void CreateNode(QQ_NodeType type, Vector2 position) { int id = NextID++; var node = new QQ_Node(id, type, position.x, position.y); if (type == QQ_NodeType.Quest) { var questNode = new QQ_QuestNode(id, type, position.x, position.y); node.Window.width = questNode.Window.width; node.Window.height = questNode.Window.height; node.Inputs = questNode.CloneKnobs(QQ_KnobType.Input); node.Outputs = questNode.CloneKnobs(QQ_KnobType.Output); node.AllowedInputs = questNode.AllowedInputs; node.AllowedOutputs = questNode.AllowedOutputs; var questData = DataDB.Quest; DataDB.Quest = questData; questNode.Data = questData; QuestNodes.Add(questNode); } else if (type == QQ_NodeType.Task) { var taskNode = new QQ_TaskNode(id, type, position.x, position.y); node.Window.width = taskNode.Window.width; node.Window.height = taskNode.Window.height; node.Inputs = taskNode.CloneKnobs(QQ_KnobType.Input); node.Outputs = taskNode.CloneKnobs(QQ_KnobType.Output); node.AllowedInputs = taskNode.AllowedInputs; node.AllowedOutputs = taskNode.AllowedOutputs; var taskData = new QQ_Task(id); QQ_QuestNode quest = GetQuestNode(0); quest.Data.Tasks.Add(taskData); DataDB.SetQuest(0, quest.Data); taskNode.Data = taskData; TaskNodes.Add(taskNode); } Nodes.Add(node); }
public QQ_QuestNode(int id, QQ_NodeType type, float x = 0, float y = 0) : base(id, type, x, y) { Type = QQ_NodeType.Quest; Window = new Rect(0, 0, 300, 125); Inputs = new List <QQ_Knob> { }; Outputs = new List <QQ_Knob> { new QQ_Knob(0, "First Tasks", QQ_KnobType.Output, 7.5f, true) }; AllowedInputs = new List <QQ_ConnectionRule> { }; AllowedOutputs = new List <QQ_ConnectionRule> { new QQ_ConnectionRule(QQ_NodeType.Task, 0, QQ_NodeType.Quest, 0) }; }
/// <summary> /// The function called to modify the node's data whenever a node disconnects. /// </summary> /// <param name="quest">The quest data.</param> /// <param name="connectionType">The type of the connecting node.</param> /// <param name="connectionID">The id of the connected node.</param> /// <param name="knobID">The id of the knob.</param> /// <param name="knobType">The type of the knob.</param> public override void OnDisconnect(QQ_QuestSO quest, QQ_NodeType connectionType, int connectionID, int knobID, QQ_KnobType knobType) { Data.OnDisconnect(quest, connectionType, connectionID, knobID, knobType); QQ_QuestEditor.db.DataDB.SetTask(Data.ID, Data); }
/// <summary> /// The function called to modify the node's data whenever a node disconnects. /// </summary> /// <param name="quest">The quest data.</param> /// <param name="connectionType">The type of the connecting node.</param> /// <param name="connectionID">The id of the connected node.</param> public override void OnDisconnect(QQ_QuestSO quest, QQ_NodeType connectionType, int connectionID) { Data.OnDisconnect(quest, connectionType, connectionID); QQ_QuestEditor.db.DataDB.SetQuest(Data.ID, Data); }
/// <summary> /// The function called to modify the node's data whenever a node disconnects. /// </summary> /// <param name="quest">The quest data.</param> /// <param name="connectionType">The type of the connecting node.</param> /// <param name="connectionID">The id of the connected node.</param> /// <param name="connectionKnobID">The id of the connected knob.</param> /// <param name="knobID">The id of the knob.</param> /// <param name="knobType">The type of the knob.</param> public void OnDisconnect(QQ_QuestSO quest, QQ_NodeType connectionType, int connectionID, int connectionKnobID, int knobID, QQ_KnobType knobType) { OnDisconnect(quest, connectionType, connectionID, knobID, knobType); }
/// <summary> /// The function called to modify the node's data whenever a node disconnects. /// </summary> /// <param name="quest">The quest data.</param> /// <param name="connectionType">The type of the connecting node.</param> /// <param name="connectionID">The id of the connected node.</param> public void OnDisconnect(QQ_QuestSO quest, QQ_NodeType connectionType, int connectionID) { FirstTasks.Remove(connectionID); }