class_name TowerComponent extends Node var current_tower: Tower enum ComponentType { Range, Attack, Speed, Frost, Burn, Poison, } var type: ComponentType var sprite: TextureRect = TextureRect.new() var id: String: get(): return get_type_name() signal level_changed var level: int = 1: set(value): level = value level_changed.emit() func set_sprite(texture: Texture2D): 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() func get_type_name(component_type: ComponentType = type): return ComponentType.keys()[component_type] func on_add(tower: Tower): current_tower = tower class NetworkData extends Resource: var type: ComponentType var level: int func to_network_data() -> NetworkData: var data = NetworkData.new() data.type = type data.level = level return data func update_with_network_data(_data: NetworkData): pass static func from_network_data(data: NetworkData) -> TowerComponent: var component = preload("res://Towers/Components/TowerComponent.gd").new() component.type = data.type component.level = data.level return component