From 63d2a59042fb9d90a586ad85d8364de7c38aea8e Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 6 Nov 2024 22:35:04 +0100 Subject: next commit --- Towers/Components/TowerComponent.gd | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'Towers/Components/TowerComponent.gd') 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() -- cgit v1.2.3