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();
}
@ -119,9 +119,20 @@ public class TileWorld : Spatial
_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)
{
@ -142,7 +153,7 @@ public class TileWorld : Spatial
_currentGenerationState = GenerationState.Done;
EmitSignal("WorldGenerated");
OnMapGenerationComplete();
}
}