30 lines
890 B
C#
30 lines
890 B
C#
using Godot;
|
|
using Newlon.Components.GUI.Seedpackets;
|
|
|
|
namespace Newlon.Components.GUI;
|
|
|
|
public partial class GridLoader : GridContainer
|
|
{
|
|
private const string PLANT_RESOURCE_PATH = "res://resources/plants/";
|
|
private PackedScene _plantCard;
|
|
|
|
public override void _Ready()
|
|
{
|
|
_plantCard = ResourceLoader.Load<PackedScene>("res://scenes/gui/seedpacket.tscn");
|
|
|
|
string[] files = DirAccess.GetFilesAt(PLANT_RESOURCE_PATH);
|
|
|
|
foreach(var file in files)
|
|
{
|
|
if(ResourceLoader.Exists(PLANT_RESOURCE_PATH+file))
|
|
{
|
|
Seedpacket slot = _plantCard.Instantiate<Seedpacket>();
|
|
AddChild(slot);
|
|
|
|
slot.SetPlantResource(ResourceLoader.Load<PlantResource>(PLANT_RESOURCE_PATH+file));
|
|
slot.SetHandler(new ChoosableHandler(slot));
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|