diff options
Diffstat (limited to 'Towers/Components/TowerComponent.gd')
-rw-r--r-- | Towers/Components/TowerComponent.gd | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/Towers/Components/TowerComponent.gd b/Towers/Components/TowerComponent.gd index 7ca766a..30b1c44 100644 --- a/Towers/Components/TowerComponent.gd +++ b/Towers/Components/TowerComponent.gd @@ -1,8 +1,10 @@ class_name TowerComponent -extends Node +extends Node2D -var current_tower: Tower +var current_tower: Tower: + get(): + return get_parent() enum ComponentType { Range, @@ -13,8 +15,15 @@ enum ComponentType { Poison, } -var type: ComponentType -var sprite: TextureRect = TextureRect.new() +@export var type: ComponentType +var sprite: TextureRect: + get(): + @warning_ignore("shadowed_variable") + var sprite := $Sprite.duplicate() + sprite.name = get_type_name() + + return sprite + var id: String: get(): @@ -28,12 +37,8 @@ var level: int = 1: func set_sprite(texture: Texture2D): + sprite = get_node("Sprite") sprite.texture = texture - - sprite.texture_filter = CanvasItem.TEXTURE_FILTER_NEAREST - #sprite.centered = false - sprite.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED - #sprite.scale = Vector2(2, 2) sprite.name = get_type_name() @@ -57,8 +62,8 @@ func to_network_data() -> NetworkData: return data -func update_with_network_data(_data: NetworkData): - pass +func update_with_network_data(data: NetworkData): + level = data.level static func from_network_data(data: NetworkData) -> TowerComponent: var component = preload("res://Towers/Components/TowerComponent.gd").new() |