StonehearthEditor.EncounterNodeData.LoadData C# (CSharp) Method

LoadData() public method

public LoadData ( GameMasterNode>.Dictionary allNodes ) : void
allNodes GameMasterNode>.Dictionary
return void
        public override void LoadData(Dictionary<string, GameMasterNode> allNodes)
        {
            mOutEdgeStrings = new List<string>();
            mChoiceEdgeInfo = new Dictionary<string, List<string>>();
            mEncounterType = NodeFile.Json["encounter_type"].ToString();
            mInEdge = NodeFile.Json["in_edge"].ToString();
            if (mInEdge.Equals("start"))
            {
                mIsStartNode = true;
            }

            mOutEdgeStrings = ParseOutEdges(NodeFile.Json["out_edge"]);
            switch (mEncounterType)
            {
                case "generator":
                    JToken generatorInfo = NodeFile.Json["generator_info"];
                    if (generatorInfo.SelectToken("spawn_edge") != null)
                    {
                        AddOutEdgesRecursive(generatorInfo["spawn_edge"], mOutEdgeStrings);
                    }

                    break;
                case "collection_quest":
                    Dictionary<string, string> collectionEdges = JsonHelper.GetJsonStringDictionary(NodeFile.Json["collection_quest_info"], "out_edges");
                    foreach (KeyValuePair<string, string> collectionEdge in collectionEdges)
                    {
                        string outEdge = collectionEdge.Value;
                        string choice = collectionEdge.Key;
                        if (!outEdge.Equals("none"))
                        {
                            List<string> list;
                            if (!mChoiceEdgeInfo.TryGetValue(outEdge, out list))
                            {
                                list = new List<string>();
                            }

                            list.Add(choice);
                            mChoiceEdgeInfo[outEdge] = list;
                            if (!mOutEdgeStrings.Contains(outEdge))
                            {
                                mOutEdgeStrings.Add(outEdge);
                            }
                        }
                    }

                    break;
                case "dialog_tree":
                    // Go through all the dialog nodes and add ot edges
                    foreach (JToken dialogNode in NodeFile.Json["dialog_tree_info"]["nodes"].Children())
                    {
                        JToken choices = dialogNode.First["bulletin"]["choices"];
                        foreach (JToken nodeData in choices.Values())
                        {
                            string parentName = (nodeData.Parent as JProperty).Name;
                            string translatedParentName = ModuleDataManager.GetInstance().LocalizeString(parentName);
                            JToken outEdgeSpec = nodeData["out_edge"];
                            if (outEdgeSpec != null)
                            {
                                List<string> outEdges = new List<string>();
                                AddOutEdgesRecursive(nodeData["out_edge"], outEdges);
                                foreach(string outEdge in outEdges)
                                {
                                    List<string> list;
                                    if (!mChoiceEdgeInfo.TryGetValue(outEdge, out list))
                                    {
                                        list = new List<string>();
                                    }

                                    list.Add(translatedParentName);
                                    mChoiceEdgeInfo[outEdge] = list;
                                    if (!mOutEdgeStrings.Contains(outEdge))
                                    {
                                        mOutEdgeStrings.Add(outEdge);
                                    }
                                }
                            }
                        }
                    }

                    break;
                case "counter":
                    foreach (JToken nodeData in NodeFile.Json["counter_info"]["out_edges"].Values())
                    {
                        mOutEdgeStrings.Add(nodeData.ToString());
                    }

                    break;
            }
        }