public bool Add(ReplacementRule template) { if (template != null) { collection.Add(template); return(true); } return(false); }
/// <summary> /// Read a room in the "0" FileFormat /// First line is XSize ///Second Line is YSize ///Third line are operation to generate Mirror rooms (Rotate : X, H Mirror : X, V Mirror : Y) ///Followed by YSize lines of XSize chars /// </summary> /// <param name="reader"></param> public static void Read_FileFormat_1(StreamReader reader, ReplacementRuleList templates) { try { int priority = 1; int xsize = 0; int ysize = 0; int chance = 100; Int32.TryParse(reader.ReadLine(), out priority); Int32.TryParse(reader.ReadLine(), out xsize); Int32.TryParse(reader.ReadLine(), out ysize); string operations = reader.ReadLine(); char[,] initialData = loadData(reader, xsize, ysize); Int32.TryParse(reader.ReadLine(), out chance); char[,] replacementData = loadData(reader, xsize, ysize); // if requested, create mirrored copies List <char[, ]> initialMirrors = CharUtils.CreateMirrors(initialData, operations); List <char[, ]> replacementMirrors = CharUtils.CreateMirrors(replacementData, operations); for (int i = 0; i < initialMirrors.Count; i++) { MapTemplate initial = new MapTemplate(initialMirrors[i]); MapTemplate replacement = new MapTemplate(replacementMirrors[i]); ReplacementRule replace = new ReplacementRule(); replace.InitialContent = initial; replace.ReplacementContent = replacement; replace.Priority = priority; replace.Chance = chance; if (replace.Check()) { templates.Add(replace); } } } catch (Exception e) { Logger.Error(e.Message); Console.WriteLine(e.Message); } }