diff --git a/Server/Components/Pages/GamePage.razor b/Server/Components/Pages/GamePage.razor index 97efa57..6f97853 100644 --- a/Server/Components/Pages/GamePage.razor +++ b/Server/Components/Pages/GamePage.razor @@ -148,7 +148,6 @@ private MapDisplayData _mapDisplayData = new(); private MapData? _map; private List? _path { get; set; } - private NoiseParameters _noiseParameters = new(); protected override async Task OnInitializedAsync() { diff --git a/Server/Modules/Items/Services/ItemGenerator.cs b/Server/Modules/Items/Services/ItemGenerator.cs index dd500ba..4fe4c8e 100644 --- a/Server/Modules/Items/Services/ItemGenerator.cs +++ b/Server/Modules/Items/Services/ItemGenerator.cs @@ -1,6 +1,7 @@ using System.Text.Json; using Fracture.Server.Modules.AI.Services; using Fracture.Server.Modules.Items.Models; +using Fracture.Server.Modules.NoiseGenerator.Models; using Fracture.Server.Modules.Shared; using Fracture.Server.Modules.Shared.Configuration; using Microsoft.FeatureManagement; @@ -19,6 +20,7 @@ public class ItemGenerator : IItemGenerator public ItemGenerator( INameGenerator nameGenerator, PrefixesGenerator prefixes, + NoiseParameters noiseParameters, IAIInstructionProvider? ai = null ) { @@ -26,7 +28,7 @@ public ItemGenerator( _prefixes = prefixes; _ai = ai; - _rnd = new Random(); + _rnd = new Random(noiseParameters.Seed); var configData = File.ReadAllText("itemgeneratorconfig.json"); _modifiers = JsonSerializer.Deserialize>(configData)!; diff --git a/Server/Modules/MapGenerator/Services/MapGeneratorService.cs b/Server/Modules/MapGenerator/Services/MapGeneratorService.cs index 27cb84c..e35b725 100644 --- a/Server/Modules/MapGenerator/Services/MapGeneratorService.cs +++ b/Server/Modules/MapGenerator/Services/MapGeneratorService.cs @@ -26,12 +26,10 @@ public async Task GetMap(MapParameters mapParameters) private MapData GenerateMap(MapParameters mapParameters) { var noiseParameters = mapParameters.NoiseParameters; - noiseParameters.Seed = noiseParameters.UseRandomSeed - ? _rnd.Next(-100000, 100000) - : noiseParameters.Seed; int width = 64; int height = 64; bool useFalloff = true; + int _seed = noiseParameters.Seed; var grid = new Node[width, height]; diff --git a/Server/Modules/MapGenerator/UI/NoiseParametersView.razor b/Server/Modules/MapGenerator/UI/NoiseParametersView.razor deleted file mode 100644 index 0ba9f1c..0000000 --- a/Server/Modules/MapGenerator/UI/NoiseParametersView.razor +++ /dev/null @@ -1,25 +0,0 @@ -@using Fracture.Server.Modules.NoiseGenerator.Models -
-
- - - @if (!NoiseParameters.UseRandomSeed) - { -
- - - } -
-
- -@code { - [Parameter] - public NoiseParameters NoiseParameters { get; set; } - [Parameter] - public EventCallback NoiseParametersChanged { get; set; } - - private Task OnNoiseParametersChanged(ChangeEventArgs e) - { - return NoiseParametersChanged.InvokeAsync(NoiseParameters); - } -} diff --git a/Server/Modules/MapGenerator/UI/NoiseParametersView.razor.css b/Server/Modules/MapGenerator/UI/NoiseParametersView.razor.css deleted file mode 100644 index acf6ec1..0000000 --- a/Server/Modules/MapGenerator/UI/NoiseParametersView.razor.css +++ /dev/null @@ -1,3 +0,0 @@ -#content { - background-color: #F4F6F6; -} diff --git a/Server/Modules/MapGenerator/UI/TileInfoView.razor b/Server/Modules/MapGenerator/UI/TileInfoView.razor deleted file mode 100644 index c551503..0000000 --- a/Server/Modules/MapGenerator/UI/TileInfoView.razor +++ /dev/null @@ -1,7 +0,0 @@ -
- Tile information... -
- -@code { - -} diff --git a/Server/Modules/MapGenerator/UI/TileInfoView.razor.css b/Server/Modules/MapGenerator/UI/TileInfoView.razor.css deleted file mode 100644 index acf6ec1..0000000 --- a/Server/Modules/MapGenerator/UI/TileInfoView.razor.css +++ /dev/null @@ -1,3 +0,0 @@ -#content { - background-color: #F4F6F6; -} diff --git a/Server/Modules/NoiseGenerator/Models/NoiseParameters.cs b/Server/Modules/NoiseGenerator/Models/NoiseParameters.cs index 0263cdf..56261dd 100644 --- a/Server/Modules/NoiseGenerator/Models/NoiseParameters.cs +++ b/Server/Modules/NoiseGenerator/Models/NoiseParameters.cs @@ -13,7 +13,4 @@ public class NoiseParameters public float Boost { get; set; } public float Falloff { get; set; } public bool FalloffType { get; set; } - - public bool UseRandomSeed { get; set; } = true; - public bool GenerateNew { get; set; } = true; } diff --git a/Server/Modules/NoiseGenerator/Services/CustomPerlin.cs b/Server/Modules/NoiseGenerator/Services/CustomPerlin.cs index 39848c7..0b4a6e7 100644 --- a/Server/Modules/NoiseGenerator/Services/CustomPerlin.cs +++ b/Server/Modules/NoiseGenerator/Services/CustomPerlin.cs @@ -92,16 +92,13 @@ public static float PerlinOctaves( public static float[,] GenerateNoiseMap( int size, - int? seed = null, + int seed, int octaves = 1, float persistence = 0.5f, float lacunarity = 2.0f, float scale = 1.0f ) { // Noise map generation - // can be called with a seed or without it - int actualSeed = seed ?? new Random().Next(); - float[,] map = new float[size, size]; for (int y = 0; y < size; y++) @@ -110,14 +107,7 @@ public static float PerlinOctaves( { float scaledX = x / (float)Math.PI / scale; float scaledY = y / (float)Math.PI / scale; - map[x, y] = PerlinOctaves( - scaledX, - scaledY, - actualSeed, - octaves, - persistence, - lacunarity - ); + map[x, y] = PerlinOctaves(scaledX, scaledY, seed, octaves, persistence, lacunarity); } } return map; diff --git a/Server/Program.cs b/Server/Program.cs index cb88b59..d1f8023 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -5,6 +5,7 @@ using Fracture.Server.Modules.Items.Models; using Fracture.Server.Modules.Items.Services; using Fracture.Server.Modules.MapGenerator.Services; +using Fracture.Server.Modules.NoiseGenerator.Models; using Fracture.Server.Modules.Shared; using Fracture.Server.Modules.Shared.Configuration; using Fracture.Server.Modules.Shared.NameGenerators;