summaryrefslogtreecommitdiff
path: root/Towers/Components/TowerComponent.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-11-06 22:35:04 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-11-06 22:35:04 +0100
commit63d2a59042fb9d90a586ad85d8364de7c38aea8e (patch)
treef4c648b39313f10f44898d0216a9147dfb4ba491 /Towers/Components/TowerComponent.gd
parentf20b3a48a14f34def41d823fabb476981ef7055e (diff)
next commit
Diffstat (limited to 'Towers/Components/TowerComponent.gd')
-rw-r--r--Towers/Components/TowerComponent.gd27
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()