29 lines
784 B
C#
29 lines
784 B
C#
|
namespace OSMImporter
|
||
|
{
|
||
|
public class RegionManager
|
||
|
{
|
||
|
private readonly Dictionary<ulong, Region> _regions;
|
||
|
|
||
|
public RegionManager()
|
||
|
{
|
||
|
this._regions = new Dictionary<ulong, Region>();
|
||
|
}
|
||
|
|
||
|
public Region GetRegion(Coordinates coordinates)
|
||
|
{
|
||
|
if(this._regions.ContainsKey(coordinates.GetRegionHash()))
|
||
|
return this._regions[coordinates.GetRegionHash()];
|
||
|
else
|
||
|
{
|
||
|
Region newRegion = new Region(coordinates);
|
||
|
this._regions.Add(newRegion.regionHash, value: newRegion);
|
||
|
return newRegion;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public Region[] GetAllRegions()
|
||
|
{
|
||
|
return this._regions.Values.ToArray();
|
||
|
}
|
||
|
}
|
||
|
}
|