Пример #1
0
        /// <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);
        }