/// <summary> /// Gets building information from current location. /// Does not change discovery state for building. /// </summary> /// <param name="buildingKey">Key of building to query.</param> bool GetBuildingDiscoveryData(int buildingKey, out DiscoveredBuilding buildingDiscoveryData) { buildingDiscoveryData = new DiscoveredBuilding(); // Get building directory for location BuildingDirectory buildingDirectory = GameManager.Instance.StreamingWorld.GetCurrentBuildingDirectory(); if (!buildingDirectory) { return(false); } // Get detailed building data from directory BuildingSummary buildingSummary; if (!buildingDirectory.GetBuildingSummary(buildingKey, out buildingSummary)) { int layoutX, layoutY, recordIndex; BuildingDirectory.ReverseBuildingKey(buildingKey, out layoutX, out layoutY, out recordIndex); Debug.LogFormat("Unable to find expected building key {0} in {1}.{2}", buildingKey, buildingDirectory.LocationData.RegionName, buildingDirectory.LocationData.Name); Debug.LogFormat("LayoutX={0}, LayoutY={1}, RecordIndex={2}", layoutX, layoutY, recordIndex); return(false); } // Resolve name by building type string buildingName; if (RMBLayout.IsResidence(buildingSummary.BuildingType)) { // Residence // TODO: Link to quest system active sites buildingName = HardStrings.residence; } else { // Fixed building name buildingName = BuildingNames.GetName( buildingSummary.NameSeed, buildingSummary.BuildingType, buildingSummary.FactionId, buildingDirectory.LocationData.Name, buildingDirectory.LocationData.RegionName); } // Add to data buildingDiscoveryData.buildingKey = buildingKey; buildingDiscoveryData.displayName = buildingName; buildingDiscoveryData.factionID = buildingSummary.FactionId; buildingDiscoveryData.quality = buildingSummary.Quality; buildingDiscoveryData.buildingType = buildingSummary.BuildingType; return(true); }
// Output building info to HUD private void PresentBuildingInfo(StaticBuilding building) { // Get building directory for location BuildingDirectory buildingDirectory = GameManager.Instance.StreamingWorld.GetCurrentBuildingDirectory(); if (!buildingDirectory) { return; } // Get detailed building data from directory BuildingSummary buildingSummary; if (!buildingDirectory.GetBuildingSummary(building.buildingKey, out buildingSummary)) { int layoutX, layoutY, recordIndex; BuildingDirectory.ReverseBuildingKey(building.buildingKey, out layoutX, out layoutY, out recordIndex); Debug.LogFormat("Unable to find expected building key {0} in {1}.{2}", building.buildingKey, buildingDirectory.LocationData.RegionName, buildingDirectory.LocationData.Name); Debug.LogFormat("LayoutX={0}, LayoutY={1}, RecordIndex={2}", layoutX, layoutY, recordIndex); throw new Exception("Error finding building key in directory."); } // Resolve name by building type string buildingName; if (RMBLayout.IsResidence(buildingSummary.BuildingType)) { // Residence // TODO: Link to quest system active sites buildingName = HardStrings.residence; } else { // Fixed building name buildingName = BuildingNames.GetName( buildingSummary.NameSeed, buildingSummary.BuildingType, buildingSummary.FactionId, buildingDirectory.LocationData.Name, buildingDirectory.LocationData.RegionName); } // Output building name to HUD DaggerfallUI.AddHUDText(buildingName); }
/// <summary> /// Gets building information from current location. /// Does not change discovery state for building. /// </summary> /// <param name="buildingKey">Key of building to query.</param> bool GetBuildingDiscoveryData(int buildingKey, out DiscoveredBuilding buildingDiscoveryData) { buildingDiscoveryData = new DiscoveredBuilding(); // Get building directory for location BuildingDirectory buildingDirectory = GameManager.Instance.StreamingWorld.GetCurrentBuildingDirectory(); if (!buildingDirectory) { return(false); } // Get detailed building data from directory BuildingSummary buildingSummary; if (!buildingDirectory.GetBuildingSummary(buildingKey, out buildingSummary)) { int layoutX, layoutY, recordIndex; BuildingDirectory.ReverseBuildingKey(buildingKey, out layoutX, out layoutY, out recordIndex); Debug.LogFormat("Unable to find expected building key {0} in {1}.{2}", buildingKey, buildingDirectory.LocationData.RegionName, buildingDirectory.LocationData.Name); Debug.LogFormat("LayoutX={0}, LayoutY={1}, RecordIndex={2}", layoutX, layoutY, recordIndex); return(false); } // Resolve name by building type string buildingName; if (RMBLayout.IsResidence(buildingSummary.BuildingType)) { // Residence buildingName = HardStrings.residence; // Link to quest system active sites // note Nystul: do this via TalkManager, this might seem odd at first glance but there is a reason to do so: // get info from TalkManager if pc learned about existence of the building (i.e. its name) // either through dialog ("add dialog" or by dialog-link) or quest (quest did not hide location via "dialog link" command) bool pcLearnedAboutExistence = false; bool receivedDirectionalHints = false; bool locationWasMarkedOnMapByNPC = false; string overrideBuildingName = string.Empty; if (GameManager.Instance.TalkManager.IsBuildingQuestResource(buildingSummary.buildingKey, ref overrideBuildingName, ref pcLearnedAboutExistence, ref receivedDirectionalHints, ref locationWasMarkedOnMapByNPC)) { if (pcLearnedAboutExistence) { buildingName = overrideBuildingName; } } } else { // Fixed building name buildingName = BuildingNames.GetName( buildingSummary.NameSeed, buildingSummary.BuildingType, buildingSummary.FactionId, buildingDirectory.LocationData.Name, buildingDirectory.LocationData.RegionName); } // Add to data buildingDiscoveryData.buildingKey = buildingKey; buildingDiscoveryData.displayName = buildingName; buildingDiscoveryData.factionID = buildingSummary.FactionId; buildingDiscoveryData.quality = buildingSummary.Quality; buildingDiscoveryData.buildingType = buildingSummary.BuildingType; return(true); }
IEnumerator GenerateMarker() { if (marker.buildingSummary.BuildingType == DFLocation.BuildingTypes.AllValid) { yield return(null); } //setup and assign the final world position and rotation using the building, block, and tallest spot cordinates. This places the indicators .2f above the original building model. //remove collider from mes. //marker.attachedMesh.GetComponent<Collider>().name = marker.attachedMesh.name; if (marker.attachedMesh != null) { marker.markerBounds = marker.attachedMesh.GetComponent <Renderer>().bounds; } MeshRenderer currentMeshRender; Renderer currentRenderer; //gets buildings largest side size for label multiplier. float sizeMultiplier = (marker.staticBuilding.size.x + marker.staticBuilding.size.z) * .033f; GameObject hitDetector = GameObject.CreatePrimitive(PrimitiveType.Quad); currentRenderer = hitDetector.GetComponent <Renderer>(); currentRenderer.enabled = false; hitDetector.name = string.Concat(marker.buildingSummary.BuildingType.ToString(), " Hit Detector ", marker.buildingSummary.buildingKey); hitDetector.transform.position = marker.attachedMesh.GetComponent <Renderer>().bounds.center + new Vector3(0, 12f, 0); hitDetector.transform.localScale = new Vector3(sizeMultiplier * Minimap.MinimapInstance.iconSetupSize * 10, sizeMultiplier * Minimap.MinimapInstance.iconSetupSize * 10, sizeMultiplier * Minimap.MinimapInstance.iconSetupSize * 10); currentRenderer.shadowCastingMode = 0; hitDetector.transform.Rotate(90, 0, 0); hitDetector.GetComponent <MeshCollider>().isTrigger = false; hitDetector.transform.SetParent(marker.attachedMesh.transform); Destroy(hitDetector.GetComponent <MeshRenderer>()); //Destroy(hitDetector.GetComponent<MeshCollider>()); marker.attachedDoorIcon = GameObject.CreatePrimitive(PrimitiveType.Quad); currentRenderer = marker.attachedDoorIcon.GetComponent <Renderer>(); currentRenderer.enabled = false; currentMeshRender = marker.attachedDoorIcon.GetComponent <MeshRenderer>(); marker.attachedDoorIcon.GetComponent <Renderer>().enabled = false; marker.attachedDoorIcon.name = string.Concat(marker.buildingSummary.BuildingType.ToString(), " Door ", marker.buildingSummary.buildingKey); //marker.attachedIcon.transform.Rotate(90, 0, 0); marker.attachedDoorIcon.layer = Minimap.layerMinimap; currentRenderer.material = Minimap.iconMarkerMaterial; currentRenderer.shadowCastingMode = 0; currentMeshRender.material.mainTexture = Minimap.minimapBuildingManager.doorIconTexture; marker.attachedDoorIcon.transform.position = new Vector3(marker.doorPosition.x, marker.position.y + 8f, marker.doorPosition.z); marker.attachedDoorIcon.transform.localScale = new Vector3(sizeMultiplier * Minimap.MinimapInstance.iconSetupSize * 5, sizeMultiplier * Minimap.MinimapInstance.iconSetupSize * 5, .1f); marker.attachedDoorIcon.transform.Rotate(new Vector3(90, 0, 0)); currentMeshRender.material.enableInstancing = true; currentMeshRender.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off; currentMeshRender.motionVectorGenerationMode = MotionVectorGenerationMode.ForceNoMotion; //remove collider from mes. Destroy(marker.attachedDoorIcon.GetComponent <Collider>()); Destroy(marker.attachedDoorIcon.GetComponent <MeshCollider>()); if (marker.questActive) { //setup icons for building. marker.attachedQuestIcon = GameObject.CreatePrimitive(PrimitiveType.Quad); Renderer iconRender = marker.attachedQuestIcon.GetComponent <Renderer>(); iconRender.enabled = false; marker.attachedQuestIcon.name = "Quest Icon"; marker.attachedQuestIcon.transform.position = marker.attachedMesh.GetComponent <Renderer>().bounds.max + new Vector3(-2.5f, 4f, -2.5f); marker.attachedQuestIcon.transform.localScale = new Vector3(sizeMultiplier * Minimap.MinimapInstance.iconSetupSize * .5f, 0, sizeMultiplier * Minimap.MinimapInstance.iconSetupSize * .5f); marker.attachedQuestIcon.transform.Rotate(0, 0, 180); marker.attachedQuestIcon.layer = Minimap.layerMinimap; iconRender.material = Minimap.iconMarkerMaterial; iconRender.material.color = Color.white; iconRender.shadowCastingMode = 0; iconRender.material.mainTexture = ImageReader.GetTexture("TEXTURE.208", 1, 0, true, 0); //remove collider from mes. Destroy(marker.attachedQuestIcon.GetComponent <MeshCollider>()); } //setup icons for building. marker.attachedIcon = GameObject.CreatePrimitive(PrimitiveType.Quad); currentRenderer = marker.attachedIcon.GetComponent <Renderer>(); currentMeshRender = marker.attachedIcon.GetComponent <MeshRenderer>(); currentRenderer.enabled = false; marker.attachedIcon.name = string.Concat(marker.buildingSummary.BuildingType.ToString(), " Icon ", marker.buildingSummary.buildingKey); marker.attachedIcon.transform.position = marker.attachedMesh.GetComponent <Renderer>().bounds.center + new Vector3(0, 4f, 0); //marker.attachedIcon.transform.localScale = new Vector3(sizeMultiplier * Minimap.MinimapInstance.iconSetupSize, sizeMultiplier * Minimap.MinimapInstance.iconSetupSize, sizeMultiplier * Minimap.MinimapInstance.iconSetupSize) * 2; //marker.attachedIcon.transform.Rotate(90, 0, 0); marker.attachedIcon.layer = Minimap.layerMinimap; currentMeshRender.material = Minimap.iconMarkerMaterial; currentMeshRender.shadowCastingMode = 0; currentMeshRender.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off; currentMeshRender.motionVectorGenerationMode = MotionVectorGenerationMode.ForceNoMotion; //remove collider from mes. Destroy(marker.attachedIcon.GetComponent <MeshCollider>()); //sets up text mesh pro object and settings. marker.attachedLabel = GameObject.CreatePrimitive(PrimitiveType.Quad); marker.attachedLabel.transform.position = marker.attachedMesh.GetComponent <Renderer>().bounds.center + new Vector3(0, 6f, 0); marker.attachedLabel.SetActive(false); TextMeshPro labelutility = marker.attachedLabel.AddComponent <TMPro.TextMeshPro>(); marker.attachedLabel.layer = Minimap.layerMinimap; RectTransform textboxRect = marker.attachedLabel.GetComponent <RectTransform>(); labelutility.enableAutoSizing = true; textboxRect.sizeDelta = new Vector2(100, 100); labelutility.isOrthographic = true; labelutility.fontMaterial = Minimap.labelMaterial; labelutility.fontMaterial.SetColor(ShaderUtilities.ID_OutlineColor, new Color(0.0f, 0.0f, 0.0f)); labelutility.material.enableInstancing = true; labelutility.characterSpacing = 2; labelutility.fontSizeMin = 26; labelutility.enableWordWrapping = true; labelutility.fontStyle = TMPro.FontStyles.Bold; labelutility.outlineColor = new Color32(0, 0, 0, 255); labelutility.outlineWidth = .33f; currentMeshRender.material.enableInstancing = true; currentMeshRender.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off; currentMeshRender.motionVectorGenerationMode = MotionVectorGenerationMode.ForceNoMotion; if (marker.staticBuilding.size.x < marker.staticBuilding.size.z) { marker.attachedLabel.transform.localScale = new Vector3(marker.staticBuilding.size.x * .0105f, marker.staticBuilding.size.x * .0105f, marker.staticBuilding.size.x * .0105f); } else { marker.attachedLabel.transform.localScale = new Vector3(marker.staticBuilding.size.z * .0105f, marker.staticBuilding.size.z * .0105f, marker.staticBuilding.size.z * .0105f); } marker.attachedLabel.transform.Rotate(new Vector3(90, 0, 0)); labelutility.alignment = TMPro.TextAlignmentOptions.Center; marker.attachedLabel.name = string.Concat(marker.buildingSummary.BuildingType.ToString(), " Label ", marker.buildingSummary.buildingKey); labelutility.ForceMeshUpdate(); var words = Regex.Matches(marker.buildingSummary.BuildingType.ToString(), @"([A-Z][a-z]+)") .Cast <Match>() .Select(m => m.Value); var withSpaces = string.Join(" ", words); marker.dynamicBuildingName = withSpaces.ToString(); PlayerGPS.DiscoveredBuilding discoveredBuilding; if (GameManager.Instance.PlayerGPS.GetDiscoveredBuilding(marker.buildingSummary.buildingKey, out discoveredBuilding)) { marker.dynamicBuildingName = BuildingNames.GetName(marker.buildingSummary.NameSeed, marker.buildingSummary.BuildingType, marker.buildingSummary.FactionId, marker.buildingLocation.Name, marker.buildingLocation.RegionName); } labelutility.text = marker.dynamicBuildingName; labelutility.color = Color.magenta; //remove collider from mes. Destroy(marker.attachedLabel.GetComponent <Collider>()); Material iconTempMat = marker.attachedIcon.GetComponent <MeshRenderer>().material; //Texture2D iconTexture = null; switch (marker.buildingSummary.BuildingType) { case DFLocation.BuildingTypes.Tavern: marker.iconGroup = Minimap.MarkerGroups.Taverns; marker.iconTexture = ImageReader.GetTexture("TEXTURE.205", 0, 0, true, 0); iconTempMat.mainTexture = marker.iconTexture; marker.attachedIcon.transform.localScale = new Vector3(sizeMultiplier * .898f, sizeMultiplier); textboxRect.sizeDelta = new Vector2(150, 100); break; case DFLocation.BuildingTypes.ClothingStore: marker.iconTexture = ImageReader.GetTexture("TEXTURE.204", 0, 0, true, 0); iconTempMat.mainTexture = marker.iconTexture; marker.attachedIcon.transform.localScale = new Vector3(sizeMultiplier, sizeMultiplier * .68f); textboxRect.sizeDelta = new Vector2(150, 100); marker.iconGroup = Minimap.MarkerGroups.Shops; break; case DFLocation.BuildingTypes.FurnitureStore: marker.iconTexture = ImageReader.GetTexture("TEXTURE.200", 14, 0, true, 0); iconTempMat.mainTexture = marker.iconTexture; marker.attachedIcon.transform.localScale = new Vector3(sizeMultiplier * .66f, sizeMultiplier); textboxRect.sizeDelta = new Vector2(150, 100); marker.iconGroup = Minimap.MarkerGroups.Shops; break; case DFLocation.BuildingTypes.Alchemist: marker.iconTexture = ImageReader.GetTexture("TEXTURE.253", 41, 0, true, 0); iconTempMat.mainTexture = marker.iconTexture; marker.attachedIcon.transform.localScale = new Vector3(sizeMultiplier * .885f, sizeMultiplier); marker.iconGroup = Minimap.MarkerGroups.Shops; textboxRect.sizeDelta = new Vector2(150, 100); break; case DFLocation.BuildingTypes.Bank: marker.iconTexture = ImageReader.GetTexture("TEXTURE.216", 0, 0, true, 0); iconTempMat.mainTexture = marker.iconTexture; marker.attachedIcon.transform.localScale = new Vector3(sizeMultiplier * 1.63f, sizeMultiplier * 1.25f); marker.iconGroup = Minimap.MarkerGroups.Shops; textboxRect.sizeDelta = new Vector2(150, 100); break; case DFLocation.BuildingTypes.Bookseller: marker.iconTexture = ImageReader.GetTexture("TEXTURE.209", 0, 0, true, 0); iconTempMat.mainTexture = marker.iconTexture; marker.attachedIcon.transform.localScale = new Vector3(sizeMultiplier, sizeMultiplier * .52f); textboxRect.sizeDelta = new Vector2(150, 100); marker.iconGroup = Minimap.MarkerGroups.Shops; break; case DFLocation.BuildingTypes.GemStore: //needs updated. THis is copy paste record. marker.iconTexture = ImageReader.GetTexture("TEXTURE.216", 19, 0, true, 0); iconTempMat.mainTexture = marker.iconTexture; marker.attachedIcon.transform.localScale = new Vector3(sizeMultiplier, sizeMultiplier * .79f); textboxRect.sizeDelta = new Vector2(150, 100); marker.iconGroup = Minimap.MarkerGroups.Shops; break; case DFLocation.BuildingTypes.GeneralStore: marker.iconTexture = ImageReader.GetTexture("TEXTURE.253", 70, 0, true, 0); iconTempMat.mainTexture = marker.iconTexture; marker.attachedIcon.transform.localScale = new Vector3(sizeMultiplier * 1.37f, sizeMultiplier); textboxRect.sizeDelta = new Vector2(150, 100); marker.iconGroup = Minimap.MarkerGroups.Shops; break; case DFLocation.BuildingTypes.PawnShop: marker.iconTexture = ImageReader.GetTexture("TEXTURE.216", 33, 0, true, 0); iconTempMat.mainTexture = marker.iconTexture; marker.attachedIcon.transform.localScale = new Vector3(sizeMultiplier * 1.5f, sizeMultiplier * .37f); textboxRect.sizeDelta = new Vector2(150, 100); marker.iconGroup = Minimap.MarkerGroups.Shops; break; case DFLocation.BuildingTypes.Armorer: marker.iconTexture = ImageReader.GetTexture("TEXTURE.249", 05, 0, true, 0); iconTempMat.mainTexture = marker.iconTexture; marker.attachedIcon.transform.localScale = new Vector3(sizeMultiplier * 1.02f, sizeMultiplier * 1.25f); marker.iconGroup = Minimap.MarkerGroups.Blacksmiths; textboxRect.sizeDelta = new Vector2(150, 100); break; case DFLocation.BuildingTypes.WeaponSmith: marker.iconTexture = ImageReader.GetTexture("TEXTURE.207", 00, 0, true, 0); iconTempMat.mainTexture = marker.iconTexture; marker.attachedIcon.transform.localScale = new Vector3(sizeMultiplier * 1.1f, sizeMultiplier * 1.2f); marker.iconGroup = Minimap.MarkerGroups.Blacksmiths; textboxRect.sizeDelta = new Vector2(150, 100); break; case DFLocation.BuildingTypes.Temple: marker.iconTexture = ImageReader.GetTexture("TEXTURE.333", 0, 0, true, 0); iconTempMat.mainTexture = marker.iconTexture; marker.attachedIcon.transform.localScale = new Vector3(sizeMultiplier, sizeMultiplier * .5f); textboxRect.sizeDelta = new Vector2(150, 100); marker.iconGroup = Minimap.MarkerGroups.Utilities; break; case DFLocation.BuildingTypes.Library: marker.iconTexture = ImageReader.GetTexture("TEXTURE.253", 28, 0, true, 0); iconTempMat.mainTexture = marker.iconTexture; marker.attachedIcon.transform.localScale = new Vector3(sizeMultiplier * .73f, sizeMultiplier); textboxRect.sizeDelta = new Vector2(150, 100); marker.iconGroup = Minimap.MarkerGroups.Utilities; break; case DFLocation.BuildingTypes.GuildHall: marker.iconTexture = ImageReader.GetTexture("TEXTURE.333", 4, 0, true, 0); iconTempMat.mainTexture = marker.iconTexture; marker.attachedIcon.transform.localScale = new Vector3(sizeMultiplier * 1.25f, sizeMultiplier * .625f); textboxRect.sizeDelta = new Vector2(150, 100); marker.iconGroup = Minimap.MarkerGroups.Utilities; break; case DFLocation.BuildingTypes.Palace: marker.iconGroup = Minimap.MarkerGroups.Government; marker.iconTexture = ImageReader.GetTexture("TEXTURE.216", 6, 0, true, 0); iconTempMat.mainTexture = marker.iconTexture; marker.attachedIcon.transform.localScale = new Vector3(sizeMultiplier * .86f, sizeMultiplier * .7f); textboxRect.sizeDelta = new Vector2(150, 100); break; case DFLocation.BuildingTypes.House1: case DFLocation.BuildingTypes.House2: case DFLocation.BuildingTypes.House3: case DFLocation.BuildingTypes.House4: case DFLocation.BuildingTypes.House5: case DFLocation.BuildingTypes.House6: marker.iconGroup = Minimap.MarkerGroups.Houses; marker.attachedLabel.GetComponent <TMPro.TextMeshPro>().text = "House"; marker.iconTexture = ImageReader.GetTexture("TEXTURE.211", 37, 0, true, 0); iconTempMat.mainTexture = marker.iconTexture; marker.attachedIcon.transform.localScale = new Vector3(sizeMultiplier * 1.09f, sizeMultiplier); break; case DFLocation.BuildingTypes.HouseForSale: marker.iconGroup = Minimap.MarkerGroups.Houses; marker.attachedLabel.GetComponent <TMPro.TextMeshPro>().text = "House Sale"; marker.iconTexture = ImageReader.GetTexture("TEXTURE.212", 4, 0, true, 0); iconTempMat.mainTexture = marker.iconTexture; marker.attachedIcon.transform.localScale = new Vector3(sizeMultiplier, sizeMultiplier * 1.77f); break; } marker.attachedIcon.transform.localScale = new Vector3(marker.attachedIcon.transform.localScale.x * 15, marker.attachedIcon.transform.localScale.y * 15); marker.attachedIcon.transform.rotation = Quaternion.Euler(90, 0, 0); marker.attachedIcon.GetComponent <MeshRenderer>().lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off; marker.attachedIcon.GetComponent <MeshRenderer>().motionVectorGenerationMode = MotionVectorGenerationMode.ForceNoMotion; marker.position = new Vector3(marker.position.x, marker.position.y, marker.position.z); //updates materials based on user settings saved to dictionary. //grabbing the individual materials within the building mesh and assigning it to mesh array. Material[] buildingMaterials = marker.attachedMesh.GetComponent <MeshRenderer>().materials; //List<Material> materialList = new List<Material>(buildingMaterials); //running through dumped material array to assign each mesh material on model the proper transperency texture. for (int i = 0; i < buildingMaterials.Length; i++) { string textureName = buildingMaterials[i].name.Split(new char[] { ' ' })[0]; switch (textureName) { case "TEXTURE.069": case "TEXTURE.070": case "TEXTURE.137": case "TEXTURE.169": case "TEXTURE.170": case "TEXTURE.171": case "TEXTURE.337": case "TEXTURE.369": case "TEXTURE.370": case "TEXTURE.469": case "TEXTURE.470": buildingMaterials[i] = Minimap.minimapBuildingManager.buildingMaterialDict[marker.iconGroup]; buildingMaterials[i].color = Minimap.iconGroupColors[marker.iconGroup]; break; default: Destroy(buildingMaterials[i]); buildingMaterials[i] = null; break; } } //buildingMaterials = materialList.ToArray(); marker.attachedMesh.GetComponent <MeshRenderer>().sharedMaterials = buildingMaterials; generatedMarker = true; yield break; }
/// <summary> /// Generate a list of potential sites based on building type. /// This uses actual map layout and block data rather than the (often inaccurate) list of building in map data. /// Specify BuildingTypes.AllValid to find all valid building types /// </summary> SiteDetails[] CollectQuestSitesOfBuildingType(DFLocation location, DFLocation.BuildingTypes buildingType) { // Valid building types for valid search int[] validBuildingTypes = { 0, 2, 3, 5, 6, 8, 9, 11, 12, 13, 14, 15, 17, 18, 19, 20 }; List <SiteDetails> foundSites = new List <SiteDetails>(); // Iterate through all blocks DFBlock[] blocks; RMBLayout.GetLocationBuildingData(location, out blocks); int width = location.Exterior.ExteriorData.Width; int height = location.Exterior.ExteriorData.Height; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { // Iterate through all buildings in this block int index = y * width + x; BuildingSummary[] buildingSummary = RMBLayout.GetBuildingData(blocks[index], x, y); for (int i = 0; i < buildingSummary.Length; i++) { // When enumAllValid is specified accept all valid building types bool forceAccept = false; if (buildingType == DFLocation.BuildingTypes.AllValid) { for (int j = 0; j < validBuildingTypes.Length; j++) { if (validBuildingTypes[j] == (int)buildingSummary[i].BuildingType) { forceAccept = true; break; } } } // Match building against required type if (buildingSummary[i].BuildingType == buildingType || forceAccept) { // Building must be a valid quest site QuestMarker[] questSpawnMarkers, questItemMarkers; EnumerateBuildingQuestMarkers(blocks[index], i, out questSpawnMarkers, out questItemMarkers); if (!ValidateQuestMarkers(questSpawnMarkers, questItemMarkers)) { continue; } // Get building name based on type string buildingName; if (RMBLayout.IsResidence(buildingType)) { // Generate a random surname for this residence DFRandom.srand(Time.renderedFrameCount); string surname = DaggerfallUnity.Instance.NameHelper.Surname(Utility.NameHelper.BankTypes.Breton); buildingName = HardStrings.theNamedResidence.Replace("%s", surname); } else { // Use fixed name buildingName = BuildingNames.GetName( buildingSummary[i].NameSeed, buildingSummary[i].BuildingType, buildingSummary[i].FactionId, location.Name, location.RegionName); } // Configure new site details SiteDetails site = new SiteDetails(); site.questUID = ParentQuest.UID; site.siteType = SiteTypes.Building; site.mapId = location.MapTableData.MapId; site.locationId = location.Exterior.ExteriorData.LocationId; site.regionName = location.RegionName; site.locationName = location.Name; site.buildingKey = buildingSummary[i].buildingKey; site.buildingName = buildingName; site.questSpawnMarkers = questSpawnMarkers; site.questItemMarkers = questItemMarkers; // Asssign markers only if available if (questSpawnMarkers != null) { siteDetails.selectedQuestSpawnMarker = UnityEngine.Random.Range(0, questSpawnMarkers.Length); } if (questItemMarkers != null) { siteDetails.selectedQuestItemMarker = UnityEngine.Random.Range(0, questItemMarkers.Length); } foundSites.Add(site); } } } } return(foundSites.ToArray()); }
private void GetBuildingList() { listBuildings = new List <BuildingInfo>(); ContentReader.MapSummary mapSummary; DFPosition mapPixel = GameManager.Instance.PlayerGPS.CurrentMapPixel; if (!DaggerfallUnity.Instance.ContentReader.HasLocation(mapPixel.X, mapPixel.Y, out mapSummary)) { // no location found return; // do nothing } DFLocation location = DaggerfallUnity.Instance.ContentReader.MapFileReader.GetLocation(mapSummary.RegionIndex, mapSummary.MapIndex); if (!location.Loaded) { // Location not loaded, something went wrong DaggerfallUnity.LogMessage("error when loading location for in TalkManager.GetBuildingList", true); } DaggerfallExteriorAutomap.BlockLayout[] blockLayout = GameManager.Instance.ExteriorAutomap.ExteriorLayout; DFBlock[] blocks; RMBLayout.GetLocationBuildingData(location, out blocks); int width = location.Exterior.ExteriorData.Width; int height = location.Exterior.ExteriorData.Height; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int index = y * width + x; BuildingSummary[] buildingsInBlock = RMBLayout.GetBuildingData(blocks[index], x, y); foreach (BuildingSummary buildingSummary in buildingsInBlock) { try { string locationName = BuildingNames.GetName(buildingSummary.NameSeed, buildingSummary.BuildingType, buildingSummary.FactionId, location.Name, location.RegionName); BuildingInfo item; item.buildingType = buildingSummary.BuildingType; item.name = locationName; item.buildingKey = buildingSummary.buildingKey; // compute building position in map coordinate system float xPosBuilding = blockLayout[index].rect.xpos + (int)(buildingSummary.Position.x / (BlocksFile.RMBDimension * MeshReader.GlobalScale) * DaggerfallExteriorAutomap.blockSizeWidth) - GameManager.Instance.ExteriorAutomap.LocationWidth * DaggerfallExteriorAutomap.blockSizeWidth * 0.5f; float yPosBuilding = blockLayout[index].rect.ypos + (int)(buildingSummary.Position.z / (BlocksFile.RMBDimension * MeshReader.GlobalScale) * DaggerfallExteriorAutomap.blockSizeHeight) - GameManager.Instance.ExteriorAutomap.LocationHeight * DaggerfallExteriorAutomap.blockSizeHeight * 0.5f; item.position = new Vector2(xPosBuilding, yPosBuilding); listBuildings.Add(item); } catch (Exception e) { string exceptionMessage = String.Format("exception occured in function BuildingNames.GetName (exception message: " + e.Message + @") with params: seed: {0}, type: {1}, factionID: {2}, locationName: {3}, regionName: {4}", buildingSummary.NameSeed, buildingSummary.BuildingType, buildingSummary.FactionId, location.Name, location.RegionName); DaggerfallUnity.LogMessage(exceptionMessage, true); } } } } }