50 lines
1.3 KiB
GDScript
50 lines
1.3 KiB
GDScript
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
|
|
}
|
|
var _pos: Vector2i
|
|
var interaction_display: ProgressBar
|
|
|
|
func _to_string() -> String:
|
|
return "{%s %s}" % [_pos, layer_info]
|
|
|
|
func _init(pos: Vector2i) -> void:
|
|
_pos = pos
|
|
|
|
func change_layer(layer: int, data: Variant) -> bool:
|
|
if layer_info.has(layer) and layer_info[layer] == data:
|
|
return false
|
|
layer_info[layer] = data
|
|
return true
|
|
|
|
func change_resource(data: GameResource) -> void:
|
|
layer_info[Constants.TilemapLayers.ENVIRONMENT] = data
|
|
|
|
func get_resource() -> GameResource:
|
|
return layer_info[Constants.TilemapLayers.ENVIRONMENT] as 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]
|
|
|
|
func has_layer(layer: int) -> bool:
|
|
return layer_info.has(layer)
|
|
|
|
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
|