interaction wheel

cancel interaction wheel
This commit is contained in:
2024-02-28 07:12:09 -06:00
parent f87b1cfa9a
commit 50093e5937
9 changed files with 188 additions and 5 deletions

View File

@@ -1,6 +1,9 @@
class_name CellData
extends Resource
const BUILD = preload("res://data/interactions/build.tres")
const GATHER = preload("res://data/interactions/gather.tres")
@export var layer_info: Dictionary = {
Constants.TilemapLayers.CORRUPTION: false
}
@@ -27,6 +30,9 @@ func get_resource() -> GameResource:
func has_resource() -> bool:
return has_layer(Constants.TilemapLayers.ENVIRONMENT)
func has_building() -> bool:
return has_layer(Constants.TilemapLayers.BUILDINGS)
func is_corrupted() -> bool:
return layer_info[Constants.TilemapLayers.CORRUPTION]
@@ -35,7 +41,7 @@ func has_layer(layer: int) -> bool:
return layer_info.has(layer)
func interact(timer: Timer) -> void:
var is_interactable := has_resource() or has_layer(Constants.TilemapLayers.BUILDINGS)
var is_interactable := has_resource() or not has_building()
if is_interactable and not interaction_display:
timer.timeout.connect(_on_interaction_finished.bind(timer))
timer.start(3)
@@ -47,6 +53,14 @@ func interact(timer: Timer) -> void:
var tween = timer.get_tree().create_tween()
tween.tween_property(interaction_display, "value", 100, 3)
timer.get_parent().add_sibling(interaction_display)
func get_interaction_options() -> Array[Interaction]:
var interactions: Array[Interaction] = []
if has_resource():
interactions.append(GATHER)
if not has_building():
interactions.append(BUILD)
return interactions
func _on_interaction_finished(timer: Timer) -> void:
timer.timeout.disconnect(_on_interaction_finished)