1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-21 23:54:23 +00:00

Add timings

This commit is contained in:
Steffo 2024-05-03 01:57:06 +02:00
parent f0c363b0b1
commit 67acbacb53
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0

View file

@ -9,6 +9,9 @@ class_name MainGame
@onready var cursor: Cursor = %"Cursor" @onready var cursor: Cursor = %"Cursor"
@onready var music: Music = %"Music" @onready var music: Music = %"Music"
var time_elapsed: float = 0.0
var recipe_timings := {}
static func get_via_group(node: Node) -> MainGame: static func get_via_group(node: Node) -> MainGame:
var result = node.get_tree().get_nodes_in_group("game") var result = node.get_tree().get_nodes_in_group("game")
@ -23,7 +26,14 @@ func _ready():
gold_counter.changed.connect(cursor.gold_display.change) gold_counter.changed.connect(cursor.gold_display.change)
cursor.gold_display.set_text(gold_counter.value) cursor.gold_display.set_text(gold_counter.value)
func _physics_process(delta: float) -> void:
time_elapsed += delta
func _on_recipe_matched(_m: SummoningRecipe.Match, recipe: SummoningRecipe) -> void: func _on_recipe_matched(_m: SummoningRecipe.Match, recipe: SummoningRecipe) -> void:
var timing = recipe_timings.get(recipe.name)
if timing == null:
recipe_timings[recipe.name] = time_elapsed
Log.p(self, "Recipe %s first completed in: %f s" % [recipe.name, time_elapsed])
# Quick hack for now # Quick hack for now
match recipe.name: match recipe.name:
"FiveSheep": "FiveSheep":