using Godot; using Newlon.Components.GUI.Seedpackets; using Newlon.Components.Level; namespace Newlon.Components.GUI; public partial class GridLoader : GridContainer { private PackedScene _plantCard; public const string SEEDPACKED_UID = "uid://e7vutg71l6f2"; public override void _Ready() { _plantCard = ResourceLoader.Load(SEEDPACKED_UID); var list = GameRegistry.GetPlants(); list.Sort((a, b) => { return a.Order - b.Order; }); foreach (var resource in list) { Seedpacket slot = _plantCard.Instantiate(); AddChild(slot); slot.SetResource(resource); slot.SetForbidden(RuntimeLevelData.LevelResource.forbiddenPlants.Contains(resource.GetInternalID())); slot.SetLocked(PlayerProgress.Instance.PlayerPlants.Contains(resource) == false); if (GetChildCount() == 1) slot.GrabFocus(); if (RuntimeLevelData.LevelResource.prepickedPlants.Contains(resource.GetInternalID())) { slot.SetHandler(new PrepickedDummyHandler(slot)); slot.disablePacket = true; } else { slot.SetHandler(new ChoosableHandler(slot)); } } } }