Esempio n. 1
0
        public void PostLoad(Project project)
        {
            //Resolve links with package
            Package = project.GetPackage(PackageName);
            if (Package == null)
            {
                EditorCore.LogError("Loading a Dialogue without Package (forcing default) : " + GetName(), this);
                Package = project.GetDefaultPackage();
            }

            //Resolve links between nodes
            RootNode = GetNodeByID(RootNodeID) as DialogueNodeRoot;

            foreach (DialogueNode node in ListNodes)
            {
                node.Next = GetNodeByID(node.NextID);
                if (node is DialogueNodeChoice)
                {
                    DialogueNodeChoice nodeChoice = node as DialogueNodeChoice;
                    foreach (int replyID in nodeChoice.RepliesIDs)
                    {
                        DialogueNodeReply nodeReply = GetNodeByID(replyID) as DialogueNodeReply;
                        if (nodeReply != null)
                        {
                            nodeChoice.Replies.Add(nodeReply);
                        }
                    }
                }
                else if (node is DialogueNodeGoto)
                {
                    DialogueNodeGoto nodeGoto = node as DialogueNodeGoto;
                    nodeGoto.Goto = GetNodeByID(nodeGoto.GotoID);
                }
                else if (node is DialogueNodeBranch)
                {
                    DialogueNodeBranch nodebranch = node as DialogueNodeBranch;
                    nodebranch.Branch = GetNodeByID(nodebranch.BranchID);
                }
            }

            EditorCore.OnDialoguePostLoad?.Invoke(this);
        }