private void PrepareMapping(ICorridorMapDescription <int> mapDescription) { var graph = mapDescription.GetGraph(); var corridors = graph.Vertices.Where(mapDescription.IsCorridorRoom).ToList(); foreach (var corridor in corridors) { var room = ScriptableObject.CreateInstance <Room>(); precomputedMapping.Add(room, corridor); } }
/// <inheritdoc /> /// <summary> /// Finds the smallest feasible multiple of a specified number and then make from it a sequence of corridors. /// </summary> public void AddCorridorsToMapping(ICorridorMapDescription <int> mapDescription, TwoWayDictionary <int, int> mapping) { var graph = mapDescription.GetGraph(); var corridors = graph.Vertices.Where(mapDescription.IsCorridorRoom).ToList(); var maxNonCorridorNumber = graph.Vertices.Where(x => !mapDescription.IsCorridorRoom(x)).Max(); var parts = maxNonCorridorNumber / roundTo; var nextNumber = roundTo * (parts + 1); var counter = nextNumber; foreach (var corridor in corridors) { mapping.Add(counter++, corridor); } }
/// <inheritdoc /> /// <remarks> /// Adds number to a given prefix until all corridors have a name. /// </remarks> public void AddCorridorsToMapping(ICorridorMapDescription <int> mapDescription, TwoWayDictionary <string, int> mapping) { var graph = mapDescription.GetGraph(); var corridors = graph.Vertices.Where(mapDescription.IsCorridorRoom).ToList(); var counter = 0; foreach (var corridor in corridors) { while (true) { var name = prefix + counter; if (!mapping.ContainsKey(name)) { mapping.Add(name, corridor); break; } counter++; } } }