/// <summary> /// 初期化 /// </summary> public static void Init() { _Equipments.Clear(); X4Database.Instance.ExecQuery("SELECT EquipmentID, EquipmentTypeID, SizeID, Name FROM Equipment", (dr, args) => { var id = (string)dr["EquipmentID"]; var type = (string)dr["EquipmentTypeID"]; var size = (string)dr["SizeID"]; var name = (string)dr["Name"]; _Equipments.Add(id, new Equipment(id, name, EquipmentType.Get(type), X4Size.Get(size))); }); }
/// <summary> /// 初期化 /// </summary> public static void Init() { _Modules.Clear(); const string sql1 = "SELECT ModuleID, ModuleTypeID, Name, MaxWorkers, WorkersCapacity, NoBlueprint FROM Module"; foreach (var record in X4Database.Instance.Query <ModuleTable>(sql1)) { var moduleType = ModuleType.Get(record.ModuleTypeID); const string sql2 = "SELECT FactionID FROM ModuleOwner WHERE ModuleID = :ModuleID"; var owners = X4Database.Instance.Query <string>(sql2, record) .Select <string, Faction>(Faction.Get !) .Where(x => x != null) .ToArray(); var buildMethods = record.NoBlueprint ? Array.Empty <ModuleProduction>() : ModuleProduction.Get(record.ModuleID); const string sql3 = "SELECT SizeID, Amount FROM ModuleTurret WHERE ModuleID = :ModuleID"; var turretCapacity = X4Database.Instance .Query <(string sizeID, int amount)>(sql3, record) .ToDictionary(t => X4Size.Get(t.sizeID), t => t.amount); const string sql4 = "SELECT SizeID, Amount FROM ModuleShield WHERE ModuleID = :ModuleID"; var shieldCapacity = X4Database.Instance .Query <(string sizeID, int amount)>(sql4, record) .ToDictionary(t => X4Size.Get(t.sizeID), t => t.amount); var module = new Module(record.ModuleID, record.Name, moduleType, record.MaxWorkers, record.WorkersCapacity, buildMethods, owners, turretCapacity, shieldCapacity); _Modules.Add(record.ModuleID, module); } }