From ee46a240c2295e979c8990c9e2f1fe58ace5132f Mon Sep 17 00:00:00 2001 From: Zacharie Guet Date: Sat, 31 Aug 2024 16:39:53 +0200 Subject: [PATCH] Add get_stat function to terrain.gd --- scripts/terrain.gd | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/terrain.gd b/scripts/terrain.gd index 6ea6604..3609b82 100644 --- a/scripts/terrain.gd +++ b/scripts/terrain.gd @@ -129,6 +129,20 @@ func modify_rect( ) update_texture() +func get_stat( + pos: Vector2, + stat : Stats +) : + var pixel_pos = map_to_pixel(pos) + var levels = color_to_levels(image.get_pixelv(pixel_pos)) + match stat: + Stats.WATER: + return levels.x + Stats.FERTILITY: + return levels.y + Stats.TEMPERATURE: + return levels.z + func setup_texture( levels : Vector3i ):