public void Initialize() { this.GSAI = new GSAI(this); for (int key = 1; key < 100; ++key) { Fleet fleet = new Fleet(); fleet.Owner = this; string str = ""; switch (key) { case 0: str = "10th"; break; case 1: str = "1st"; break; case 2: str = "2nd"; break; case 3: str = "3rd"; break; case 4: str = "4th"; break; case 5: str = "5th"; break; case 6: str = "6th"; break; case 7: str = "7th"; break; case 8: str = "8th"; break; case 9: str = "9th"; break; } fleet.Name = str + " fleet"; this.FleetsDict.TryAdd(key, fleet); } foreach (KeyValuePair<string, Technology> keyValuePair in ResourceManager.TechTree) { TechEntry techEntry = new TechEntry(); techEntry.Progress = 0.0f; techEntry.UID = keyValuePair.Key; //added by McShooterz: Checks if tech is racial, hides it, and reveals it only to races that pass if (keyValuePair.Value.RaceRestrictions.Count != 0) { techEntry.Discovered = false; techEntry.GetTech().Secret = true; foreach (Technology.RequiredRace raceTech in keyValuePair.Value.RaceRestrictions) { if (raceTech.ShipType == this.data.Traits.ShipType) { techEntry.Discovered = true; techEntry.Unlocked = keyValuePair.Value.RootNode == 1; if (this.data.Traits.Militaristic == 1 && techEntry.GetTech().Militaristic) techEntry.Unlocked = true; break; } } } else //not racial tech { techEntry.Unlocked = keyValuePair.Value.RootNode == 1; } if (this.isFaction || this.data.Traits.Prewarp == 1) { techEntry.Unlocked = false; } if (this.data.Traits.Militaristic == 1) { //added by McShooterz: alternate way to unlock militaristic techs if (techEntry.GetTech().Militaristic && techEntry.GetTech().RaceRestrictions.Count == 0) techEntry.Unlocked = true; // If using the customMilTraitsTech option in ModInformation, default traits will NOT be automatically unlocked. Allows for totally custom militaristic traits. if (GlobalStats.ActiveModInfo == null || (GlobalStats.ActiveModInfo != null && !GlobalStats.ActiveModInfo.customMilTraitTechs)) { if (techEntry.UID == "HeavyFighterHull") { techEntry.Unlocked = true; } if (techEntry.UID == "Military") { techEntry.Unlocked = true; } if (techEntry.UID == "ArmorTheory") { techEntry.Unlocked = true; } } } if(this.data.Traits.Cybernetic >0) { if (techEntry.UID == "Biospheres") techEntry.Unlocked = true; } if (techEntry.Unlocked) techEntry.Progress = techEntry.GetTech().Cost * UniverseScreen.GamePaceStatic; this.TechnologyDict.Add(keyValuePair.Key, techEntry); } foreach (KeyValuePair<string, ShipData> keyValuePair in ResourceManager.HullsDict) this.UnlockedHullsDict.Add(keyValuePair.Value.Hull, false); foreach (KeyValuePair<string, Troop> keyValuePair in ResourceManager.TroopsDict) this.UnlockedTroopDict.Add(keyValuePair.Key, false); foreach (KeyValuePair<string, Building> keyValuePair in ResourceManager.BuildingsDict) this.UnlockedBuildingsDict.Add(keyValuePair.Key, false); foreach (KeyValuePair<string, ShipModule> keyValuePair in ResourceManager.ShipModulesDict) this.UnlockedModulesDict.Add(keyValuePair.Key, false); //unlock from empire data file foreach (string building in this.data.unlockBuilding) this.UnlockedBuildingsDict[building] = true; foreach (KeyValuePair<string, TechEntry> keyValuePair in this.TechnologyDict) { if (keyValuePair.Value.Unlocked) { keyValuePair.Value.Unlocked = false; this.UnlockTech(keyValuePair.Key); } } //unlock ships from empire data foreach (string ship in this.data.unlockShips) this.ShipsWeCanBuild.Add(ship); //clear these lists as they serve no more purpose this.data.unlockBuilding.Clear(); this.data.unlockShips.Clear(); this.UpdateShipsWeCanBuild(); if (this.data.EconomicPersonality == null) this.data.EconomicPersonality = new ETrait { Name = "Generalists" }; //Added by McShooterz: mod support for EconomicResearchStrategy folder try { if (File.Exists(string.Concat(Ship_Game.ResourceManager.WhichModPath, "/EconomicResearchStrategy/", this.data.EconomicPersonality.Name, ".xml"))) { this.economicResearchStrategy = (EconomicResearchStrategy)ResourceManager.EconSerializer.Deserialize((Stream)new FileInfo(string.Concat(Ship_Game.ResourceManager.WhichModPath, "/EconomicResearchStrategy/", this.data.EconomicPersonality.Name, ".xml")).OpenRead()); } else { this.economicResearchStrategy = (EconomicResearchStrategy)ResourceManager.EconSerializer.Deserialize((Stream)new FileInfo("Content/EconomicResearchStrategy/" + this.data.EconomicPersonality.Name + ".xml").OpenRead()); } } catch(Exception e) { e.Data.Add("Failing File: ", string.Concat(Ship_Game.ResourceManager.WhichModPath, "/EconomicResearchStrategy/", this.data.EconomicPersonality.Name, ".xml")); e.Data.Add("Fail Reaseon: ", e.InnerException); throw e; } //Added by gremlin Figure out techs with modules that we have ships for. foreach (KeyValuePair<string,TechEntry> tech in this.TechnologyDict) { if(tech.Value.GetTech().ModulesUnlocked.Count>0 && tech.Value.GetTech().HullsUnlocked.Count()==0 && !this.WeCanUseThis(tech.Value.GetTech())) { this.TechnologyDict[tech.Key].shipDesignsCanuseThis = false; } } foreach (KeyValuePair<string,TechEntry> tech in this.TechnologyDict) { if(!tech.Value.shipDesignsCanuseThis) { if(WeCanUseThisLater(tech.Value)) { tech.Value.shipDesignsCanuseThis = true; } } } this.MarkShipDesignsUnlockable(); }
private bool WeCanUseThisLater(TechEntry tech) { //List<Technology.LeadsToTech> leadsto = new List<Technology.LeadsToTech>(); // leadsto =tech.GetTech().LeadsTo; foreach (Technology.LeadsToTech leadsto in tech.GetTech().LeadsTo) { TechEntry entry = this.TechnologyDict[leadsto.UID]; if (entry.shipDesignsCanuseThis == true) return true; else if (WeCanUseThisLater(entry)) return true; } return false; }