using Godot; using System; using System.Collections.Generic; using System.Linq; using System.Text.Json; public partial class ResourceLoader { public static PackedScene LoadLayerPrefab() { return GD.Load($"res://Prefabs/Layer.tscn"); } public static PackedScene LoadRobotPrefab() { return GD.Load($"res://Prefabs/Robot/Robot.tscn"); } public static PackedScene LoadRobotDisplay() { return GD.Load($"res://Prefabs/Robot/RobotDisplay.tscn"); } public static PackedScene LoadItemDisplay() { return GD.Load($"res://Prefabs/Crafting/ItemDisplay.tscn"); } public static Texture2D LoadPath(string path) { return GD.Load(path); } public static Dictionary LoadTiles() { Dictionary tileMeshes = new Dictionary(); PackedScene tileCollection = GD.Load($"res://Assets/Objects/Tiles.glb"); Node root = tileCollection.Instantiate(); foreach (MeshInstance3D child in root.GetChildren()) { tileMeshes.Add(child.Name.ToString().ToLower(), child); } return tileMeshes; } public static Dictionary LoadDecorations() { Dictionary decorationMeshes = new Dictionary(); PackedScene decorationCollection = GD.Load($"res://Assets/Objects/Decorations.glb"); Node root = decorationCollection.Instantiate(); foreach (MeshInstance3D child in root.GetChildren()) { decorationMeshes.Add(child.Name.ToString().ToLower(), child); } return decorationMeshes; } public static Dictionary LoadDSLNodes() { Dictionary nodes = new() { { new MoveNode(), GD.Load($"res://Prefabs/DSL/MoveNode.tscn") }, { new HarvestNode(), GD.Load($"res://Prefabs/DSL/HarvestNode.tscn") }, { new CraftNode(), GD.Load($"res://Prefabs/DSL/CraftNode.tscn") }, { new ExploreNode(), GD.Load($"res://Prefabs/DSL/ExploreNode.tscn") } }; return nodes; } public static Dictionary LoadResourceSymbols() { Dictionary symbols = new() { { "iron_ore", GD.Load($"res://Assets/Images/Resources/IronSymbol.png") }, { "tin_ore", GD.Load($"res://Assets/Images/Resources/TinSymbol.png") }, { "copper_ore", GD.Load($"res://Assets/Images/Resources/CopperSymbol.png") }, { "mushroom", GD.Load($"res://Assets/Images/Resources/MushroomSymbol.png") }, { "spider_silk", GD.Load($"res://Assets/Images/Resources/SpiderSilkSymbol.png") }, { "coal", GD.Load($"res://Assets/Images/Resources/CoalSymbol.png") }, { "water", GD.Load($"res://Assets/Images/Resources/WaterSymbol.png") }, { "stone", GD.Load($"res://Assets/Images/Resources/StoneSymbol.png") }, }; return symbols; } public static Dictionary LoadItems() { FileAccess file = FileAccess.Open("res://Assets/Recipes.json", FileAccess.ModeFlags.Read); string json = file.GetAsText(); Dictionary result = new(); List items = JsonSerializer.Deserialize>(json); foreach (ItemData item in items) { result.Add(item.Id, item); } return result; } }