Exemple #1
0
        //mxd. Applies coped properties using selected settings
        public void Apply(ICollection <Sector> sectors, SectorPropertiesCopySettings settings)
        {
            foreach (Sector s in sectors)
            {
                if (settings.FloorHeight)
                {
                    s.FloorHeight = floorheight;
                }
                if (settings.CeilingHeight)
                {
                    s.CeilHeight = ceilheight;
                }
                if (settings.FloorTexture)
                {
                    s.SetFloorTexture(floortexture);
                }
                if (settings.CeilingTexture)
                {
                    s.SetCeilTexture(ceilingtexture);
                }
                if (settings.Brightness)
                {
                    s.Brightness = brightness;
                }
                if (settings.Tag)
                {
                    s.Tags = new List <int>(tags);                             //mxd
                }
                if (settings.Special)
                {
                    s.Effect = effect;
                }
                if (settings.CeilingSlope)
                {
                    s.CeilSlopeOffset = ceilslopeoffset;
                    s.CeilSlope       = ceilslope;
                }
                if (settings.FloorSlope)
                {
                    s.FloorSlopeOffset = floorslopeoffset;
                    s.FloorSlope       = floorslope;
                }
                if (settings.Flags)
                {
                    s.ClearFlags();                                  //mxd
                    foreach (KeyValuePair <string, bool> f in flags) //mxd
                    {
                        s.SetFlag(f.Key, f.Value);
                    }
                }
            }

            // Should we bother?
            if (!General.Map.UDMF)
            {
                return;
            }

            // Apply custom fields
            foreach (Sector s in sectors)
            {
                s.Fields.BeforeFieldsChange();
                if (settings.Fields)
                {
                    ApplyCustomFields(s.Fields);
                }
            }

            // Apply UI fields
            ApplyUIFields(sectors, settings);
        }
Exemple #2
0
        public static bool PropertiesMatch(SectorPropertiesCopySettings flags, Sector source, Sector target)
        {
            // Built-in properties
            if (flags.FloorHeight && source.FloorHeight != target.FloorHeight)
            {
                return(false);
            }
            if (flags.CeilingHeight && source.CeilHeight != target.CeilHeight)
            {
                return(false);
            }
            if (flags.FloorTexture && source.FloorTexture != target.FloorTexture)
            {
                return(false);
            }
            if (flags.CeilingTexture && source.CeilTexture != target.CeilTexture)
            {
                return(false);
            }
            if (flags.Brightness && source.Brightness != target.Brightness)
            {
                return(false);
            }
            if (flags.Tag && !TagsMatch(source.Tags, target.Tags))
            {
                return(false);
            }
            if (flags.Flags && !FlagsMatch(source.GetEnabledFlags(), target.GetEnabledFlags()))
            {
                return(false);
            }

            // Generalized effects require more tender loving care...
            if (flags.Special && source.Effect != target.Effect)
            {
                if (!General.Map.Config.GeneralizedEffects || source.Effect == 0 || target.Effect == 0)
                {
                    return(false);
                }

                // Get effect bits...
                SectorEffectData sourcedata = General.Map.Config.GetSectorEffectData(source.Effect);
                SectorEffectData targetdata = General.Map.Config.GetSectorEffectData(target.Effect);

                // No bits match when at least one effect is not generalized, or when bits don't overlap
                if (sourcedata.Effect != targetdata.Effect ||
                    sourcedata.GeneralizedBits.Count != targetdata.GeneralizedBits.Count ||
                    !sourcedata.GeneralizedBits.Overlaps(targetdata.GeneralizedBits))
                {
                    return(false);
                }
            }

            if (!General.Map.UDMF)
            {
                return(true);
            }

            // UI fields
            if (!UIFieldsMatch(flags, source, target))
            {
                return(false);
            }

            // Custom fields
            return(!flags.Fields || UniFields.CustomFieldsMatch(source.Fields, target.Fields));
        }