public bool WeCanUseThisNow(Technology tech)
        {
            bool flag = false;
            HashSet<string> unlocklist = new HashSet<string>();
            foreach(Technology.UnlockedMod unlocked in tech.ModulesUnlocked)
            {
                unlocklist.Add(unlocked.ModuleUID);
            }

            //Parallel.ForEach(ResourceManager.ShipsDict, (ship, status) =>
            ShipData shipData;
            foreach(KeyValuePair<string,Ship> ship in ResourceManager.ShipsDict )
            {

                shipData = ship.Value.shipData;
                if (shipData.ShipStyle == null || shipData.ShipStyle == this.data.Traits.ShipType)
                {
                    if (shipData == null || (!this.UnlockedHullsDict.ContainsKey(shipData.Hull) || !this.UnlockedHullsDict[shipData.Hull]))
                        continue;
                    foreach (ModuleSlotData module in ship.Value.shipData.ModuleSlotList)
                    {
                        //if (tech.ModulesUnlocked.Where(uid => uid.ModuleUID == module.InstalledModuleUID).Count() > 0)
                        if(unlocklist.Contains(module.InstalledModuleUID))
                        {
                            flag = true;
                            break;
                            //status.Stop();
                            //continue;
                        }
                    }
                    //if (status.IsStopped)
                    //    return;
                }
            }//);
            return flag;
        }
 public static List<string> FindPreviousTechs(Empire empire, Technology target, List<string> alreadyFound)
 {
     bool found = false;
     foreach (KeyValuePair<string, TechEntry> TechTreeItem in empire.TechnologyDict)
     {
         foreach (Technology.LeadsToTech leadsto in TechTreeItem.Value.GetTech().LeadsTo)
         {
             if (leadsto.UID == target.UID)
             {
                 alreadyFound.Add(target.UID);
                 alreadyFound= FindPreviousTechs(empire, TechTreeItem.Value.GetTech(), alreadyFound);
                 //alreadyFound.AddRange(FindPreviousTechs(empire, TechTreeItem.Value.GetTech(), alreadyFound));
                 found = true;
                 break;
             }
         }
         if (found)
             break;
     }
     return alreadyFound;
 }
        public bool WeCanUseThis(Technology tech)
        {
            //foreach(KeyValuePair<string,Ship> ship in ResourceManager.ShipsDict)
            //bool flag = false;
            //Parallel.ForEach(ResourceManager.ShipsDict, (ship, status) =>
            foreach (KeyValuePair<string, Ship> ship in ResourceManager.ShipsDict)
            {
                //if (flag)
                //   break;
                //List<Technology> techtree = new List<Technology>();

                ShipData shipData = ship.Value.shipData;
                if (shipData.ShipStyle == null || shipData.ShipStyle == this.data.Traits.ShipType)
                {
                    foreach (ModuleSlotData module in ship.Value.shipData.ModuleSlotList)
                    {
                        //if (tech.ModulesUnlocked.Where(uid => uid.ModuleUID == module.InstalledModuleUID).Count() > 0)
                        foreach (Ship_Game.Technology.UnlockedMod entry in tech.ModulesUnlocked)
                        {
                            if (entry.ModuleUID == module.InstalledModuleUID)
                                return true;
                        }
                    }
                }
            }
            return false;
        }