static void RemoveFromLookupDict(string name, FSNSnapshot.Layer layer)
    {
        var nameDict = layer.GetCustomData(c_customDataName) as Dictionary <string, int>;

        if (nameDict == null)
        {
            nameDict = new Dictionary <string, int>();
            layer.SetCustomData(c_customDataName, nameDict);
        }

        nameDict.Remove(name);
    }
Esempio n. 2
0
    public override void ProcessCustomElementCommand(Segments.Sound segment, FSNSnapshot.Layer layer)
    {
        //base.ProcessCustomElementCommand(segment, layer);

        // One-Shot 사운드에 대한 처리

        // 레이어에 one-shot 사운드 리스트가 없다면 생성
        var oneshotSounds = layer.GetCustomData(c_oneshotSoundData) as List <Segments.Sound>;

        if (oneshotSounds == null)
        {
            oneshotSounds = new List <Segments.Sound>();
            layer.SetCustomData(c_oneshotSoundData, oneshotSounds);
        }

        oneshotSounds.Add(segment);                                                     // 세그먼트채로 집어넣는다.
    }
    static bool AddToLookupDict(string name, ElemT elem, FSNSnapshot.Layer layer)
    {
        var nameDict = layer.GetCustomData(c_customDataName) as Dictionary <string, int>;

        if (nameDict == null)
        {
            nameDict = new Dictionary <string, int>();
            layer.SetCustomData(c_customDataName, nameDict);
        }

        if (nameDict.ContainsKey(name))
        {
            return(false);
        }
        else
        {
            nameDict[name] = elem.UniqueID;
            return(true);
        }
    }
    /// <summary>
    /// 오브젝트 이름으로 UID 찾기
    /// </summary>
    /// <param name="name"></param>
    /// <param name="uid"></param>
    /// <returns></returns>
    protected static bool FindUIDFromLookupDict(string name, out int uid, FSNSnapshot.Layer layer)
    {
        var nameDict = layer.GetCustomData(c_customDataName) as Dictionary <string, int>;

        if (nameDict == null)
        {
            nameDict = new Dictionary <string, int>();
            layer.SetCustomData(c_customDataName, nameDict);
        }

        if (!nameDict.ContainsKey(name))
        {
            uid = 0;
            return(false);
        }
        else
        {
            uid = nameDict[name];
            return(true);
        }
    }
    public override FSNSnapshot.Layer GenerateNextLayerImage(FSNSnapshot.Layer curLayer, params FSNProcessModuleCallParam[] callParams)
    {
        FSNSnapshot.Layer newLayer = curLayer.Clone();
        if (curLayer.GetCustomData(c_customDataName) != null)                   // 이름 dictionary 카피
        {
            newLayer.SetCustomData(c_customDataName, new Dictionary <string, int>(curLayer.GetCustomData(c_customDataName) as Dictionary <string, int>));
        }

        foreach (var callParam in callParams)
        {
            if (callParam.segment.type == FSNScriptSequence.Segment.Type.Object)
            {
                var objSeg = callParam.segment as SegT;

                switch (objSeg.command)
                {
                case Segments.Object.CommandType.Create:
                    CreateElement(objSeg, newLayer);
                    break;

                case Segments.Object.CommandType.Remove:
                    RemoveElement(objSeg, newLayer);
                    break;

                case Segments.Object.CommandType.SetInitial:
                    SetElementInitial(objSeg, newLayer);
                    break;

                case Segments.Object.CommandType.SetFinal:
                    SetElementFinal(objSeg, newLayer);
                    break;

                case Segments.Object.CommandType.SetKey:
                    SetElement(objSeg, newLayer);
                    break;

                case Segments.Object.CommandType.Custom:
                    ProcessCustomElementCommand(objSeg, newLayer);
                    break;
                }
            }
            else if (callParam.segment.type == FSNScriptSequence.Segment.Type.Control)
            {
                var controlSeg = callParam.segment as Segments.Control;
                if (controlSeg.controlType == Segments.Control.ControlType.Clear && acceptClearCommand)                 // Clear 명령에 반응
                {
                    foreach (var rawelem in newLayer.Elements)                                                          // finalstate가 세팅되지 않은 오브젝트에 한해서 디폴트 세팅
                    {
                        var elem = rawelem as ElemT;
                        AutoSetFinalState(elem);
                    }

                    newLayer = new FSNSnapshot.Layer();                                                                                         // 완전히 새로운 레이어로 교체

                    // TODO : 힘들게 복제한 레이어를 버리는 구조임. 최적화 여지가 있음.
                }
            }
            else if (callParam.segment.type == FSNScriptSequence.Segment.Type.HardClone)                // 레이어 Hard-Clone
            {
                newLayer.MakeAllElemsHardClone();
            }
            else
            {
            }
        }

        // TODO : call 처리 이후, snapshot 마무리
        OnAfterGenerateNextLayerImage(newLayer);

        return(newLayer);
    }