private static bool UIFieldsMatch(MapElementPropertiesCopySettings settings, MapElement first, MapElement second) { FieldInfo[] props = settings.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance); foreach (FieldInfo prop in props) { // Property set? if (!(bool)prop.GetValue(settings)) { continue; } foreach (Attribute attr in Attribute.GetCustomAttributes(prop)) { if (attr.GetType() != typeof(FieldDescription)) { continue; } FieldDescription fd = (FieldDescription)attr; if (fd.SupportsCurrentMapFormat && !string.IsNullOrEmpty(fd.Field1)) { if (!string.IsNullOrEmpty(fd.Field2)) { if (!UniFields.ValuesMatch(fd.Field1, fd.Field2, first, second)) { return(false); } } else { if (!UniFields.ValuesMatch(fd.Field1, first, second)) { return(false); } } } } } return(true); }
public static bool PropertiesMatch(ThingPropertiesCopySettings flags, Thing source, Thing target) { // Built-in properties if (flags.Type && source.Type != target.Type) { return(false); } if (flags.Angle && source.AngleDoom != target.AngleDoom) { return(false); } if (flags.Action && source.Action != target.Action) { return(false); } if (flags.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 (flags.Tag && source.Tag != target.Tag) { return(false); } if (flags.Flags && !FlagsMatch(source.GetEnabledFlags(), target.GetEnabledFlags())) { return(false); } if (!General.Map.UDMF) { return(true); } // UDMF-specific properties if (flags.Pitch && source.Pitch != target.Pitch) { return(false); } if (flags.Roll && source.Roll != target.Roll) { return(false); } if (flags.Scale && (source.ScaleX != target.ScaleX) || (source.ScaleY != target.ScaleY)) { return(false); } // UI fields if (!UIFieldsMatch(flags, source, target)) { return(false); } // Custom fields return(!flags.Fields || UniFields.CustomFieldsMatch(source.Fields, target.Fields)); }
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))); }