示例#1
0
 public void Apply(Linedef l)
 {
     if ((front != null) && (l.Front != null))
     {
         front.Apply(l.Front);
     }
     if ((back != null) && (l.Back != null))
     {
         back.Apply(l.Back);
     }
     l.ClearFlags();
     foreach (KeyValuePair <string, bool> f in flags)
     {
         l.SetFlag(f.Key, f.Value);
     }
     l.Action   = action;
     l.Activate = activate;
     l.Tag      = tag;
     for (int i = 0; i < l.Args.Length; i++)
     {
         l.Args[i] = args[i];
     }
     l.Fields.BeforeFieldsChange();
     l.Fields.Clear();
     foreach (KeyValuePair <string, UniValue> v in fields)
     {
         l.Fields.Add(v.Key, new UniValue(v.Value));
     }
 }
示例#2
0
        //mxd. Applies selected linededf and sidedef settings
        public void Apply(ICollection <Linedef> lines, LinedefPropertiesCopySettings settings, SidedefPropertiesCopySettings sidesettings)
        {
            List <Sidedef> frontsides = new List <Sidedef>(lines.Count);
            List <Sidedef> backsides  = new List <Sidedef>(lines.Count);

            foreach (Linedef l in lines)
            {
                if (settings.Flags)
                {
                    l.ClearFlags();
                    foreach (KeyValuePair <string, bool> f in flags)
                    {
                        l.SetFlag(f.Key, f.Value);
                    }
                }
                if (settings.Activation)
                {
                    l.Activate = activate;
                }
                if (settings.Tag)
                {
                    l.Tags = new List <int>(tags);                             //mxd
                }
                if (settings.Action)
                {
                    l.Action = action;
                }
                if (settings.Arguments)
                {
                    for (int i = 0; i < l.Args.Length; i++)
                    {
                        l.Args[i] = args[i];
                    }
                }

                if (l.Front != null)
                {
                    frontsides.Add(l.Front);
                }
                if (l.Back != null)
                {
                    backsides.Add(l.Back);
                }
            }

            // Should we bother?
            if (General.Map.UDMF)
            {
                // Apply fields
                foreach (Linedef l in lines)
                {
                    l.Fields.BeforeFieldsChange();

                    // Apply string arguments
                    if (settings.Arguments)
                    {
                        Apply(l.Fields, "arg0str");

                        //TODO: re-enable when UI part is ready
                        //Apply(l.Fields, "arg1str");
                        //Apply(l.Fields, "arg2str");
                        //Apply(l.Fields, "arg3str");
                        //Apply(l.Fields, "arg4str");
                    }

                    // Apply custom fields
                    if (settings.Fields)
                    {
                        ApplyCustomFields(l.Fields);
                    }
                }

                // Apply UI fields
                ApplyUIFields(lines, settings);
            }

            // Apply sidedef settings
            if (sidesettings != null)
            {
                if (front != null)
                {
                    front.Apply(frontsides, sidesettings);
                }
                if (back != null)
                {
                    back.Apply(backsides, sidesettings);
                }
            }
        }