2025-09-06 15:04:32 +08:00
|
|
|
extends PanelContainer
|
2025-09-06 15:24:50 +08:00
|
|
|
class_name SkillIcon
|
2025-09-06 15:04:32 +08:00
|
|
|
|
|
|
|
|
@export var weapon: Weapon = null;
|
|
|
|
|
|
2025-09-06 15:46:39 +08:00
|
|
|
@onready var textureRect: TextureRect = $"%texture"
|
2025-09-10 22:08:57 +08:00
|
|
|
@onready var particle: GPUParticles2D = $"%particle"
|
|
|
|
|
|
|
|
|
|
var showed: bool = false
|
|
|
|
|
|
2025-09-06 15:46:39 +08:00
|
|
|
func _ready():
|
2025-09-10 06:31:53 +08:00
|
|
|
material = material.duplicate()
|
2025-09-06 15:04:32 +08:00
|
|
|
func _physics_process(_delta):
|
|
|
|
|
if is_instance_valid(weapon):
|
|
|
|
|
textureRect.texture = weapon.avatarTexture
|
2026-01-24 09:43:25 +08:00
|
|
|
var progress = min(weapon.cooldownTimer.percent(), UIState.player.fillingProgress(weapon.needEnergy))
|
2025-09-10 06:31:53 +08:00
|
|
|
material.set_shader_parameter("progress", progress)
|
2026-04-05 08:29:29 +08:00
|
|
|
particle.emitting = weapon.canAttackBy(UIState.player)
|
2025-09-10 22:08:57 +08:00
|
|
|
if progress >= 1:
|
|
|
|
|
if !showed:
|
|
|
|
|
showed = true
|
|
|
|
|
else:
|
|
|
|
|
showed = false
|