Lockable seeds

This commit is contained in:
Rendo 2025-07-22 03:23:46 +05:00
commit a4c58bb245
19 changed files with 405 additions and 61 deletions

View file

@ -13,6 +13,8 @@ public partial class Seedpacket : TextureButton
private TextureRect _icon;
private Timer _timer;
private SeedpacketHandler _handler;
public bool _forbidden;
public bool _locked;
public bool disablePacket = false;
@ -22,7 +24,7 @@ public partial class Seedpacket : TextureButton
public override void _Ready()
{
if (_resource != null)
UpdateContents();
UpdateContents();
if (Prefab == null)
{
Prefab = ResourceLoader.Load<PackedScene>(PATH_TO_PACKED_SCENE);
@ -44,10 +46,10 @@ public partial class Seedpacket : TextureButton
}
if (_handler is ISeedpacketProcess processHandler) processHandler.Process();
}
public void SetResource(DisplayResource resource )
public void SetResource(DisplayResource resource)
{
_resource = resource;
UpdateContents();
}
@ -77,6 +79,7 @@ public partial class Seedpacket : TextureButton
public override void _Pressed()
{
GrabFocus();
if (_forbidden || _locked) return;
if (_handler is ISeedpacketPress pressHandler)
pressHandler.Pressed();
}
@ -91,4 +94,14 @@ public partial class Seedpacket : TextureButton
{
if (_handler is ISeedpacketUnfocus unfocusHandler) unfocusHandler.OnUnfocused();
}
public void SetForbidden(bool value)
{
_forbidden = value;
GetNode<TextureRect>("ForbiddenTexture").Visible = value;
}
public void SetLocked(bool value)
{
_locked = value;
GetNode<TextureRect>("LockedTexture").Visible = value;
}
}