30 lines
692 B
GDScript3
30 lines
692 B
GDScript3
|
extends "res://scripts/Machine.gd"
|
||
|
|
||
|
@export var production_period: float = 0.0
|
||
|
var production_timer: float = 0.0
|
||
|
|
||
|
|
||
|
func _ready() -> void:
|
||
|
super()
|
||
|
determine_resource()
|
||
|
|
||
|
func place() -> void:
|
||
|
super()
|
||
|
determine_resource()
|
||
|
|
||
|
func determine_resource() -> void:
|
||
|
var tile_coord: Vector2i = $"..".local_to_map(position)
|
||
|
var ore: Resource = $"..".get_cell_tile_data(tile_coord).get_custom_data("Ore")
|
||
|
if ore != null:
|
||
|
produced_item = ore
|
||
|
|
||
|
func _process(delta: float) -> void:
|
||
|
if !is_functional():
|
||
|
return
|
||
|
if produced_item != null:
|
||
|
if production_period > 0:
|
||
|
production_timer += delta
|
||
|
if production_timer >= production_period:
|
||
|
production_timer -= production_period
|
||
|
produce()
|