using Godot; using System; public partial class PlantSlot : TextureButton { [Export] private PlantResource _resource; [Export] private Label _cost; [Export] private TextureRect _icon; [Export] private Timer _timer; public override void _Ready() { if (_resource != null) UpdateContents(); } public void SetPlantResource( PlantResource resource ) { _resource = resource; UpdateContents(); } private void UpdateContents() { _cost.Text = _resource.Cost.ToString(); _icon.Texture = _resource.Preview; _timer.WaitTime = _resource.ReloadTime; } private void OnPressed() { if (_timer.TimeLeft == 0) { LevelController.Instance.PlantField.SetPlant(this, _resource); } } private void OnFocusExited() { LevelController.Instance.PlantField.SetPlant(null, null); } public void Recharge() { Disabled = true; FocusMode = FocusModeEnum.None; ReleaseFocus(); _timer.Start(); } private void Timeout() { Disabled = false; FocusMode = FocusModeEnum.All; } }