/// <summary> /// Build dictionary of locations. /// </summary> private void EnumerateMaps() { //System.Diagnostics.Stopwatch s = System.Diagnostics.Stopwatch.StartNew(); //long startTime = s.ElapsedMilliseconds; mapDict = new Dictionary <int, MapSummary>(); locationIdToMapIdDict = new Dictionary <int, int>(); for (int region = 0; region < mapFileReader.RegionCount; region++) { DFRegion dfRegion = mapFileReader.GetRegion(region); for (int location = 0; location < dfRegion.LocationCount; location++) { // Get map summary MapSummary summary = new MapSummary(); DFRegion.RegionMapTable mapTable = dfRegion.MapTable[location]; summary.ID = mapTable.MapId & 0x000fffff; summary.RegionIndex = region; summary.MapIndex = location; summary.LocationType = mapTable.LocationType; summary.DungeonType = mapTable.DungeonType; mapDict.Add(summary.ID, summary); // Link locationId with mapId - adds ~25ms overhead int locationId = mapFileReader.ReadLocationIdFast(region, location); locationIdToMapIdDict.Add(locationId, summary.ID); } } //long totalTime = s.ElapsedMilliseconds - startTime; //Debug.LogFormat("Total time to enum maps: {0}ms", totalTime); }
public override string LocationDirection() { Vector2 positionPlayer; Vector2 positionLocation = Vector2.zero; DFPosition position = new DFPosition(); PlayerGPS playerGPS = GameManager.Instance.PlayerGPS; if (playerGPS) { position = playerGPS.CurrentMapPixel; } positionPlayer = new Vector2(position.X, position.Y); int region = DaggerfallUnity.Instance.ContentReader.MapFileReader.GetPoliticIndex(position.X, position.Y) - 128; if (region < 0 || region >= DaggerfallUnity.Instance.ContentReader.MapFileReader.RegionCount) { region = -1; } DFRegion.RegionMapTable locationInfo = new DFRegion.RegionMapTable(); DFRegion currentDFRegion = DaggerfallUnity.Instance.ContentReader.MapFileReader.GetRegion(region); string name = this.parent.LastPlaceReferenced.SiteDetails.locationName.ToLower(); string[] locations = currentDFRegion.MapNames; for (int i = 0; i < locations.Length; i++) { if (locations[i].ToLower() == name) // Valid location found with exact name { if (currentDFRegion.MapNameLookup.ContainsKey(locations[i])) { int index = currentDFRegion.MapNameLookup[locations[i]]; locationInfo = currentDFRegion.MapTable[index]; position = MapsFile.LongitudeLatitudeToMapPixel((int)locationInfo.Longitude, (int)locationInfo.Latitude); positionLocation = new Vector2(position.X, position.Y); } } } if (positionLocation != Vector2.zero) { Vector2 vecDirectionToTarget = positionLocation - positionPlayer; vecDirectionToTarget.y = -vecDirectionToTarget.y; // invert y axis return(GameManager.Instance.TalkManager.DirectionVector2DirectionHintString(vecDirectionToTarget)); } else { return("... never mind ..."); } }
/// <summary> /// Build dictionary of locations. /// </summary> private void EnumerateMaps() { mapDict = new Dictionary <int, MapSummary>(); for (int region = 0; region < mapFileReader.RegionCount; region++) { DFRegion dfRegion = mapFileReader.GetRegion(region); for (int location = 0; location < dfRegion.LocationCount; location++) { MapSummary summary = new MapSummary(); DFRegion.RegionMapTable mapTable = dfRegion.MapTable[location]; summary.ID = mapTable.MapId & 0x000fffff; summary.RegionIndex = region; summary.MapIndex = location; mapDict.Add(summary.ID, summary); } } }
/// <summary> /// Build dictionary of locations. /// </summary> private void EnumerateMaps() { //System.Diagnostics.Stopwatch s = System.Diagnostics.Stopwatch.StartNew(); //long startTime = s.ElapsedMilliseconds; mapDict = new Dictionary <int, MapSummary>(); locationIdToMapIdDict = new Dictionary <int, int>(); for (int region = 0; region < mapFileReader.RegionCount; region++) { DFRegion dfRegion = mapFileReader.GetRegion(region); for (int location = 0; location < dfRegion.LocationCount; location++) { MapSummary summary = new MapSummary(); try { // Get map summary DFRegion.RegionMapTable mapTable = dfRegion.MapTable[location]; summary.ID = mapTable.MapId & 0x000fffff; summary.RegionIndex = region; summary.MapIndex = location; summary.LocationType = mapTable.LocationType; summary.DungeonType = mapTable.DungeonType; // TODO: This by itself doesn't account for DFRegion.LocationTypes.GraveyardForgotten locations that start the game discovered in classic summary.Discovered = mapTable.Discovered; mapDict.Add(summary.ID, summary); // Link locationId with mapId - adds ~25ms overhead int locationId = mapFileReader.ReadLocationIdFast(region, location); locationIdToMapIdDict.Add(locationId, summary.ID); } catch (ArgumentException) { Debug.LogErrorFormat("Colliding location for MapId:{0} found when enumerating maps! Unable to initialise content reader. ", summary.ID); } } } //long totalTime = s.ElapsedMilliseconds - startTime; //Debug.LogFormat("Total time to enum maps: {0}ms", totalTime); }
public static bool HasPort(DFRegion.RegionMapTable mapTable) { return(HasPort(mapTable.MapId)); }
public static bool HasPortExtra(DFRegion.RegionMapTable mapTable) { return(Array.Exists(portLocationExtraIds, n => n == (mapTable.MapId & 0xFFFFF))); }