/// <summary> /// 분기 혹은 점프 후, 이전 레이어 상태를 읽어서 오브젝트가 있는 Module들을 내부적으로 활성화해준다. /// 객체가 있는데도 모듈 콜이 누락되는 경우를 막기 위함 /// </summary> public void CatchupPreviousLayerState(FSNSnapshot prevSnapshot) { var layerIDs = prevSnapshot.AllLayerIDs; int count = layerIDs.Length; for (int i = 0; i < count; i++) { var module = FSNEngine.Instance.GetModuleByLayerID(layerIDs[i]) as IFSNProcessModule; if (module != null && !m_moduleCallTable.ContainsKey(module)) { m_moduleCallTable[module] = new List <FSNProcessModuleCallParam>(); } } }
/// <summary> /// 쌓인 콜 모두 실행 후 Clear /// </summary> public void ProcessCall(FSNSnapshot prevSnapshot, FSNSnapshot curSnapshot) { foreach (var pair in m_moduleCallTable) { var module = pair.Key; var prevLayer = prevSnapshot.GetLayer(module.LayerID) ?? FSNSnapshot.Layer.Empty; var callInfo = pair.Value; var newLayer = module.GenerateNextLayerImage(prevLayer, callInfo.ToArray()); curSnapshot.SetLayer(module.LayerID, newLayer); } ClearCall(); }
/// <summary> /// 해당 방향으로 진행하여 현재 상태 바꾸기. 덤으로 해당 snapshot에 지정된 함수들도 호출한다. /// </summary> /// <param name="dir"></param> /// <returns>진행 가능할 경우, 해당 방향의 snapshot. 아니면 null</returns> public FSNSnapshot TravelTo(FSNInGameSetting.FlowDirection dir) { FSNSnapshot next = null; var linked = GetLinkedToDir(dir); if (linked != null) // 해당 방향으로 진행 가능한 경우만 변경 { m_current = linked; next = linked.snapshot; ExecuteSnapshotFunctions(); // 함수 실행 if (m_current.Type == FlowType.Load) // 스크립트 로딩 이벤트 { ScriptLoadRequested(m_current.Parameter as string); } } return(next); }
//======================================================================= /// <summary> /// FSNSequence를 해석하여 FSNSnapshotSequence를 만든다. /// </summary> /// <param name="sequence"></param> /// <returns></returns> public static FSNSnapshotSequence BuildSnapshotSequence(FSNScriptSequence sequence) { // 디버깅 정보 설정 FSNDebug.currentRuntimeStage = FSNDebug.RuntimeStage.SnapshotBuild; FSNDebug.currentProcessingScript = sequence.OriginalScriptPath; FSNSnapshotSequence snapshotSeq = new FSNSnapshotSequence(); State builderState = new State(); snapshotSeq.OriginalScriptPath = sequence.OriginalScriptPath; // 스크립트 경로 보관 snapshotSeq.ScriptHashKey = sequence.ScriptHashKey; // ScriptHashKey 복사해오기 snapshotSeq.ScriptHeader = sequence.Header; // State 초기 세팅 builderState.sequence = sequence; builderState.segIndex = 0; builderState.settings = new FSNInGameSetting.Chain(FSNEngine.Instance.DefaultInGameSetting); // 시작 Snapshot 만들기 FSNSnapshot startSnapshot = new FSNSnapshot(); startSnapshot.NonstopToForward = true; startSnapshot.InGameSetting = builderState.settings; Segment startSegment = new Segment(); startSegment.Type = FlowType.Normal; startSegment.snapshot = startSnapshot; snapshotSeq.Add(startSegment); // 빌드 시작 ProcessSnapshotBuild(builderState, snapshotSeq, 0); // 디버깅 정보 설정 FSNDebug.currentRuntimeStage = FSNDebug.RuntimeStage.Runtime; return(snapshotSeq); }
//======================================================================= /// <summary> /// FSNSequence를 해석하여 FSNSnapshotSequence를 만든다. /// </summary> /// <param name="sequence"></param> /// <returns></returns> public static FSNSnapshotSequence BuildSnapshotSequence(FSNScriptSequence sequence) { // 디버깅 정보 설정 FSNDebug.currentRuntimeStage = FSNDebug.RuntimeStage.SnapshotBuild; FSNDebug.currentProcessingScript = sequence.OriginalScriptPath; FSNSnapshotSequence snapshotSeq = new FSNSnapshotSequence(); State builderState = new State(); snapshotSeq.OriginalScriptPath = sequence.OriginalScriptPath; // 스크립트 경로 보관 snapshotSeq.ScriptHashKey = sequence.ScriptHashKey; // ScriptHashKey 복사해오기 snapshotSeq.ScriptHeader = sequence.Header; // State 초기 세팅 builderState.sequence = sequence; builderState.segIndex = 0; builderState.settings = new FSNInGameSetting.Chain(FSNEngine.Instance.DefaultInGameSetting); // 시작 Snapshot 만들기 FSNSnapshot startSnapshot = new FSNSnapshot(); startSnapshot.NonstopToForward = true; startSnapshot.InGameSetting = builderState.settings; Segment startSegment = new Segment(); startSegment.Type = FlowType.Normal; startSegment.snapshot = startSnapshot; snapshotSeq.Add(startSegment); // 빌드 시작 ProcessSnapshotBuild(builderState, snapshotSeq, 0); // 디버깅 정보 설정 FSNDebug.currentRuntimeStage = FSNDebug.RuntimeStage.Runtime; return snapshotSeq; }
/// <summary> /// 분기 혹은 점프 후, 이전 레이어 상태를 읽어서 오브젝트가 있는 Module들을 내부적으로 활성화해준다. /// 객체가 있는데도 모듈 콜이 누락되는 경우를 막기 위함 /// </summary> public void CatchupPreviousLayerState(FSNSnapshot prevSnapshot) { var layerIDs = prevSnapshot.AllLayerIDs; int count = layerIDs.Length; for (int i = 0; i < count; i++) { var module = FSNEngine.Instance.GetModuleByLayerID(layerIDs[i]) as IFSNProcessModule; if(module != null && !m_moduleCallTable.ContainsKey(module)) m_moduleCallTable[module] = new List<FSNProcessModuleCallParam>(); } }
/// <summary> /// 쌓인 콜 모두 실행 후 Clear /// </summary> public void ProcessCall(FSNSnapshot prevSnapshot, FSNSnapshot curSnapshot) { foreach(var pair in m_moduleCallTable) { var module = pair.Key; var prevLayer = prevSnapshot.GetLayer(module.LayerID) ?? FSNSnapshot.Layer.Empty; var callInfo = pair.Value; var newLayer = module.GenerateNextLayerImage(prevLayer, callInfo.ToArray()); curSnapshot.SetLayer(module.LayerID, newLayer); } ClearCall(); }
/// <summary> /// 새 Segment/Snapshot 세팅 (숏컷) /// </summary> /// <param name="newSeg"></param> /// <param name="newSnapshot"></param> static void NewSnapshot(out Segment newSeg, out FSNSnapshot newSnapshot) { newSnapshot = new FSNSnapshot(); newSeg = new Segment(); newSeg.snapshot = newSnapshot; }
/// <summary> /// 새 Segment/Snapshot 세팅 (숏컷) /// </summary> /// <param name="newSeg"></param> /// <param name="newSnapshot"></param> static void NewSnapshot(out Segment newSeg, out FSNSnapshot newSnapshot) { newSnapshot = new FSNSnapshot(); newSeg = new Segment(); newSeg.snapshot = newSnapshot; }