Esempio n. 1
0
        //---------------------------------------------------------------------------------------

        /// <summary>
        /// 헤더 정보 먼저 처리
        /// </summary>
        /// <param name="scriptData"></param>
        /// <param name="session"></param>
        static void ProcessHeaders(string scriptData, FSNScriptSequence sequence, FSNSession session)
        {
            var    strstream  = new System.IO.StringReader(scriptData);
            string line       = null;
            int    linenumber = 0;                        // 줄 번호

            while ((line = strstream.ReadLine()) != null) // 줄 단위로 읽는다.
            {
                linenumber++;
                FSNDebug.currentProcessingScriptLine = linenumber;                       // 디버깅 정보 설정

                if (line.Length > 0 && line.Substring(0, 1) == c_token_PreProcessor)     // 프리프로세서 기호에만 반응한다
                {
                    var commandAndParam = line.Substring(1).Split(c_whiteSpaceArray, 2); // 명령어 파라미터 구분
                    var command         = commandAndParam[0];
                    var paramStr        = commandAndParam.Length > 1? commandAndParam[1] : "";

                    // 아직까지는 header 커맨드밖에 없으므로 간단하게 if로만 체크한다. 더 늘어나면 리팩토링이 필요해질듯...
                    if (command == "헤더" || command == "header")
                    {
                        sequence.Header.FromAsset(paramStr.Trim());
                    }
                    else
                    {
                        Debug.LogErrorFormat("[FSNSequence] line {0} : unknown preprocessor command {1}", linenumber, command);
                    }
                }
            }

            // 읽어들인 헤더 정보를 바탕으로 플래그/변수 기본값들 세팅하기 (선언되어있지 않은 경우에만)

            foreach (var pair in sequence.Header.FlagDeclarations)                    // 플래그 선언
            {
                if (!session.FlagIsDeclared(pair.Key))                                // 아직 선언되지 않은 경우만 세팅
                {
                    bool value = string.IsNullOrEmpty(pair.Value)?
                                 false : FSNUtils.StringToValue <bool>(pair.Value);                 // 초기값까지 선언한 경우 값 해독, 아니면 기본값 false
                    session.SetFlagValue(pair.Key, value, true);
                }
            }

            foreach (var pair in sequence.Header.ValueDeclarations)                   // 값 선언
            {
                if (!session.ValueIsDeclared(pair.Key))                               // 아직 선언되지 않은 경우만 세팅
                {
                    float value = string.IsNullOrEmpty(pair.Value)?
                                  0 : FSNUtils.StringToValue <float>(pair.Value);                   // 초기값까지 선언한 경우 값 해독, 아니면 기본값 false
                    session.SetNumberValue(pair.Key, value, true);
                }
            }
        }
Esempio n. 2
0
        //=======================================================================

        /// <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;
        }
Esempio n. 4
0
    /// <summary>
    /// 스크립트 실행
    /// </summary>
    /// <param name="filepath"></param>
    /// <param name="session">실행 중에 사용할 Session. 지정하지 않을 경우 새 세션을 사용</param>
    /// <param name="snapshotIndex">불러오기 시에만 사용. 시작할 Snapshot Index를 지정</param>
    public void RunScript(string filepath, ExecuteType exeType = ExecuteType.NewStart, int snapshotIndex = 0)
    {
        FSNResourceCache.StartLoadingSession(FSNResourceCache.Category.Script);                     // 리소스 로딩 세션 시작

        if (exeType == ExecuteType.NewStart)                                                        // 새 세션을 열어야하는 경우 미리 세션 생성하기 (새 게임)
        {
            m_seqEngine.PrepareNewSession();
        }

        FSNScriptSequence scriptSeq = FSNScriptSequence.Parser.FromAsset(filepath, m_seqEngine.CurrentSession);                 // 스크립트 해석

        // TODO : header 적용, 여기에 코드를 삽입하는 것이 맞는지는 잘 모르겠음. 리팩토링이 필요할수도.

        // 인게임 세팅

        var stchain = new FSNInGameSetting.Chain(FSNInGameSetting.DefaultInGameSetting);                // 디폴트 속성을 베이스로 chain 만들기

        foreach (var pair in scriptSeq.Header.InGameSettings)
        {
            var alias = FSNInGameSetting.ConvertPropertyNameAlias(pair.Key);
            stchain.SetPropertyByString(alias, pair.Value);
        }
        m_inGameSetting = stchain.Freeze();                                                                                                             // 속성값 고정, 현재 엔진의 디폴트 속성을 덮어씌운다.
        //

        var sshotSeq = FSNSnapshotSequence.Builder.BuildSnapshotSequence(scriptSeq);                // Snapshot 시퀀스 생성

        FSNResourceCache.EndLoadingSession();                                                       // 리소스 로딩 세션 종료

        bool overwriteScriptInfoToSession = exeType != ExecuteType.LoadFromSession;                 // 불러오기한 경우가 아니면 스크립트 정보를 세션에 덮어써야한다.

        m_seqEngine.StartSnapshotSequence(sshotSeq, overwriteScriptInfoToSession, snapshotIndex);   // 실행


        ControlSystem.ScriptLoadComplete();                                                                                                             // 스크립트 로딩 완료 이벤트
    }
Esempio n. 5
0
        //---------------------------------------------------------------------------------------
        /// <summary>
        /// 헤더 정보 먼저 처리
        /// </summary>
        /// <param name="scriptData"></param>
        /// <param name="session"></param>
        static void ProcessHeaders(string scriptData, FSNScriptSequence sequence, FSNSession session)
        {
            var strstream	= new System.IO.StringReader(scriptData);
            string line		= null;
            int linenumber	= 0;    // 줄 번호

            while ((line = strstream.ReadLine()) != null)               // 줄 단위로 읽는다.
            {
                linenumber++;
                FSNDebug.currentProcessingScriptLine    = linenumber;   // 디버깅 정보 설정

                if (line.Length > 0 && line.Substring(0,1) == c_token_PreProcessor)		// 프리프로세서 기호에만 반응한다
                {
                    var commandAndParam = line.Substring(1).Split(c_whiteSpaceArray, 2);            // 명령어 파라미터 구분
                    var command         = commandAndParam[0];
                    var paramStr        = commandAndParam.Length > 1? commandAndParam[1] : "";

                    // 아직까지는 header 커맨드밖에 없으므로 간단하게 if로만 체크한다. 더 늘어나면 리팩토링이 필요해질듯...
                    if (command == "헤더" || command == "header")
                    {
                        sequence.Header.FromAsset(paramStr.Trim());
                    }
                    else
                    {
                        Debug.LogErrorFormat("[FSNSequence] line {0} : unknown preprocessor command {1}", linenumber, command);
                    }
                }
            }

            // 읽어들인 헤더 정보를 바탕으로 플래그/변수 기본값들 세팅하기 (선언되어있지 않은 경우에만)

            foreach (var pair in sequence.Header.FlagDeclarations)        // 플래그 선언
            {
                if (!session.FlagIsDeclared(pair.Key))                          // 아직 선언되지 않은 경우만 세팅
                {
                    bool value  = string.IsNullOrEmpty(pair.Value)?
                        false : FSNUtils.StringToValue<bool>(pair.Value);   // 초기값까지 선언한 경우 값 해독, 아니면 기본값 false
                    session.SetFlagValue(pair.Key, value, true);
                }
            }

            foreach (var pair in sequence.Header.ValueDeclarations)       // 값 선언
            {
                if (!session.ValueIsDeclared(pair.Key))                         // 아직 선언되지 않은 경우만 세팅
                {
                    float value = string.IsNullOrEmpty(pair.Value)?
                        0 : FSNUtils.StringToValue<float>(pair.Value);      // 초기값까지 선언한 경우 값 해독, 아니면 기본값 false
                    session.SetNumberValue(pair.Key, value, true);
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 문자열으로 스크립트 파싱
        /// </summary>
        /// <param name="scriptData"></param>
        /// <returns></returns>
        public static FSNScriptSequence FromString(string scriptData, FSNSession session)
        {
            // 디버깅 세션 세팅
            FSNDebug.currentRuntimeStage = FSNDebug.RuntimeStage.Compile;

            var sequence				= new FSNScriptSequence();
            sequence.OriginalScriptPath	= "(string)";
            sequence.ScriptHashKey		= GenerateHashKeyFromScript(scriptData);    // 해시키 생성해두기 (세이브 파일과 스크립트 파일 버전 체크용)

            // ===== FIRST PASS : 헤더 파일 먼저 해석 ==================================

            ProcessHeaders(scriptData, sequence, session);

            // ===== SECOND PASS : 나머지 스크립트 요소들 해석 =========================
            var strstream               = new System.IO.StringReader(scriptData);

            // 스크립트 해석 상태값들
            CommandGenerateProtocol protocol	= new CommandGenerateProtocol();

            // flags
            Segments.Period	periodSeg			= null;				// Period 세그먼트. 먼저 만들어놓고 있다가 적당한 때에 삽입한다. (스크립트와 실제 세그먼트 순서가 다르기 때문)
            bool			textMultilineMode	= false;			// 텍스트 여러줄 처리중인지 (//)
            string			multilineText		= "";				// 멀티라인 모드에서, 텍스트 처리중일 때
            //

            // ** 스크립트 로드 후 첫번째 스냅샷에서 다시 이전으로 돌아가는 것은 불가능하므로, 맨 처음에 oneway 컨트롤 세그먼트를 추가해준다
            var onewayAtFirstSeg			= new Segments.Control();
            onewayAtFirstSeg.controlType	= Segments.Control.ControlType.Oneway;
            var onewaySegInfo				= new FSNScriptSequence.Parser.GeneratedSegmentInfo()
            {
                newSeg	= onewayAtFirstSeg
            };
            protocol.PushSegment(onewaySegInfo);
            //

            string line		= null;
            int linenumber	= 0;	// 줄 번호
            while ((line = strstream.ReadLine()) != null)				// 줄 단위로 읽는다.
            {
                line		= sequence.Header.Macros.Replace(line);		// 정적 매크로 치환

                linenumber++;
                FSNDebug.currentProcessingScriptLine	= linenumber;	// 디버깅 정보 설정

                if (!textMultilineMode && line.Length == 0)				// * 빈 줄은 스루. 단 여러줄 텍스트 모드일 경우 빈 줄에서는 여러줄 모드를 끝내게 한다.
                    continue;

                if (line.EndsWith(c_token_LineConcat))					// * 여러줄 텍스트로 지정된 경우, 자동으로 여러줄 모드로. 해당 라인 붙이기
                {
                    textMultilineMode	= true;

                    if (multilineText.Length > 0)						// 이미 쌓여있는 텍스트가 있다면 공백 추가
                        multilineText	+= "\n";
                    multilineText		+= line.Substring(0, line.Length - c_token_LineConcat.Length);
                }
                else
                {
                    var pretoken		= line.Length > 0? line.Substring(0, 1) : "";
                    switch (pretoken)										// 앞쪽 토큰으로 명령 구분
                    {
                        case c_token_Comment:								// * 주석
                            // 스루. 뭐 왜 뭐 주석인데 뭐
                            break;

                        case c_token_PreProcessor:							// * 전처리 구문
                            // 프리프로세서는 첫번째 패스에서 처리함.
                            break;

                        case c_token_Command:								// * 명령
                            {
                                var commandAndParam	= line.Substring(1).Split(c_whiteSpaceArray, 2);			// 명령어 파라미터 구분
                                var command			= commandAndParam[0];
                                var paramStr		= commandAndParam.Length > 1? commandAndParam[1] : "";

                                CommandSegmentGenerateFunc genfunc = null;
                                s_aliasToSegFunction.TryGetValue(command, out genfunc);
                                if(genfunc == null)																// 등록된 명령어인지 체크
                                {
                                    Debug.LogError("Unknown command : " + command);
                                }
                                else
                                {
                                    protocol.parameters	= ParseParameters(paramStr);
                                    genfunc(protocol);
                                }
                            }
                            break;

                        case c_token_HardLabel:								// * hard label
                            {
                                var labelSeg		= new Segments.Label();
                                labelSeg.labelName	= line.Substring(1);
                                labelSeg.labelType	= Segments.Label.LabelType.Hard;

                                var segInfo				= new GeneratedSegmentInfo();
                                segInfo.newSeg			= labelSeg;
                                segInfo.usePrevPeriod	= true;				// Label 전에 period로 다 출력해야함
                                segInfo.selfPeriod		= false;
                                protocol.PushSegment(segInfo);
                            }
                            break;

                        case c_token_SoftLabel:								// * soft label
                            {
                                var labelSeg		= new Segments.Label();
                                labelSeg.labelName	= line.Substring(1);
                                labelSeg.labelType	= Segments.Label.LabelType.Soft;

                                var segInfo				= new GeneratedSegmentInfo();
                                segInfo.newSeg			= labelSeg;
                                segInfo.usePrevPeriod	= true;				// Label 전에 period로 다 출력해야함
                                segInfo.selfPeriod		= false;
                                protocol.PushSegment(segInfo);
                            }
                            break;

                        case c_token_Period:								// * period
                            if (line.Length == 1)							// . 한글자일 때 - 일반 period
                            {
                                if(periodSeg != null)						// * 이미 period 명령어가 대기중일 때, 기존 명령어를 먼저 처리한다
                                {
                                    sequence.m_segments.Add(periodSeg);
                                }
                                periodSeg	= new Segments.Period();
                            }
                            else if(line.Length == 2 && line[1].ToString() == c_token_Period)	// .. 으로 두 글자일 때 - 연결 period, 만약 period가 이전에 등장했다면 연결으로 변경
                            {
                                Segments.Period lastPeriodseg;

                                if(periodSeg != null)											// 처리 안된 period가 있을 경우, 이것을 chaining으로 변경해준다
                                {
                                    lastPeriodseg	= periodSeg;
                                }
                                else if((lastPeriodseg = sequence.m_segments[sequence.m_segments.Count - 1] as Segments.Period)
                                                .type == Segment.Type.Period)					// 아닐 경우, 가장 마지막으로 추가된 세그먼트가 period를 chaining으로 변경한다
                                {
                                    //
                                }
                                else
                                {																// 그도 아닐 경우 새로 period 생성
                                    periodSeg		= new Segments.Period();
                                    lastPeriodseg	= periodSeg;
                                }

                                lastPeriodseg.isChaining	= true;								// 선택한 period에 chaining속성 부여
                            }
                            else
                            {
                                Debug.LogError("invalid command... is it a period command?");
                            }
                            break;

                        case c_token_ForceText:
                        default:											// * 아무 토큰도 없음 : 텍스트
                            {
                                if (line.Length > 0 && line[0].ToString() == c_token_ForceText)	// 만약 강제 텍스트 토큰 (~) 이 붙어있었다면, 해당 토큰 제거
                                    line	= line.Substring(1);

                                multilineText		+= multilineText.Length > 0? "\n" + line : line;
                                var textSeg			= new Segments.Text();
                                textSeg.text		= multilineText;
                                textSeg.textType	= Segments.Text.TextType.Normal;

                                multilineText		= "";	// 멀티라인 텍스트 보관되어있던 것을 초기화
                                textMultilineMode	= false;

                                var segInfo				= new GeneratedSegmentInfo();
                                segInfo.newSeg			= textSeg;
                                segInfo.usePrevPeriod	= true;	// 출력 명령어임
                                segInfo.selfPeriod		= true;	// 스스로 period를 포함함
                                protocol.PushSegment(segInfo);
                            }
                            break;
                    }

                    GeneratedSegmentInfo newSegInfo	= null;
                    while ((newSegInfo = protocol.PullSegment()) != null)	// 새로 생성된 시퀀스 모두 처리
                    {
                        if (newSegInfo.usePrevPeriod && periodSeg != null)	// * 선행 period를 먼저 처리해야하는 상황
                        {
                            periodSeg.scriptLineNumber		= linenumber;	// 줄번호 기록?
                            sequence.m_segments.Add(periodSeg);
                            periodSeg	= null;
                        }

                        newSegInfo.newSeg.scriptLineNumber	= linenumber;	// 줄번호 기록
                        sequence.m_segments.Add(newSegInfo.newSeg);			// 시퀀스 추가
                        if (newSegInfo.newSeg.type == Segment.Type.Label)	// 라벨일 경우 등록
                            sequence.RegisterLabelSegment();

                        if(newSegInfo.selfPeriod)							// * 방금 추가된 세그먼트가 period를 포함하는 개념이라면, period 대기시켜놓기
                        {
                            periodSeg	= new Segments.Period();
                        }
                    }
                }
            }

            if(periodSeg != null)											// 끝날 때까지 처리되지 않은 period가 있다면 여기서 추가해준다
            {
                periodSeg.scriptLineNumber		= linenumber;				// 줄번호 기록?
                sequence.m_segments.Add(periodSeg);
                periodSeg = null;
            }

            // 디버깅 세션 세팅
            FSNDebug.currentRuntimeStage = FSNDebug.RuntimeStage.Runtime;

            return sequence;
        }
Esempio n. 7
0
        /// <summary>
        /// 문자열으로 스크립트 파싱
        /// </summary>
        /// <param name="scriptData"></param>
        /// <returns></returns>
        public static FSNScriptSequence FromString(string scriptData, FSNSession session)
        {
            // 디버깅 세션 세팅
            FSNDebug.currentRuntimeStage = FSNDebug.RuntimeStage.Compile;

            var sequence = new FSNScriptSequence();

            sequence.OriginalScriptPath = "(string)";
            sequence.ScriptHashKey      = GenerateHashKeyFromScript(scriptData);                    // 해시키 생성해두기 (세이브 파일과 스크립트 파일 버전 체크용)

            // ===== FIRST PASS : 헤더 파일 먼저 해석 ==================================

            ProcessHeaders(scriptData, sequence, session);


            // ===== SECOND PASS : 나머지 스크립트 요소들 해석 =========================
            var strstream = new System.IO.StringReader(scriptData);

            // 스크립트 해석 상태값들
            CommandGenerateProtocol protocol = new CommandGenerateProtocol();

            // flags
            Segments.Period periodSeg         = null;                                                   // Period 세그먼트. 먼저 만들어놓고 있다가 적당한 때에 삽입한다. (스크립트와 실제 세그먼트 순서가 다르기 때문)
            bool            textMultilineMode = false;                                                  // 텍스트 여러줄 처리중인지 (//)
            string          multilineText     = "";                                                     // 멀티라인 모드에서, 텍스트 처리중일 때
            //

            // ** 스크립트 로드 후 첫번째 스냅샷에서 다시 이전으로 돌아가는 것은 불가능하므로, 맨 처음에 oneway 컨트롤 세그먼트를 추가해준다
            var onewayAtFirstSeg = new Segments.Control();

            onewayAtFirstSeg.controlType = Segments.Control.ControlType.Oneway;
            var onewaySegInfo = new FSNScriptSequence.Parser.GeneratedSegmentInfo()
            {
                newSeg = onewayAtFirstSeg
            };

            protocol.PushSegment(onewaySegInfo);
            //

            string line       = null;
            int    linenumber = 0;                           // 줄 번호

            while ((line = strstream.ReadLine()) != null)    // 줄 단위로 읽는다.
            {
                line = sequence.Header.Macros.Replace(line); // 정적 매크로 치환

                linenumber++;
                FSNDebug.currentProcessingScriptLine = linenumber;                      // 디버깅 정보 설정

                if (!textMultilineMode && line.Length == 0)                             // * 빈 줄은 스루. 단 여러줄 텍스트 모드일 경우 빈 줄에서는 여러줄 모드를 끝내게 한다.
                {
                    continue;
                }

                if (line.EndsWith(c_token_LineConcat))                                                  // * 여러줄 텍스트로 지정된 경우, 자동으로 여러줄 모드로. 해당 라인 붙이기
                {
                    textMultilineMode = true;

                    if (multilineText.Length > 0)                                                               // 이미 쌓여있는 텍스트가 있다면 공백 추가
                    {
                        multilineText += "\n";
                    }
                    multilineText += line.Substring(0, line.Length - c_token_LineConcat.Length);
                }
                else
                {
                    var pretoken = line.Length > 0? line.Substring(0, 1) : "";
                    switch (pretoken)                                                                                           // 앞쪽 토큰으로 명령 구분
                    {
                    case c_token_Comment:                                                                                       // * 주석
                        // 스루. 뭐 왜 뭐 주석인데 뭐
                        break;

                    case c_token_PreProcessor:                                                                                  // * 전처리 구문
                        // 프리프로세서는 첫번째 패스에서 처리함.
                        break;

                    case c_token_Command:                                                                                       // * 명령
                    {
                        var commandAndParam = line.Substring(1).Split(c_whiteSpaceArray, 2);                                    // 명령어 파라미터 구분
                        var command         = commandAndParam[0];
                        var paramStr        = commandAndParam.Length > 1? commandAndParam[1] : "";

                        CommandSegmentGenerateFunc genfunc = null;
                        s_aliasToSegFunction.TryGetValue(command, out genfunc);
                        if (genfunc == null)                                                                                                                                                                    // 등록된 명령어인지 체크
                        {
                            Debug.LogError("Unknown command : " + command);
                        }
                        else
                        {
                            protocol.parameters = ParseParameters(paramStr);
                            genfunc(protocol);
                        }
                    }
                    break;

                    case c_token_HardLabel:                                                                                     // * hard label
                    {
                        var labelSeg = new Segments.Label();
                        labelSeg.labelName = line.Substring(1);
                        labelSeg.labelType = Segments.Label.LabelType.Hard;

                        var segInfo = new GeneratedSegmentInfo();
                        segInfo.newSeg        = labelSeg;
                        segInfo.usePrevPeriod = true;                                                                   // Label 전에 period로 다 출력해야함
                        segInfo.selfPeriod    = false;
                        protocol.PushSegment(segInfo);
                    }
                    break;

                    case c_token_SoftLabel:                                                                                     // * soft label
                    {
                        var labelSeg = new Segments.Label();
                        labelSeg.labelName = line.Substring(1);
                        labelSeg.labelType = Segments.Label.LabelType.Soft;

                        var segInfo = new GeneratedSegmentInfo();
                        segInfo.newSeg        = labelSeg;
                        segInfo.usePrevPeriod = true;                                                                   // Label 전에 period로 다 출력해야함
                        segInfo.selfPeriod    = false;
                        protocol.PushSegment(segInfo);
                    }
                    break;

                    case c_token_Period:                                                                                        // * period
                        if (line.Length == 1)                                                                                   // . 한글자일 때 - 일반 period
                        {
                            if (periodSeg != null)                                                                              // * 이미 period 명령어가 대기중일 때, 기존 명령어를 먼저 처리한다
                            {
                                sequence.m_segments.Add(periodSeg);
                            }
                            periodSeg = new Segments.Period();
                        }
                        else if (line.Length == 2 && line[1].ToString() == c_token_Period)                                      // .. 으로 두 글자일 때 - 연결 period, 만약 period가 이전에 등장했다면 연결으로 변경
                        {
                            Segments.Period lastPeriodseg;

                            if (periodSeg != null)                                                                                                                      // 처리 안된 period가 있을 경우, 이것을 chaining으로 변경해준다
                            {
                                lastPeriodseg = periodSeg;
                            }
                            else if ((lastPeriodseg = sequence.m_segments[sequence.m_segments.Count - 1] as Segments.Period)
                                     .type == Segment.Type.Period)                                                                                              // 아닐 경우, 가장 마지막으로 추가된 세그먼트가 period를 chaining으로 변경한다
                            {
                                //
                            }
                            else
                            {                                                                                                                                                                   // 그도 아닐 경우 새로 period 생성
                                periodSeg     = new Segments.Period();
                                lastPeriodseg = periodSeg;
                            }

                            lastPeriodseg.isChaining = true;                                                                                                    // 선택한 period에 chaining속성 부여
                        }
                        else
                        {
                            Debug.LogError("invalid command... is it a period command?");
                        }
                        break;

                    case c_token_ForceText:
                    default:                                                                                                    // * 아무 토큰도 없음 : 텍스트
                    {
                        if (line.Length > 0 && line[0].ToString() == c_token_ForceText)                                         // 만약 강제 텍스트 토큰 (~) 이 붙어있었다면, 해당 토큰 제거
                        {
                            line = line.Substring(1);
                        }

                        multilineText += multilineText.Length > 0? "\n" + line : line;
                        var textSeg = new Segments.Text();
                        textSeg.text     = multilineText;
                        textSeg.textType = Segments.Text.TextType.Normal;

                        multilineText     = "";                                                 // 멀티라인 텍스트 보관되어있던 것을 초기화
                        textMultilineMode = false;

                        var segInfo = new GeneratedSegmentInfo();
                        segInfo.newSeg        = textSeg;
                        segInfo.usePrevPeriod = true;                                           // 출력 명령어임
                        segInfo.selfPeriod    = true;                                           // 스스로 period를 포함함
                        protocol.PushSegment(segInfo);
                    }
                    break;
                    }

                    GeneratedSegmentInfo newSegInfo = null;
                    while ((newSegInfo = protocol.PullSegment()) != null)                       // 새로 생성된 시퀀스 모두 처리
                    {
                        if (newSegInfo.usePrevPeriod && periodSeg != null)                      // * 선행 period를 먼저 처리해야하는 상황
                        {
                            periodSeg.scriptLineNumber = linenumber;                            // 줄번호 기록?
                            sequence.m_segments.Add(periodSeg);
                            periodSeg = null;
                        }

                        newSegInfo.newSeg.scriptLineNumber = linenumber;                                // 줄번호 기록
                        sequence.m_segments.Add(newSegInfo.newSeg);                                     // 시퀀스 추가
                        if (newSegInfo.newSeg.type == Segment.Type.Label)                               // 라벨일 경우 등록
                        {
                            sequence.RegisterLabelSegment();
                        }

                        if (newSegInfo.selfPeriod)                                                                              // * 방금 추가된 세그먼트가 period를 포함하는 개념이라면, period 대기시켜놓기
                        {
                            periodSeg = new Segments.Period();
                        }
                    }
                }
            }

            if (periodSeg != null)                                                                              // 끝날 때까지 처리되지 않은 period가 있다면 여기서 추가해준다
            {
                periodSeg.scriptLineNumber = linenumber;                                                        // 줄번호 기록?
                sequence.m_segments.Add(periodSeg);
                periodSeg = null;
            }

            // 디버깅 세션 세팅
            FSNDebug.currentRuntimeStage = FSNDebug.RuntimeStage.Runtime;

            return(sequence);
        }
 /// <summary>
 /// 오브젝트가 존재하는 모든 모듈에 콜 보내기
 /// </summary>
 /// <param name="segment"></param>
 /// <param name="setting"></param>
 public void AddAllModuleCall(FSNScriptSequence.Segment segment, IInGameSetting setting)
 {
     foreach (var callList in m_moduleCallTable.Values)
     {
         callList.Add(new FSNProcessModuleCallParam() { segment = segment, setting = setting });
     }
 }
            /// <summary>
            /// 콜 추가
            /// </summary>
            /// <param name="module"></param>
            /// <param name="segment"></param>
            public void AddCall(IFSNProcessModule module, FSNScriptSequence.Segment segment, IInGameSetting setting)
            {
                if(!m_moduleCallTable.ContainsKey(module))
                    m_moduleCallTable[module]	= new List<FSNProcessModuleCallParam>();

                m_moduleCallTable[module].Add(new FSNProcessModuleCallParam() { segment = segment, setting = setting });
            }