Interaction wheel
do interaction
This commit is contained in:
24
data/interactions/gather/interaction_gather.gd
Normal file
24
data/interactions/gather/interaction_gather.gd
Normal file
@@ -0,0 +1,24 @@
|
||||
extends Interaction
|
||||
class_name InteractionGather
|
||||
|
||||
var interaction_display
|
||||
var _pos
|
||||
|
||||
func interact_at(pos: Vector2i, root: Node) -> Array[Interaction]:
|
||||
_pos = pos
|
||||
print("Gathering at: %s" % pos)
|
||||
|
||||
interaction_display = ProgressBar.new()
|
||||
interaction_display.position = Grid.grid_to_world_center(_pos) - Vector2(30, 10)
|
||||
interaction_display.size = Vector2(60, 20)
|
||||
interaction_display.show_percentage = false
|
||||
var tween = root.create_tween()
|
||||
tween.tween_property(interaction_display, "value", 100, 3)
|
||||
tween.tween_callback(_cleanup_gather)
|
||||
root.add_child(interaction_display)
|
||||
return []
|
||||
|
||||
func _cleanup_gather() -> void:
|
||||
interaction_display.queue_free()
|
||||
var res: GameResource = Grid.get_location_data(_pos).get_resource()
|
||||
res.gained_resource.emit(res)
|
||||
Reference in New Issue
Block a user