using Godot; using System; using System.Collections.Generic; public partial class GameScene : Control { // 资源类型枚举 public enum ResourceType { IronOre, CopperOre, IronIngot, CopperIngot } // 资源数据结构 public class ResourceData { public string Name { get; set; } public int Amount { get; set; } public ResourceType Type { get; set; } public bool IsProcessed { get; set; } } // 电力系统数据 private float powerGeneration = 0; private float powerConsumption = 0; private float powerStorage = 0; private float powerDischarge = 0; // 库存数据(保留用于兼容性,但主要由InventoryManager管理) private Dictionary inventory = new Dictionary(); // UI引用 private Label powerGenerationLabel; private Label powerConsumptionLabel; private Label powerStorageLabel; private Label powerDischargeLabel; private TabContainer categoryTabs; private CraftingQueueManager craftingQueue; public override void _Ready() { GD.Print("GameScene _Ready 开始"); // 先初始化管理器系统,确保在UI创建之前完成 InitializeManagers(); // 等待一帧确保管理器完全初始化 CallDeferred(nameof(InitializeUI)); } private void InitializeManagers() { // 创建ProductionLineManager var productionLineManager = new ProductionLineManager(); productionLineManager.Name = "ProductionLineManager"; AddChild(productionLineManager); // 创建ProductionProcessor var productionProcessor = new ProductionProcessor(); productionProcessor.Name = "ProductionProcessor"; AddChild(productionProcessor); // 创建PowerManager var powerManager = new PowerManager(); powerManager.Name = "PowerManager"; AddChild(powerManager); GD.Print("自动产线管理器和电力管理器初始化完成"); } private void InitializeUI() { GD.Print("开始初始化UI"); // 测试ProductionLineManager是否正常 var productionLineManager = ProductionLineManager.Instance; if (productionLineManager != null) { var allLines = productionLineManager.GetAllProductionLines(); GD.Print($"ProductionLineManager已初始化,共有 {allLines.Count} 个生产线"); var categories = productionLineManager.GetAllCategories(); GD.Print($"生产线分类数: {categories.Count}"); foreach (var category in categories) { GD.Print($"- 分类: {category}"); } } else { GD.PrintErr("ProductionLineManager 仍然为null!"); } // 获取UI引用 powerGenerationLabel = GetNode