예제 #1
0
        public void SetMorphs(List <DAZMorph> morphs)
        {
            var fixedMorphs = new List <SelectedMorph>();

            foreach (var m in morphs)
            {
                bool found = false;

                foreach (var sm in morphs_)
                {
                    if (sm.Morph == m)
                    {
                        fixedMorphs.Add(sm);
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    var nsm = SelectedMorph.Create(Atom, m);
                    nsm.Movement = new Movement(0, 1);
                    fixedMorphs.Add(nsm);
                }
            }


            int i = 0;

            while (i < morphs_.Count)
            {
                if (fixedMorphs.Contains(morphs_[i]))
                {
                    ++i;
                }
                else
                {
                    morphs_[i].Removed();
                    morphs_.RemoveAt(i);
                }
            }

            morphs_.Clear();
            morphs_.AddRange(fixedMorphs);

            Synergy.LogError("new morphs: " + morphs.Count.ToString());

            Progression.MorphsChanged();
        }
예제 #2
0
        public SelectedMorph AddMorph(DAZMorph m, Movement mv)
        {
            if (m == null)
            {
                return(null);
            }

            var sm = SelectedMorph.Create(Atom, m);

            if (mv != null)
            {
                sm.Movement = mv;
            }

            AddMorph(sm);

            return(sm);
        }
예제 #3
0
        public override bool FromJSON(J.Node n)
        {
            if (!base.FromJSON(n))
            {
                return(false);
            }

            var o = n.AsObject("MorphModifier");

            if (o == null)
            {
                return(false);
            }

            if (Atom != null)
            {
                var morphsArray = o.Get("selectedMorphs").AsArray();

                if (morphsArray != null)
                {
                    morphsArray.ForEach((morphNode) =>
                    {
                        var sm = SelectedMorph.Create(Atom, null);

                        if (sm.FromJSON(morphNode))
                        {
                            morphs_.Add(sm);
                        }
                    });
                }

                IMorphProgression p = null;
                o.Opt <MorphProgressionFactory, IMorphProgression>(
                    "progression", ref p);

                Progression = p;
            }

            return(true);
        }