/// <summary> /// Gets settings for specified map climate. /// </summary> /// <param name="worldClimate">Climate value from CLIMATE.PAK. Valid range is 223-232.</param> /// <returns>Climate settings for specified world climate value.</returns> static public DFLocation.ClimateSettings GetWorldClimateSettings(int worldClimate) { // Create settings struct DFLocation.ClimateSettings settings = new DFLocation.ClimateSettings(); settings.WorldClimate = worldClimate; // Set based on world climate switch (worldClimate) { case 223: settings.ClimateType = DFLocation.ClimateBaseType.Swamp; settings.GroundArchive = 402; settings.SceneryArchive = 502; settings.SkyArchive = 29; break; case 224: settings.ClimateType = DFLocation.ClimateBaseType.Desert; settings.GroundArchive = 2; settings.SceneryArchive = 503; settings.SkyArchive = 9; break; case 225: settings.ClimateType = DFLocation.ClimateBaseType.Desert; settings.GroundArchive = 2; settings.SceneryArchive = 503; settings.SkyArchive = 9; break; case 226: settings.ClimateType = DFLocation.ClimateBaseType.Mountain; settings.GroundArchive = 102; settings.SceneryArchive = 510; settings.SkyArchive = 1; break; case 227: settings.ClimateType = DFLocation.ClimateBaseType.Swamp; settings.GroundArchive = 402; settings.SceneryArchive = 500; settings.SkyArchive = 29; break; case 228: settings.ClimateType = DFLocation.ClimateBaseType.Swamp; settings.GroundArchive = 402; settings.SceneryArchive = 502; settings.SkyArchive = 29; break; case 229: settings.ClimateType = DFLocation.ClimateBaseType.Desert; settings.GroundArchive = 2; settings.SceneryArchive = 501; settings.SkyArchive = 25; break; case 230: settings.ClimateType = DFLocation.ClimateBaseType.Mountain; settings.GroundArchive = 102; settings.SceneryArchive = 504; settings.SkyArchive = 17; break; case 231: settings.ClimateType = DFLocation.ClimateBaseType.Temperate; settings.GroundArchive = 302; settings.SceneryArchive = 504; settings.SkyArchive = 17; break; case 232: settings.ClimateType = DFLocation.ClimateBaseType.Temperate; settings.GroundArchive = 302; settings.SceneryArchive = 508; settings.SkyArchive = 17; break; default: throw new Exception("Unknown world climate encountered."); } return(settings); }
private void UpdateWorldInfo(int x, int y) { // Requires DaggerfallUnity to be ready if (!ReadyCheck()) { return; } // Requires MAPS.BSA connection if (dfUnity.ContentReader.MapFileReader == null) { return; } // Get climate and politic data currentClimateIndex = dfUnity.ContentReader.MapFileReader.GetClimateIndex(x, y); currentPoliticIndex = dfUnity.ContentReader.MapFileReader.GetPoliticIndex(x, y); climateSettings = MapsFile.GetWorldClimateSettings(currentClimateIndex); if (currentPoliticIndex >= 128) { regionName = dfUnity.ContentReader.MapFileReader.GetRegionName(currentPoliticIndex - 128); } else if (currentPoliticIndex == 64) { regionName = "Ocean"; } else { regionName = "Unknown"; } // Get region data currentRegion = dfUnity.ContentReader.MapFileReader.GetRegion(CurrentRegionIndex); // Get location data ContentReader.MapSummary mapSummary; if (dfUnity.ContentReader.HasLocation(x, y, out mapSummary)) { currentLocation = dfUnity.ContentReader.MapFileReader.GetLocation(mapSummary.RegionIndex, mapSummary.MapIndex); hasCurrentLocation = true; CalculateWorldLocationRect(); } else { currentLocation = new DFLocation(); hasCurrentLocation = false; ClearWorldLocationRect(); } // Get location type if (hasCurrentLocation) { if (currentRegion.MapTable == null) { DaggerfallUnity.LogMessage(string.Format("PlayerGPS: Location {0} in region{1} has a null MapTable.", currentLocation.Name, currentLocation.RegionName)); } else { currentLocationType = currentRegion.MapTable[mapSummary.MapIndex].LocationType; } } }
// Drops nature flats based on random chance scaled by simple rules public static void LayoutNatureBillboards(DaggerfallTerrain dfTerrain, DaggerfallBillboardBatch dfBillboardBatch, float terrainScale) { const float maxSteepness = 50f; // 50 const float chanceOnDirt = 0.2f; // 0.2 const float chanceOnGrass = 0.9f; // 0.4 const float chanceOnStone = 0.05f; // 0.05 // Get terrain Terrain terrain = dfTerrain.gameObject.GetComponent <Terrain>(); if (!terrain) { return; } // Get terrain data TerrainData terrainData = terrain.terrainData; if (!terrainData) { return; } // Remove exiting billboards dfBillboardBatch.Clear(); // Seed random with terrain key UnityEngine.Random.seed = MakeTerrainKey(dfTerrain.MapPixelX, dfTerrain.MapPixelY); // Just layout some random flats spread evenly across entire map pixel area // Flats are aligned with tiles, max 127x127 in billboard batch Vector2 tilePos = Vector2.zero; float scale = terrainData.heightmapScale.x; int dim = TerrainHelper.terrainTileDim - 1; for (int y = 0; y < dim; y++) { for (int x = 0; x < dim; x++) { // Reject based on steepness float steepness = terrainData.GetSteepness((float)x / dim, (float)y / dim); if (steepness > maxSteepness) { continue; } // Reject if inside location rect // Rect is expanded slightly to give extra clearance around locations tilePos.x = x; tilePos.y = y; const int natureClearance = 4; Rect rect = dfTerrain.MapData.locationRect; if (rect.x > 0 && rect.y > 0) { rect.xMin -= natureClearance; rect.xMin += natureClearance; rect.yMin -= natureClearance; rect.yMax += natureClearance; if (rect.Contains(tilePos)) { continue; } } // Chance scaled based on map pixel height // This tends to produce sparser lowlands and denser highlands // Adjust or remove clamp range to influence nature generation float elevationScale = (dfTerrain.MapData.worldHeight / 128f); elevationScale = Mathf.Clamp(elevationScale, 0.4f, 1.0f); // Chance scaled by base climate type float climateScale = 1.0f; DFLocation.ClimateSettings climate = MapsFile.GetWorldClimateSettings(dfTerrain.MapData.worldClimate); switch (climate.ClimateType) { case DFLocation.ClimateBaseType.Desert: // Just lower desert for now climateScale = 0.25f; break; } // Chance also determined by tile type WorldSample sample = TerrainHelper.GetSample(ref dfTerrain.MapData.samples, x, y); if (sample.record == 1) { // Dirt if (UnityEngine.Random.Range(0f, 1f) > chanceOnDirt * elevationScale * climateScale) { continue; } } else if (sample.record == 2) { // Grass if (UnityEngine.Random.Range(0f, 1f) > chanceOnGrass * elevationScale * climateScale) { continue; } } else if (sample.record == 3) { // Stone if (UnityEngine.Random.Range(0f, 1f) > chanceOnStone * elevationScale * climateScale) { continue; } } else { // Anything else continue; } // Sample height and position billboard Vector3 pos = new Vector3(x * scale, 0, y * scale); float height = terrain.SampleHeight(pos + terrain.transform.position); pos.y = height; // Reject if too close to water float beachLine = DaggerfallUnity.Instance.TerrainSampler.BeachElevation * terrainScale; if (height < beachLine) { continue; } // Add to batch int record = UnityEngine.Random.Range(1, 32); dfBillboardBatch.AddItem(record, pos); } } // Apply new batch dfBillboardBatch.Apply(); }
// Drops nature flats based on random chance scaled by simple rules public static void LayoutNatureBillboards(DaggerfallTerrain dfTerrain, DaggerfallBillboardBatch dfBillboardBatch, float terrainScale, int terrainDist) { const float maxSteepness = 50f; // 50 const float slopeSinkRatio = 70f; // Sink flats slightly into ground as slope increases to prevent floaty trees. const float baseChanceOnDirt = 0.2f; // 0.2 const float baseChanceOnGrass = 0.9f; // 0.4 const float baseChanceOnStone = 0.05f; // 0.05 // Location Rect is expanded slightly to give extra clearance around locations const int natureClearance = 4; Rect rect = dfTerrain.MapData.locationRect; if (rect.x > 0 && rect.y > 0) { rect.xMin -= natureClearance; rect.xMax += natureClearance; rect.yMin -= natureClearance; rect.yMax += natureClearance; } // Chance scaled based on map pixel height // This tends to produce sparser lowlands and denser highlands // Adjust or remove clamp range to influence nature generation float elevationScale = (dfTerrain.MapData.worldHeight / 128f); elevationScale = Mathf.Clamp(elevationScale, 0.4f, 1.0f); // Chance scaled by base climate type float climateScale = 1.0f; DFLocation.ClimateSettings climate = MapsFile.GetWorldClimateSettings(dfTerrain.MapData.worldClimate); switch (climate.ClimateType) { case DFLocation.ClimateBaseType.Desert: // Just lower desert for now climateScale = 0.25f; break; } float chanceOnDirt = baseChanceOnDirt * elevationScale * climateScale; float chanceOnGrass = baseChanceOnGrass * elevationScale * climateScale; float chanceOnStone = baseChanceOnStone * elevationScale * climateScale; // Get terrain Terrain terrain = dfTerrain.gameObject.GetComponent <Terrain>(); if (!terrain) { return; } // Get terrain data TerrainData terrainData = terrain.terrainData; if (!terrainData) { return; } // Remove exiting billboards dfBillboardBatch.Clear(); MeshReplacement.ClearNatureGameObjects(terrain); // Seed random with terrain key Random.InitState(MakeTerrainKey(dfTerrain.MapPixelX, dfTerrain.MapPixelY)); // Just layout some random flats spread evenly across entire map pixel area // Flats are aligned with tiles, max 16129 billboards per batch Vector2 tilePos = Vector2.zero; int tDim = MapsFile.WorldMapTileDim; int hDim = DaggerfallUnity.Instance.TerrainSampler.HeightmapDimension; float scale = terrainData.heightmapScale.x * (float)hDim / (float)tDim; float maxTerrainHeight = DaggerfallUnity.Instance.TerrainSampler.MaxTerrainHeight; float beachLine = DaggerfallUnity.Instance.TerrainSampler.BeachElevation; for (int y = 0; y < tDim; y++) { for (int x = 0; x < tDim; x++) { // Reject based on steepness float steepness = terrainData.GetSteepness((float)x / tDim, (float)y / tDim); if (steepness > maxSteepness) { continue; } // Reject if inside location rect (expanded slightly to give extra clearance around locations) tilePos.x = x; tilePos.y = y; if (rect.x > 0 && rect.y > 0 && rect.Contains(tilePos)) { continue; } // Chance also determined by tile type int tile = dfTerrain.MapData.tilemapSamples[x, y] & 0x3F; if (tile == 1) { // Dirt if (Random.Range(0f, 1f) > chanceOnDirt) { continue; } } else if (tile == 2) { // Grass if (Random.Range(0f, 1f) > chanceOnGrass) { continue; } } else if (tile == 3) { // Stone if (Random.Range(0f, 1f) > chanceOnStone) { continue; } } else { // Anything else continue; } int hx = (int)Mathf.Clamp(hDim * ((float)x / (float)tDim), 0, hDim - 1); int hy = (int)Mathf.Clamp(hDim * ((float)y / (float)tDim), 0, hDim - 1); float height = dfTerrain.MapData.heightmapSamples[hy, hx] * maxTerrainHeight; // x & y swapped in heightmap for TerrainData.SetHeights() // Reject if too close to water if (height < beachLine) { continue; } // Sample height and position billboard Vector3 pos = new Vector3(x * scale, 0, y * scale); float height2 = terrain.SampleHeight(pos + terrain.transform.position); pos.y = height2 - (steepness / slopeSinkRatio); // Add to batch unless a mesh replacement is found int record = Random.Range(1, 32); if (terrainDist > 1 || !MeshReplacement.ImportNatureGameObject(dfBillboardBatch.TextureArchive, record, terrain, x, y)) { dfBillboardBatch.AddItem(record, pos); } else if (!NatureMeshUsed) { NatureMeshUsed = true; // Signal that nature mesh has been used to initiate extra terrain updates } } } // Apply new batch dfBillboardBatch.Apply(); }
/// <summary> /// Gets settings for specified map climate. /// </summary> /// <param name="worldClimate">Climate value from CLIMATE.PAK. Valid range is 223-232.</param> /// <returns>Climate settings for specified world climate value.</returns> public static DFLocation.ClimateSettings GetWorldClimateSettings(int worldClimate) { // Create settings struct DFLocation.ClimateSettings settings = new DFLocation.ClimateSettings(); settings.WorldClimate = worldClimate; // Set based on world climate switch (worldClimate) { case (int)Climates.Ocean: // Ocean settings.ClimateType = DFLocation.ClimateBaseType.Swamp; settings.GroundArchive = 402; settings.NatureArchive = (int)DFLocation.ClimateTextureSet.Nature_TemperateWoodland; settings.SkyBase = 24; settings.People = FactionFile.FactionRaces.Breton; settings.Names = FactionFile.FactionRaces.Breton; break; case (int)Climates.Desert: settings.ClimateType = DFLocation.ClimateBaseType.Desert; settings.GroundArchive = 2; settings.NatureArchive = (int)DFLocation.ClimateTextureSet.Nature_Desert; settings.SkyBase = 8; settings.People = FactionFile.FactionRaces.Redguard; settings.Names = FactionFile.FactionRaces.Redguard; break; case (int)Climates.Desert2: settings.ClimateType = DFLocation.ClimateBaseType.Desert; settings.GroundArchive = 2; settings.NatureArchive = (int)DFLocation.ClimateTextureSet.Nature_Desert; settings.SkyBase = 8; settings.People = FactionFile.FactionRaces.Redguard; settings.Names = FactionFile.FactionRaces.Redguard; break; case (int)Climates.Mountain: settings.ClimateType = DFLocation.ClimateBaseType.Mountain; settings.GroundArchive = 102; settings.NatureArchive = (int)DFLocation.ClimateTextureSet.Nature_Mountains; settings.SkyBase = 0; settings.People = FactionFile.FactionRaces.Nord; settings.Names = FactionFile.FactionRaces.Nord; break; case (int)Climates.Rainforest: settings.ClimateType = DFLocation.ClimateBaseType.Swamp; settings.GroundArchive = 402; settings.NatureArchive = (int)DFLocation.ClimateTextureSet.Nature_RainForest; settings.SkyBase = 24; settings.People = FactionFile.FactionRaces.Redguard; settings.Names = FactionFile.FactionRaces.Redguard; break; case (int)Climates.Swamp: settings.ClimateType = DFLocation.ClimateBaseType.Swamp; settings.GroundArchive = 402; settings.NatureArchive = (int)DFLocation.ClimateTextureSet.Nature_Swamp; settings.SkyBase = 24; settings.People = FactionFile.FactionRaces.Breton; settings.Names = FactionFile.FactionRaces.Redguard; break; case (int)Climates.Subtropical: settings.ClimateType = DFLocation.ClimateBaseType.Desert; settings.GroundArchive = 2; settings.NatureArchive = (int)DFLocation.ClimateTextureSet.Nature_SubTropical; settings.SkyBase = 24; settings.People = FactionFile.FactionRaces.Breton; settings.Names = FactionFile.FactionRaces.Redguard; break; case (int)Climates.MountainWoods: settings.ClimateType = DFLocation.ClimateBaseType.Mountain; settings.GroundArchive = 102; settings.NatureArchive = (int)DFLocation.ClimateTextureSet.Nature_TemperateWoodland; settings.SkyBase = 16; settings.People = FactionFile.FactionRaces.Nord; settings.Names = FactionFile.FactionRaces.Nord; break; case (int)Climates.Woodlands: settings.ClimateType = DFLocation.ClimateBaseType.Temperate; settings.GroundArchive = 302; settings.NatureArchive = (int)DFLocation.ClimateTextureSet.Nature_TemperateWoodland; settings.SkyBase = 16; settings.People = FactionFile.FactionRaces.Breton; settings.Names = FactionFile.FactionRaces.Breton; break; case (int)Climates.HauntedWoodlands: settings.ClimateType = DFLocation.ClimateBaseType.Temperate; settings.GroundArchive = 302; settings.NatureArchive = (int)DFLocation.ClimateTextureSet.Nature_HauntedWoodlands; settings.SkyBase = 16; settings.People = FactionFile.FactionRaces.Breton; settings.Names = FactionFile.FactionRaces.Breton; break; default: settings.ClimateType = DFLocation.ClimateBaseType.Temperate; settings.GroundArchive = 302; settings.NatureArchive = (int)DFLocation.ClimateTextureSet.Nature_TemperateWoodland; settings.SkyBase = 16; settings.People = FactionFile.FactionRaces.Breton; settings.Names = FactionFile.FactionRaces.Breton; break; } // Set nature set from nature archive index settings.NatureSet = (DFLocation.ClimateTextureSet)settings.NatureArchive; return(settings); }
protected override void LoadContent() { // Create scene scene = new Scene(core); scene.Camera.Position = new Vector3(33.0625f, 4.4375f, 89.8125f); scene.Camera.Transform(327, 0, Vector3.Zero); scene.Camera.Update(); core.ActiveScene = scene; // Disable core input handling core.Input.ActiveDevices = Input.DeviceFlags.None; core.Renderer.ClearColor = clearColor; // Set day/night mode for window textures core.MaterialManager.Daytime = false; // Set climate DFLocation.ClimateSettings climateSettings = MapsFile.DefaultClimateSettings; climateSettings.ClimateType = DFLocation.ClimateBaseType.Swamp; climateSettings.SceneryArchive = 510; // Create level entity DynamicEntity level = new DynamicEntity(core.ActiveScene); // Create block component DaggerfallBlockComponent block = new DaggerfallBlockComponent(core); block.LoadBlock("CASTAA26.RMB", climateSettings, core.ActiveScene, true); level.Components.Add(block); // Attach block flats AddBlockFlats(level, block); // Create directional lights Color lightColor = new Color(100, 100, 200); DynamicEntity directionalLight = new DynamicEntity(core.ActiveScene); directionalLight.Components.Add(new LightComponent(core, Vector3.Normalize(Vector3.Down + Vector3.Right), lightColor, 0.60f)); directionalLight.Components.Add(new LightComponent(core, Vector3.Normalize(Vector3.Forward + Vector3.Left), lightColor, 0.90f)); // Create fireflies in courtyard for (int i = 0; i < 10; i++) { Entities.Firefly firefly = new Entities.Firefly(scene); firefly.Matrix = Matrix.CreateTranslation(62.5f, 3.125f, 43.75f); } // Create fireflies in left of courtyard for (int i = 0; i < 10; i++) { Entities.Firefly firefly = new Entities.Firefly(scene); firefly.Matrix = Matrix.CreateTranslation(31.25f, 3.125f, 43.75f); } // Create fireflies near camera for (int i = 0; i < 10; i++) { Entities.Firefly firefly = new Entities.Firefly(scene); firefly.Matrix = Matrix.CreateTranslation(37.5f, 3.125f, 75f); } // Load songs song = Game.Content.Load <Song>("Songs/DanGoodale_DF-11"); MediaPlayer.IsRepeating = true; MediaPlayer.Play(song); // Load fonts titleFont = Game.Content.Load <SpriteFont>("Fonts/TitleFont"); consoleFont = Game.Content.Load <SpriteFont>("Fonts/ConsoleFont"); menuFont = Game.Content.Load <SpriteFont>("Fonts/MenuFont"); menuFont2 = Game.Content.Load <SpriteFont>("Fonts/MenuFont2"); // Create gui manager gui = new InterfaceManager(core); gui.SetMargins(Margins.All, 20); // Create a stack panel StackPanelScreenComponent stackPanel = new StackPanelScreenComponent(core, Vector2.Zero, new Vector2(500, 300), 0); stackPanel.HorizontalAlignment = HorizontalAlignment.Right; gui.Components.Add(stackPanel); // Create title text TextItemScreenComponent title = new TextItemScreenComponent(core, titleFont, titleText, HorizontalAlignment.Right, VerticalAlignment.None); title.OutlineColor = Color.Gray; title.EnableOutline = true; title.ShadowColor = Color.MidnightBlue; title.ShadowVector = new Vector2(3, 3); // Create version text TextItemScreenComponent version = new TextItemScreenComponent(core, consoleFont, versionText, HorizontalAlignment.Right, VerticalAlignment.None); version.TextColor = Color.Gold; // Create start menu item startMenuItem = new TextItemScreenComponent(core, menuFont2, startMenuText, HorizontalAlignment.Right, VerticalAlignment.None); startMenuItem.TextColor = Color.White; startMenuItem.OutlineColor = Color.Goldenrod; startMenuItem.ShadowColor = Color.MidnightBlue; startMenuItem.ShadowVector = new Vector2(2, 2); // Exit menu item exitMenuItem = new TextItemScreenComponent(core, menuFont2, exitMenuText, HorizontalAlignment.Right, VerticalAlignment.None); exitMenuItem.TextColor = Color.White; exitMenuItem.OutlineColor = Color.Gold; exitMenuItem.ShadowColor = Color.MidnightBlue; exitMenuItem.ShadowVector = new Vector2(2, 2); // Add items to stack panel stackPanel.Components.Add(title); stackPanel.Components.Add(version); stackPanel.Components.Add(new StackSpacerScreenComponent(core, 50)); stackPanel.Components.Add(startMenuItem); stackPanel.Components.Add(new StackSpacerScreenComponent(core, 20)); stackPanel.Components.Add(exitMenuItem); // Wire up menu events startMenuItem.OnMouseEnter += new EventHandler(StartMenuItem_OnMouseEnter); startMenuItem.OnMouseLeave += new EventHandler(StartMenuItem_OnMouseLeave); exitMenuItem.OnMouseEnter += new EventHandler(ExitMenuItem_OnMouseEnter); exitMenuItem.OnMouseLeave += new EventHandler(ExitMenuItem_OnMouseLeave); startMenuItem.OnMouseClick += new EventHandler(StartMenuItem_OnMouseClick); exitMenuItem.OnMouseClick += new EventHandler(ExitMenuItem_OnMouseClick); }
/// <summary> /// Gets settings for specified map climate. /// </summary> /// <param name="worldClimate">Climate value from CLIMATE.PAK. Valid range is 223-232.</param> /// <returns>Climate settings for specified world climate value.</returns> public static DFLocation.ClimateSettings GetWorldClimateSettings(int worldClimate) { // Create settings struct DFLocation.ClimateSettings settings = new DFLocation.ClimateSettings(); settings.WorldClimate = worldClimate; // Set based on world climate switch (worldClimate) { case 223: // Ocean settings.ClimateType = DFLocation.ClimateBaseType.Swamp; settings.GroundArchive = 402; settings.NatureArchive = 504; settings.SkyBase = 24; break; case 224: settings.ClimateType = DFLocation.ClimateBaseType.Desert; settings.GroundArchive = 2; settings.NatureArchive = 503; settings.SkyBase = 8; break; case 225: settings.ClimateType = DFLocation.ClimateBaseType.Desert; settings.GroundArchive = 2; settings.NatureArchive = 503; settings.SkyBase = 8; break; case 226: settings.ClimateType = DFLocation.ClimateBaseType.Mountain; settings.GroundArchive = 102; settings.NatureArchive = 510; settings.SkyBase = 0; break; case 227: settings.ClimateType = DFLocation.ClimateBaseType.Swamp; settings.GroundArchive = 402; settings.NatureArchive = 500; settings.SkyBase = 24; break; case 228: settings.ClimateType = DFLocation.ClimateBaseType.Swamp; settings.GroundArchive = 402; settings.NatureArchive = 502; settings.SkyBase = 24; break; case 229: settings.ClimateType = DFLocation.ClimateBaseType.Desert; settings.GroundArchive = 2; settings.NatureArchive = 501; settings.SkyBase = 24; break; case 230: settings.ClimateType = DFLocation.ClimateBaseType.Mountain; settings.GroundArchive = 102; settings.NatureArchive = 504; settings.SkyBase = 16; break; case 231: settings.ClimateType = DFLocation.ClimateBaseType.Temperate; settings.GroundArchive = 302; settings.NatureArchive = 504; settings.SkyBase = 16; break; case 232: settings.ClimateType = DFLocation.ClimateBaseType.Temperate; settings.GroundArchive = 302; settings.NatureArchive = 508; settings.SkyBase = 16; break; default: settings.ClimateType = DFLocation.ClimateBaseType.Temperate; settings.GroundArchive = 302; settings.NatureArchive = 504; settings.SkyBase = 16; break; } // Set nature set from nature archive index settings.NatureSet = (DFLocation.ClimateTextureSet)settings.NatureArchive; return settings; }
/// <summary> /// Gets settings for specified map climate. /// </summary> /// <param name="worldClimate">Climate value from CLIMATE.PAK. Valid range is 223-232.</param> /// <returns>Climate settings for specified world climate value.</returns> static public DFLocation.ClimateSettings GetWorldClimateSettings(int worldClimate) { // Create settings struct DFLocation.ClimateSettings settings = new DFLocation.ClimateSettings(); settings.WorldClimate = worldClimate; // Set based on world climate switch (worldClimate) { case 223: // Ocean settings.ClimateType = DFLocation.ClimateBaseType.Swamp; settings.GroundArchive = 402; settings.NatureArchive = 502; settings.SkyBase = 24; break; case 224: settings.ClimateType = DFLocation.ClimateBaseType.Desert; settings.GroundArchive = 2; settings.NatureArchive = 503; settings.SkyBase = 8; break; case 225: settings.ClimateType = DFLocation.ClimateBaseType.Desert; settings.GroundArchive = 2; settings.NatureArchive = 503; settings.SkyBase = 8; break; case 226: settings.ClimateType = DFLocation.ClimateBaseType.Mountain; settings.GroundArchive = 102; settings.NatureArchive = 510; settings.SkyBase = 0; break; case 227: settings.ClimateType = DFLocation.ClimateBaseType.Swamp; settings.GroundArchive = 402; settings.NatureArchive = 500; settings.SkyBase = 24; break; case 228: settings.ClimateType = DFLocation.ClimateBaseType.Swamp; settings.GroundArchive = 402; settings.NatureArchive = 502; settings.SkyBase = 24; break; case 229: settings.ClimateType = DFLocation.ClimateBaseType.Desert; settings.GroundArchive = 2; settings.NatureArchive = 501; settings.SkyBase = 24; break; case 230: settings.ClimateType = DFLocation.ClimateBaseType.Mountain; settings.GroundArchive = 102; settings.NatureArchive = 504; settings.SkyBase = 16; break; case 231: settings.ClimateType = DFLocation.ClimateBaseType.Temperate; settings.GroundArchive = 302; settings.NatureArchive = 504; settings.SkyBase = 16; break; case 232: settings.ClimateType = DFLocation.ClimateBaseType.Temperate; settings.GroundArchive = 302; settings.NatureArchive = 508; settings.SkyBase = 16; break; default: settings.ClimateType = DFLocation.ClimateBaseType.Temperate; settings.GroundArchive = 302; settings.NatureArchive = 504; settings.SkyBase = 16; break; } // Set nature set from nature archive index settings.NatureSet = (DFLocation.ClimateTextureSet)settings.NatureArchive; return(settings); }
public WOVegetationChance(float elevation, DFLocation.ClimateSettings climate) { if (climate.WorldClimate == (int)MapsFile.Climates.Woodlands) { if (elevation > 0.125f) { chanceOnGrass = Mathf.Clamp(Random.Range(0.225f, 0.300f), 0f, 1f); chanceOnDirt = Mathf.Clamp(Random.Range(0.450f, 0.475f), 0f, 1f); chanceOnStone = Mathf.Clamp(Random.Range(0.500f, 0.525f), 0f, 1f); } else if (elevation <= 0.125f && elevation > 0.075f) { chanceOnGrass = Mathf.Clamp(Random.Range(0.225f, 0.300f), 0f, 1f); chanceOnDirt = Mathf.Clamp(Random.Range(0.425f, 0.450f), 0f, 1f); chanceOnStone = Mathf.Clamp(Random.Range(0.675f, 0.700f), 0f, 1f); } else if (elevation <= 0.075f && elevation > 0.025f) { chanceOnGrass = Mathf.Clamp(Random.Range(0.250f, 0.300f), 0f, 1f); chanceOnDirt = Mathf.Clamp(Random.Range(0.300f, 0.325f), 0f, 1f); chanceOnStone = Mathf.Clamp(Random.Range(0.650f, 0.675f), 0f, 1f); } else if (elevation <= 0.025f) { chanceOnGrass = Mathf.Clamp(Random.Range(0.275f, 0.300f), 0f, 1f); chanceOnDirt = Mathf.Clamp(Random.Range(0.150f, 0.175f), 0f, 1f); chanceOnStone = Mathf.Clamp(Random.Range(0.625f, 0.650f), 0f, 1f); } } //Adjustment to mountain climate in respect to world height else if (climate.WorldClimate == (int)MapsFile.Climates.Mountain) { if (elevation > WOTerrainTexturing.treeLine) { chanceOnGrass = Mathf.Clamp(Random.Range(0.250f, 0.275f), 0f, 1f); chanceOnDirt = Mathf.Clamp(Random.Range(0.200f, 0.225f), 0f, 1f); chanceOnStone = Mathf.Clamp(Random.Range(0.325f, 0.350f), 0f, 1f); } else if (elevation <= WOTerrainTexturing.treeLine && elevation > 0.6f) { chanceOnGrass = Mathf.Clamp(Random.Range(0.275f, 0.300f), 0f, 1f); chanceOnDirt = Mathf.Clamp(Random.Range(0.375f, 0.400f), 0f, 1f); chanceOnStone = Mathf.Clamp(Random.Range(0.275f, 0.300f), 0f, 1f); } else if (elevation <= 0.6f && elevation > 0.4f) { chanceOnGrass = Mathf.Clamp(Random.Range(0.300f, 0.325f), 0f, 1f); chanceOnDirt = Mathf.Clamp(Random.Range(0.350f, 0.400f), 0f, 1f); chanceOnStone = Mathf.Clamp(Random.Range(0.225f, 0.250f), 0f, 1f); } else if (elevation <= 0.4f && elevation > 0.2f) { chanceOnGrass = Mathf.Clamp(Random.Range(0.325f, 0.375f), 0f, 1f); chanceOnDirt = Mathf.Clamp(Random.Range(0.350f, 0.375f), 0f, 1f); chanceOnStone = Mathf.Clamp(Random.Range(0.175f, 0.200f), 0f, 1f); } else if (elevation <= 0.2f) { chanceOnGrass = Mathf.Clamp(Random.Range(0.375f, 0.400f), 0f, 1f); chanceOnDirt = Mathf.Clamp(Random.Range(0.300f, 0.350f), 0f, 1f); chanceOnStone = Mathf.Clamp(Random.Range(0.250f, 0.275f), 0f, 1f); } } //Adjustment to desert climate in respect to world height else if (climate.WorldClimate == (int)MapsFile.Climates.Desert) { chanceOnGrass = Mathf.Clamp(Random.Range(0.100f, 0.150f), 0f, 1f); chanceOnDirt = Mathf.Clamp(Random.Range(0.100f, 0.150f), 0f, 1f); chanceOnStone = Mathf.Clamp(Random.Range(0.050f, 0.100f), 0f, 1f); } //Adjustment to desert climate in respect to world height else if (climate.WorldClimate == (int)MapsFile.Climates.Desert2) { chanceOnGrass = Mathf.Clamp(Random.Range(0.05f, 0.25f), 0f, 1f); chanceOnDirt = Mathf.Clamp(Random.Range(0.05f, 0.25f), 0f, 1f); chanceOnStone = Mathf.Clamp(Random.Range(0.05f, 0.20f), 0f, 1f); } // Adjustment to temperate woodlands climate in respect to world height else if (climate.WorldClimate == (int)MapsFile.Climates.HauntedWoodlands) { chanceOnGrass = Random.Range(0.05f, 0.09f); chanceOnDirt = Random.Range(0.045f, 0.065f); chanceOnStone = Random.Range(0.05f, 0.1f); } //Adjustment to mountain woodland climate in respect to world height else if (climate.WorldClimate == (int)MapsFile.Climates.MountainWoods) { if (elevation > 0.475f) { chanceOnGrass = Random.Range(0.035f, 0.080f); chanceOnDirt = Random.Range(0.120f, 0.150f); chanceOnStone = Random.Range(0.120f, 0.150f); } else if (elevation <= 0.475f && elevation > 0.4f) { chanceOnGrass = Random.Range(0.040f, 0.100f); chanceOnDirt = Random.Range(0.100f, 0.130f); chanceOnStone = Random.Range(0.100f, 0.130f); } else if (elevation <= 0.4f && elevation > 0.325f) { chanceOnGrass = Random.Range(0.050f, 0.100f); chanceOnDirt = Random.Range(0.090f, 0.110f); chanceOnStone = Random.Range(0.090f, 0.110f); } else if (elevation <= 0.325f && elevation > 0.25f) { chanceOnGrass = Random.Range(0.090f, 0.120f); chanceOnDirt = Random.Range(0.070f, 0.090f); chanceOnStone = Random.Range(0.060f, 0.090f); } else if (elevation <= 0.25f) { chanceOnGrass = Random.Range(0.100f, 0.130f); chanceOnDirt = Random.Range(0.060f, 0.090f); chanceOnStone = Random.Range(0.050f, 0.080f); } } //Adjustment to swamp climate in respect to world height if (climate.WorldClimate == (int)MapsFile.Climates.Swamp) { chanceOnStone = Mathf.Clamp(Random.Range(0.00f, 0.00f), 0f, 1f); chanceOnDirt = Mathf.Clamp(Random.Range(0.00f, 0.00f), 0f, 1f); chanceOnGrass = Mathf.Clamp(Random.Range(0.00f, 0.00f), 0f, 1f); } //Adjustment to rainforest climate in respect to world height else if (climate.WorldClimate == (int)MapsFile.Climates.Rainforest) { chanceOnGrass = /* Random.Range(0.035f, */ 0.30f /* ) */; chanceOnDirt = /* Random.Range(0.120f, */ 0.30f /* ) */; chanceOnStone = /* Random.Range(0.120f, */ 0.30f /* ) */; } //Adjustment to subtropical climate in respect to world height else if (climate.WorldClimate == (int)MapsFile.Climates.Subtropical) { chanceOnStone = Mathf.Clamp(Random.Range(0.00f, 0.00f), 0f, 1f); chanceOnDirt = Mathf.Clamp(Random.Range(0.00f, 0.00f), 0f, 1f); chanceOnGrass = Mathf.Clamp(Random.Range(0.00f, 0.00f), 0f, 1f); } }