internal void RegisterDialogNode(DialogNode dialogNode)
 {
     if (DialogNodesWithId.ContainsKey(dialogNode.Id))
     {
         var otherNode = DialogNodesWithId[dialogNode.Id];
         LogMessage(dialogNode.LineNumber, MessageType.DuplicateKey, "Two distinct dialog nodes share the same id \"" + dialogNode.Id + "\" : line " + otherNode.LineNumber + " and line " + dialogNode.LineNumber);
     }
     else
     {
         DialogNodesWithId.Add(dialogNode.Id, dialogNode);
     }
 }
 private void ResolveGotoReferences(DialogNode dialogNode)
 {
     if (previousNode != null && previousNode.Type == DialogNodeType.GotoNode)
     {
         var previousGotoNode = (GotoNode)previousNode;
         if (previousGotoNode.TargetNode == dialogNode)
         {
             previousGotoNode.Type = DialogNodeType.GotoNext;
         }
     }
     if (dialogNode.Type == DialogNodeType.GotoNode)
     {
         var gotoNode = (GotoNode)dialogNode;
         if (!String.IsNullOrEmpty(gotoNode.TargetNodeId))
         {
             if (DialogNodesWithId.ContainsKey(gotoNode.TargetNodeId))
             {
                 var targetNode = DialogNodesWithId[gotoNode.TargetNodeId];
                 gotoNode.TargetNode = targetNode;
                 targetNode.AddDialogNodeReference(gotoNode);
             }
             else
             {
                 LogMessage(gotoNode.LineNumber, MessageType.InvalidReference, "Goto node with invalid node reference : \"" + gotoNode.TargetNodeId + "\" (target node may be offline) => dead end");
             }
         }
     }
     previousNode = dialogNode;
     if (dialogNode.ChildrenNodes != null)
     {
         foreach (var childNode in dialogNode.ChildrenNodes)
         {
             ResolveGotoReferences(childNode);
         }
     }
 }