Exemplo n.º 1
0
        /// <summary>
        /// Discover location with regionName and locationName.
        /// </summary>
        public void DiscoverLocation(string regionName, string locationName)
        {
            DFLocation location;
            bool       found = dfUnity.ContentReader.GetLocation(regionName, locationName, out location);

            if (!found)
            {
                throw new Exception(String.Format("Error finding location {0} : {1}", regionName, locationName));
            }
            // Check if already discovered
            int mapPixelID = MapsFile.GetMapPixelIDFromLongitudeLatitude((int)location.MapTableData.Longitude, location.MapTableData.Latitude);

            if (HasDiscoveredLocation(mapPixelID))
            {
                return;
            }

            // Add to discovered locations dict
            DiscoveredLocation dl = new DiscoveredLocation();

            dl.mapID        = location.MapTableData.MapId;
            dl.mapPixelID   = mapPixelID;
            dl.regionName   = location.RegionName;
            dl.locationName = location.Name;
            discoveredLocations.Add(mapPixelID, dl);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Check if player has discovered building in current location.
        /// </summary>
        /// <param name="buildingKey">Building key to check.</param>
        /// <returns>True if building discovered.</returns>
        public bool HasDiscoveredBuilding(int buildingKey)
        {
            // Must have a location loaded
            if (!CurrentLocation.Loaded)
            {
                return(false);
            }

            // Must have discovered current location before building
            int mapPixelID = MapsFile.GetMapPixelIDFromLongitudeLatitude((int)CurrentLocation.MapTableData.Longitude, CurrentLocation.MapTableData.Latitude);

            if (!HasDiscoveredLocation(mapPixelID))
            {
                return(false);
            }

            // Get the location discovery for this mapID
            DiscoveredLocation dl = discoveredLocations[mapPixelID];

            if (dl.discoveredBuildings == null)
            {
                return(false);
            }

            return(dl.discoveredBuildings.ContainsKey(buildingKey));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Discover current location.
        /// Does nothing if player in wilderness or location already dicovered.
        /// This is performed automatically by PlayerGPS when player enters a location rect.
        /// </summary>
        void DiscoverCurrentLocation()
        {
            // Must have a location loaded
            if (!CurrentLocation.Loaded)
            {
                return;
            }

            // Check if already discovered
            int mapPixelID = MapsFile.GetMapPixelIDFromLongitudeLatitude((int)CurrentLocation.MapTableData.Longitude, CurrentLocation.MapTableData.Latitude);

            if (HasDiscoveredLocation(mapPixelID))
            {
                return;
            }

            // Add to discovered locations dict
            DiscoveredLocation dl = new DiscoveredLocation();

            dl.mapID        = CurrentLocation.MapTableData.MapId;
            dl.mapPixelID   = mapPixelID;
            dl.regionName   = CurrentLocation.RegionName;
            dl.locationName = CurrentLocation.Name;
            discoveredLocations.Add(mapPixelID, dl);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets discovered building data for current location.
        /// </summary>
        /// <param name="buildingKey">Building key in current location.</param>
        /// <param name="discoveredBuildingOut">Building discovery data out.</param>
        /// <returns>True if building discovered, false if building not discovered.</returns>
        public bool GetDiscoveredBuilding(int buildingKey, out DiscoveredBuilding discoveredBuildingOut)
        {
            discoveredBuildingOut = new DiscoveredBuilding();

            // Must have discovered building
            if (!HasDiscoveredBuilding(buildingKey))
            {
                return(false);
            }

            // Get the location discovery for this mapID
            int mapPixelID        = MapsFile.GetMapPixelIDFromLongitudeLatitude((int)CurrentLocation.MapTableData.Longitude, CurrentLocation.MapTableData.Latitude);
            DiscoveredLocation dl = discoveredLocations[mapPixelID];

            if (dl.discoveredBuildings == null)
            {
                return(false);
            }

            // Get discovery data for building
            discoveredBuildingOut = dl.discoveredBuildings[buildingKey];

            // Check if name should be overridden (owned house / quest site)
            PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;

            if (DaggerfallBankManager.IsHouseOwned(buildingKey))
            {
                discoveredBuildingOut.displayName = HardStrings.playerResidence.Replace("%s", playerEntity.Name);
            }

            return(true);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Check if player has discovered building in current location.
        /// </summary>
        /// <param name="buildingKey">Building key to check.</param>
        /// <returns>True if building discovered.</returns>
        public bool HasDiscoveredBuilding(int buildingKey)
        {
            // Must have a location loaded
            if (!CurrentLocation.Loaded)
            {
                return(false);
            }

            // Must have discovered current location before building
            int mapID = CurrentLocation.MapTableData.MapId;

            if (!HasDiscoveredLocation(mapID))
            {
                return(false);
            }

            // Get the location discovery for this mapID
            DiscoveredLocation dl = discoveredLocations[mapID];

            if (dl.discoveredBuildings == null)
            {
                return(false);
            }

            return(dl.discoveredBuildings.ContainsKey(buildingKey));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Undiscover the specified building in current location.
        /// used to undiscover residences when they are a quest resource (named residence) when "add dialog" is done for this quest resource or on quest startup
        /// otherwise previously discovered residences will automatically show up on the automap when used in a quest
        /// </summary>
        /// <param name="buildingKey">Building key of building to be undiscovered</param>
        /// <param name="onlyIfResidence">gets undiscovered only if buildingType is residence</param>
        public void UndiscoverBuilding(int buildingKey, bool onlyIfResidence = false)
        {
            // Must have a location loaded
            if (!CurrentLocation.Loaded)
            {
                return;
            }

            // Get building information
            DiscoveredBuilding db;

            if (!GetBuildingDiscoveryData(buildingKey, out db))
            {
                return;
            }

            // Get location discovery
            int mapPixelID        = MapsFile.GetMapPixelIDFromLongitudeLatitude((int)CurrentLocation.MapTableData.Longitude, CurrentLocation.MapTableData.Latitude);
            DiscoveredLocation dl = new DiscoveredLocation();

            if (discoveredLocations.ContainsKey(mapPixelID))
            {
                dl = discoveredLocations[mapPixelID];
            }

            if (onlyIfResidence && !RMBLayout.IsResidence(db.buildingType))
            {
                return;
            }

            if (dl.discoveredBuildings != null && dl.discoveredBuildings.ContainsKey(db.buildingKey))
            {
                dl.discoveredBuildings.Remove(db.buildingKey);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Discover the specified building in current location.
        /// Does nothing if player not inside a location or building already discovered.
        /// </summary>
        /// <param name="buildingKey">Building key of building to be discovered</param>
        /// <param name="overrideName">If provided, ignore previous discovery and override the name</param>
        public void DiscoverBuilding(int buildingKey, string overrideName = null)
        {
            // Ensure current location also discovered before processing building
            DiscoverCurrentLocation();

            // Must have a location loaded
            if (!CurrentLocation.Loaded)
            {
                return;
            }

            // Do nothing if building already discovered, unless overriding name
            if (overrideName == null && HasDiscoveredBuilding(buildingKey))
            {
                return;
            }

            // Get building information
            DiscoveredBuilding db;

            if (!GetBuildingDiscoveryData(buildingKey, out db))
            {
                return;
            }

            // Get location discovery
            int mapPixelID        = MapsFile.GetMapPixelIDFromLongitudeLatitude((int)CurrentLocation.MapTableData.Longitude, CurrentLocation.MapTableData.Latitude);
            DiscoveredLocation dl = new DiscoveredLocation();

            if (discoveredLocations.ContainsKey(mapPixelID))
            {
                dl = discoveredLocations[mapPixelID];
            }

            // Ensure the building dict is created
            if (dl.discoveredBuildings == null)
            {
                dl.discoveredBuildings = new Dictionary <int, DiscoveredBuilding>();
            }

            // Add the building and store back to discovered location, overriding name if requested
            if (overrideName != null)
            {
                if (!db.isOverrideName)
                {
                    db.oldDisplayName = db.displayName;
                }
                db.displayName    = overrideName;
                db.isOverrideName = true;
            }

            if (db.oldDisplayName == db.displayName)
            {
                db.isOverrideName = false;
            }

            dl.discoveredBuildings[db.buildingKey] = db;
            discoveredLocations[mapPixelID]        = dl;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Discover the specified building in current location.
        /// Does nothing if player not inside a location or building already discovered.
        /// </summary>
        /// <param name="buildingKey"></param>
        public void DiscoverBuilding(int buildingKey)
        {
            // Must have a location loaded
            if (!CurrentLocation.Loaded)
            {
                return;
            }

            // Do nothing if building already discovered
            if (HasDiscoveredBuilding(buildingKey))
            {
                return;
            }

            // Get building information
            DiscoveredBuilding db;

            if (!GetBuildingDiscoveryData(buildingKey, out db))
            {
                return;
            }

            // Get location discovery
            int mapPixelID        = MapsFile.GetMapPixelIDFromLongitudeLatitude((int)CurrentLocation.MapTableData.Longitude, CurrentLocation.MapTableData.Latitude);
            DiscoveredLocation dl = new DiscoveredLocation();

            if (discoveredLocations.ContainsKey(mapPixelID))
            {
                dl = discoveredLocations[mapPixelID];
            }

            // Ensure the building dict is created
            if (dl.discoveredBuildings == null)
            {
                dl.discoveredBuildings = new Dictionary <int, DiscoveredBuilding>();
            }

            // Add the building and store back to discovered location
            dl.discoveredBuildings.Add(db.buildingKey, db);
            discoveredLocations[mapPixelID] = dl;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Updates discovered building data in current location.
        /// </summary>
        /// <param name="discoveredBuilding">Updated data to write back to live discovery database.</param>
        void UpdateDiscoveredBuilding(DiscoveredBuilding discoveredBuildingIn)
        {
            // Must have discovered building
            if (!HasDiscoveredBuilding(discoveredBuildingIn.buildingKey))
            {
                return;
            }

            // Get the location discovery for this mapID
            int mapPixelID        = MapsFile.GetMapPixelIDFromLongitudeLatitude((int)CurrentLocation.MapTableData.Longitude, CurrentLocation.MapTableData.Latitude);
            DiscoveredLocation dl = discoveredLocations[mapPixelID];

            if (dl.discoveredBuildings == null)
            {
                return;
            }

            // Replace discovery data for building
            dl.discoveredBuildings.Remove(discoveredBuildingIn.buildingKey);
            dl.discoveredBuildings.Add(discoveredBuildingIn.buildingKey, discoveredBuildingIn);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Gets discovered building data for current location.
        /// </summary>
        /// <param name="buildingKey">Building key in current location.</param>
        /// <param name="discoveredBuildingOut">Building discovery data out.</param>
        /// <returns>True if building discovered, false if building not discovered.</returns>
        public bool GetDiscoveredBuilding(int buildingKey, out DiscoveredBuilding discoveredBuildingOut)
        {
            discoveredBuildingOut = new DiscoveredBuilding();

            // Must have discovered building
            if (!HasDiscoveredBuilding(buildingKey))
            {
                return(false);
            }

            // Get the location discovery for this mapID
            int mapPixelID        = MapsFile.GetMapPixelIDFromLongitudeLatitude((int)CurrentLocation.MapTableData.Longitude, CurrentLocation.MapTableData.Latitude);
            DiscoveredLocation dl = discoveredLocations[mapPixelID];

            if (dl.discoveredBuildings == null)
            {
                return(false);
            }

            // Get discovery data for building
            bool discovered = GetBuildingDiscoveryData(buildingKey, out discoveredBuildingOut);

            return(true);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Gets discovered building data for current location.
        /// </summary>
        /// <param name="buildingKey">Building key in current location.</param>
        /// <param name="discoveredBuildingOut">Building discovery data out.</param>
        /// <returns>True if building discovered, false if building not discovered.</returns>
        public bool GetDiscoveredBuilding(int buildingKey, out DiscoveredBuilding discoveredBuildingOut)
        {
            discoveredBuildingOut = new DiscoveredBuilding();

            // Must have discovered building
            if (!HasDiscoveredBuilding(buildingKey))
            {
                return(false);
            }

            // Get the location discovery for this mapID
            int mapID             = CurrentLocation.MapTableData.MapId;
            DiscoveredLocation dl = discoveredLocations[mapID];

            if (dl.discoveredBuildings == null)
            {
                return(false);
            }

            // Get discovery data for building
            discoveredBuildingOut = dl.discoveredBuildings[buildingKey];

            return(true);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Discover the specified building in current location.
        /// Does nothing if player not inside a location or building already discovered.
        /// </summary>
        /// <param name="buildingKey"></param>
        public void DiscoverBuilding(int buildingKey)
        {
            // Must have a location loaded
            if (!CurrentLocation.Loaded)
            {
                return;
            }

            // Do nothing if building already discovered
            if (HasDiscoveredBuilding(buildingKey))
            {
                return;
            }

            // Get building information
            DiscoveredBuilding db;

            if (!GetBuildingDiscoveryData(buildingKey, out db))
            {
                return;
            }

            // Get location discovery
            int mapID             = CurrentLocation.MapTableData.MapId;
            DiscoveredLocation dl = discoveredLocations[mapID];

            // Ensure the building dict is created
            if (dl.discoveredBuildings == null)
            {
                dl.discoveredBuildings = new Dictionary <int, DiscoveredBuilding>();
            }

            // Add the building and store back to discovered location
            dl.discoveredBuildings.Add(db.buildingKey, db);
            discoveredLocations[mapID] = dl;
        }
Exemplo n.º 13
0
        /// <summary>
        /// Discover current location.
        /// Does nothing if player in wilderness or location already dicovered.
        /// This is performed automatically by PlayerGPS when player enters a location rect.
        /// </summary>
        void DiscoverCurrentLocation()
        {
            // Must have a location loaded
            if (!CurrentLocation.Loaded)
            {
                return;
            }

            // Check if already discovered
            int mapID = CurrentLocation.MapTableData.MapId;

            if (HasDiscoveredLocation(mapID))
            {
                return;
            }

            // Add to discovered locations dict
            DiscoveredLocation dl = new DiscoveredLocation();

            dl.mapID        = mapID;
            dl.regionName   = CurrentLocation.RegionName;
            dl.locationName = CurrentLocation.Name;
            discoveredLocations.Add(mapID, dl);
        }