/// <summary> /// Add a location to the reference map. Auto increments file offset, so be sure to add small maps in correct order /// </summary> /// <param name="location">the location of reference</param> /// <param name="hasBasement">Does it have a basement? if so, start at position -1 </param> /// <param name="nFloors">How many floors?</param> private void AddLocation(SingleMapReference.Location location, bool hasBasement, short nFloors) { // get the master map file from the location info SingleMapReference.SmallMapMasterFiles masterMap = SingleMapReference.GetMapMasterFromLocation(location); // we are going to track the order that the maps were added // if the master map hasn't been seen yet, then we need to create a new index array of locations if (!masterFileLocationDictionary.ContainsKey(masterMap)) { masterFileLocationDictionary.Add(masterMap, new List <SingleMapReference.Location>()); } masterFileLocationDictionary[masterMap].Add(location); // get the filename of the location - we use it as key into a map string dataFilename = SingleMapReference.GetFilenameFromLocation(location); // create an offset counter if it doesn't already exist if (!roomOffsetCountDictionary.ContainsKey(dataFilename)) { roomOffsetCountDictionary[dataFilename] = 0; } // get the current file offset value (auto-counting...) short roomOffset = roomOffsetCountDictionary[dataFilename]; // add one or more map references mapReferences.AddRange(GenerateSingleMapReferences(location, hasBasement?-1:0, nFloors, roomOffset, locationNames[(int)location])); // add the number of floors you have just added so that it can increment the file offset for subequent calls roomOffsetCountDictionary[dataFilename] += nFloors; smallMapBasementDictionary.Add(location, hasBasement); nFloorsDictionary.Add(location, nFloors); }
/// <summary> /// Get a map reference based on a location /// </summary> /// <param name="location">The location you are looking for</param> /// <returns>a single map reference providing details on the map itself</returns> public SingleMapReference GetSingleMapByLocation(SingleMapReference.Location location, int floor) { SingleMapReference.SmallMapMasterFiles masterMap = SingleMapReference.GetMapMasterFromLocation(location); foreach (SingleMapReference mapRef in mapReferences) { if (mapRef.MapLocation == location && mapRef.Floor == floor) { return(mapRef); } } throw new Exception("Location was not found!"); }
/// <summary> /// Get the location based on the index within the small map file /// </summary> /// <param name="smallMap">the small map file reference</param> /// <param name="index">the 0-7 index within the small map file</param> /// <returns>the location reference</returns> public SingleMapReference.Location GetLocationByIndex(SingleMapReference.SmallMapMasterFiles smallMap, int index) { SingleMapReference.Location location = masterFileLocationDictionary[smallMap][index]; return(location); }