Update planet.gd

This commit is contained in:
Tomasz Boruc 2025-11-03 17:56:49 +01:00
parent eaea2e9664
commit 6caa0c05c3

View File

@ -4,7 +4,10 @@ class_name Planet
@onready var info_label = $CanvasLayer/Info
@onready var area = $Area2D
var pop_timer: float = 0.0 # licznik czasu
# --- Timery ---
var pop_timer: float = 0.0
var res_timer: float = 0.0
var cons_timer: float = 0.0
var pname: String = ""
var orbit_radius: float = 30.0
@ -103,10 +106,10 @@ func _pop_growth(delta):
population = max(population - 10, 100)
pop_timer = 0.0
func _res_growth(delta):
pop_timer += delta
if pop_timer < Settings.UPDATE_INTERVAL:
res_timer += delta
if res_timer < Settings.UPDATE_INTERVAL:
return
pop_timer = 0.0
res_timer = 0.0
for res_name in resources.keys():
var res = resources[res_name]
@ -124,10 +127,10 @@ func check_growth() -> float:
func _res_consumption(delta):
var water_usage = population * 0.0002 # np. 0.002 jednostki wody na osobę
pop_timer += delta
if pop_timer >= Settings.UPDATE_INTERVAL:
cons_timer += delta
if cons_timer >= Settings.UPDATE_INTERVAL:
if "water" in resources:
resources["water"].amount -= water_usage
if resources["water"].amount < 0:
resources["water"].amount = 0
pop_timer = 0.0
cons_timer = 0.0