Example #1
0
        public static bool PropertiesMatch(LinedefPropertiesCopySettings linedefflags, SidedefPropertiesCopySettings sideflags, Linedef source, Linedef target)
        {
            // Built-in properties
            if (linedefflags.Action && source.Action != target.Action)
            {
                return(false);
            }
            if (linedefflags.Activation && source.Activate != target.Activate)
            {
                return(false);
            }
            if (linedefflags.Tag && !TagsMatch(source.Tags, target.Tags))
            {
                return(false);
            }
            if (linedefflags.Arguments)
            {
                // Classic args
                for (int i = 0; i < source.Args.Length; i++)
                {
                    if (source.Args[i] != target.Args[i])
                    {
                        return(false);
                    }
                }

                // String args
                if (General.Map.UDMF)
                {
                    if (!UniFields.ValuesMatch("arg0str", source, target))
                    {
                        return(false);
                    }
                    if (!UniFields.ValuesMatch("arg1str", source, target))
                    {
                        return(false);
                    }
                    if (!UniFields.ValuesMatch("arg2str", source, target))
                    {
                        return(false);
                    }
                    if (!UniFields.ValuesMatch("arg3str", source, target))
                    {
                        return(false);
                    }
                    if (!UniFields.ValuesMatch("arg4str", source, target))
                    {
                        return(false);
                    }
                }
            }
            if (linedefflags.Flags && !FlagsMatch(source.GetEnabledFlags(), target.GetEnabledFlags()))
            {
                return(false);
            }

            if (General.Map.UDMF)
            {
                // UI fields
                if (!UIFieldsMatch(linedefflags, source, target))
                {
                    return(false);
                }

                // Custom fields
                if (linedefflags.Fields && !UniFields.CustomFieldsMatch(source.Fields, target.Fields))
                {
                    return(false);
                }
            }

            // Sidedef properties
            return((source.Front != null && target.Front != null && PropertiesMatch(sideflags, source.Front, target.Front)) ||
                   (source.Front != null && target.Back != null && PropertiesMatch(sideflags, source.Front, target.Back)) ||
                   (source.Back != null && target.Front != null && PropertiesMatch(sideflags, source.Back, target.Front)) ||
                   (source.Back != null && target.Back != null && PropertiesMatch(sideflags, source.Back, target.Back)));
        }