Explicit function when starting and ending map generation as it happens over multiple frames.

WorldChunkRefactoring
Martin Felis 2023-06-11 12:47:36 +02:00
parent 120d1dea7d
commit c690f0f152
1 changed files with 16 additions and 5 deletions

View File

@ -69,6 +69,8 @@ public class TileWorld : Spatial
GenerateNoiseMap();
// GenerateDebugMap();
OnHeightMapChanged();
}
private void GenerateDebugMap()
@ -92,11 +94,9 @@ public class TileWorld : Spatial
}
Colormap.SetPixel(Size - 1, Size -1, new Color(1, 1, 1, 1));
Colormap.Unlock();
_currentGenerationState = GenerationState.Done;;
EmitSignal("WorldGenerated");
OnMapGenerationComplete();
}
@ -118,10 +118,21 @@ public class TileWorld : Spatial
heightmapTexture.Flags = 0;
_heightmapOffscreenTextureRect.Texture = heightmapTexture;
Heightmap.CopyFrom(_heightmapOffscreenViewport.GetTexture().GetData());
OnHeightMapChanged();
}
private void OnHeightMapChanged()
{
_currentGenerationState = GenerationState.Heightmap;
}
private void OnMapGenerationComplete()
{
_currentGenerationState = GenerationState.Done;
EmitSignal("WorldGenerated");
}
public override void _Process(float delta)
{
@ -141,8 +152,8 @@ public class TileWorld : Spatial
Heightmap.Lock();
_currentGenerationState = GenerationState.Done;
EmitSignal("WorldGenerated");
OnMapGenerationComplete();
}
}