static public int Init(IntPtr l) { try { StorySystem.StoryInstance self = (StorySystem.StoryInstance)checkSelf(l); Dsl.DslInfo a1; checkType(l, 2, out a1); var ret = self.Init(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
private void Load(Dsl.DslFile dataFile, int sceneId, string _namespace, string resourceName) { lock (m_Lock) { Dictionary <string, StoryInstance> existStoryInstances; if (!m_StoryInstancePool.TryGetValue(resourceName, out existStoryInstances)) { List <Dsl.ISyntaxComponent> cmdOrValList = new List <Dsl.ISyntaxComponent>(); existStoryInstances = new Dictionary <string, StoryInstance>(); m_StoryInstancePool.Add(resourceName, existStoryInstances); for (int i = 0; i < dataFile.DslInfos.Count; i++) { var comp = dataFile.DslInfos[i]; string id = comp.GetId(); if (id == "story" || id == "script") { var funcData = comp as Dsl.FunctionData; if (null != funcData && funcData.IsHighOrder) { Dsl.FunctionData callData = funcData.LowerOrderFunction; if (null != callData && callData.HaveParam()) { StoryInstance instance = new StoryInstance(); if (!string.IsNullOrEmpty(_namespace)) { instance.Namespace = _namespace; } instance.Init(funcData); string storyId; if (string.IsNullOrEmpty(_namespace)) { storyId = instance.StoryId; } else { storyId = string.Format("{0}:{1}", _namespace, instance.StoryId); instance.StoryId = storyId; } if (!existStoryInstances.ContainsKey(storyId)) { existStoryInstances.Add(storyId, instance); } else { existStoryInstances[storyId] = instance; } LogSystem.Info("ParseStory {0} {1}", storyId, sceneId); } } } else if (id == "command" || id == "value") { cmdOrValList.Add(comp); } else { LogSystem.Error("[LoadStory] Unknown story keyword '{0}'", id); } } CustomCommandValueParser.FirstParse(cmdOrValList); CustomCommandValueParser.FinalParse(cmdOrValList); } Dictionary <string, StoryInstance> storyInstances; if (!m_StoryInstances.TryGetValue(sceneId, out storyInstances)) { storyInstances = new Dictionary <string, StoryInstance>(existStoryInstances); m_StoryInstances.Add(sceneId, storyInstances); } else { foreach (var pair in existStoryInstances) { if (!storyInstances.ContainsKey(pair.Key)) { storyInstances.Add(pair.Key, pair.Value); } else { storyInstances[pair.Key] = pair.Value; } } } } }
private void Load(ScriptableData.ScriptableDataFile dataFile, int sceneId) { lock (m_Lock) { #if false for (int i = 0; i < dataFile.ScriptableDatas.Count; i++) { if (dataFile.ScriptableDatas[i].GetId() == "story" || dataFile.ScriptableDatas[i].GetId() == "script") { ScriptableData.FunctionData funcData = dataFile.ScriptableDatas[i].First; if (null != funcData) { ScriptableData.CallData callData = funcData.Call; if (null != callData && callData.HaveParam()) { int storyId = int.Parse(callData.GetParamId(0)); int id = GenId(storyId, sceneId); if (!m_StoryInstances.ContainsKey(id)) { StoryInstance instance = new StoryInstance(); instance.Init(dataFile.ScriptableDatas[i]); m_StoryInstances.Add(id, instance); LogSystem.Debug("ParseStory {0}", id); } else { //repeated story config. } } } } } #else int id = GenId(1, sceneId); if (!m_StoryInstances.ContainsKey(id)) { StoryInstance instance = new StoryInstance(); instance.Init(dataFile); m_StoryInstances.Add(id, instance); } #endif /* * foreach (ScriptableData.ScriptableDataInfo info in dataFile.ScriptableDatas) { * if (info.GetId() == "story" || info.GetId() == "script") { * ScriptableData.FunctionData funcData = info.First; * if (null != funcData) { * ScriptableData.CallData callData = funcData.Call; * if (null != callData && callData.HaveParam()) { * int storyId = int.Parse(callData.GetParamId(0)); * int id = GenId(storyId, sceneId); * if (!m_StoryInstances.ContainsKey(id)) { * StoryInstance instance = new StoryInstance(); * instance.Init(info); * m_StoryInstances.Add(id, instance); * * LogSystem.Debug("ParseStory {0}", id); * } else { * //repeated story config. * } * } * } * } * }*/ } }
private void Load(Dsl.DslFile dataFile, int sceneId, string _namespace, string resourceName) { lock (m_Lock) { Dictionary<string, StoryInstance> existStoryInstances; if (!m_StoryInstancePool.TryGetValue(resourceName, out existStoryInstances)) { existStoryInstances = new Dictionary<string, StoryInstance>(); m_StoryInstancePool.Add(resourceName, existStoryInstances); for (int i = 0; i < dataFile.DslInfos.Count; i++) { Dsl.DslInfo dslInfo = dataFile.DslInfos[i]; string id = dslInfo.GetId(); if (id == "story" || id == "script") { Dsl.FunctionData funcData = dslInfo.First; if (null != funcData) { Dsl.CallData callData = funcData.Call; if (null != callData && callData.HaveParam()) { StoryInstance instance = new StoryInstance(); if (!string.IsNullOrEmpty(_namespace)) { instance.Namespace = _namespace; } instance.Init(dslInfo); string storyId; if (string.IsNullOrEmpty(_namespace)) { storyId = instance.StoryId; } else { storyId = string.Format("{0}:{1}", _namespace, instance.StoryId); instance.StoryId = storyId; } if (!existStoryInstances.ContainsKey(storyId)) { existStoryInstances.Add(storyId, instance); } else { existStoryInstances[storyId] = instance; } LogSystem.Info("ParseStory {0} {1}", storyId, sceneId); } } } else if (id == "command" || id == "value") { CustomCommandValueParser.FirstParse(dslInfo); CustomCommandValueParser.FinalParse(dslInfo); } else { LogSystem.Error("Unknown story keyword '{0}'", id); } } } Dictionary<string, StoryInstance> storyInstances; if (!m_StoryInstances.TryGetValue(sceneId, out storyInstances)) { storyInstances = new Dictionary<string, StoryInstance>(existStoryInstances); m_StoryInstances.Add(sceneId, storyInstances); } else { foreach (var pair in existStoryInstances) { if (!storyInstances.ContainsKey(pair.Key)) { storyInstances.Add(pair.Key, pair.Value); } else { storyInstances[pair.Key] = pair.Value; } } } } }