public void CleanOut()
 {
     this.OwnedPlanets.Clear();
     this.OwnedShips.Clear();
     this.Relationships.Clear();
     this.GSAI = (GSAI)null;
     this.HostilesPresent.Clear();
     this.ForcePool.Clear();
     this.KnownShips.Clear();
     this.SensorNodes.Clear();
     this.BorderNodes.Clear();
     this.TechnologyDict.Clear();
     this.SpaceRoadsList.Clear();
     foreach (KeyValuePair<int, Fleet> keyValuePair in this.FleetsDict)
         keyValuePair.Value.Ships.Clear();
     this.FleetsDict.Clear();
 }
        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();
        }
        protected void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (this.ForcePool != null)
                        this.ForcePool.Dispose();
                    if (this.BorderNodes != null)
                        this.BorderNodes.Dispose();
                    if (this.SensorNodes != null)
                        this.SensorNodes.Dispose();
                    if (this.OwnedShips != null)
                        this.OwnedShips.Dispose();
                    if (this.SensorNodeLocker != null)
                        this.SensorNodeLocker.Dispose();
                    if (this.BorderNodeLocker != null)
                        this.BorderNodeLocker.Dispose();
                    if (this.DefensiveFleet != null)
                        this.DefensiveFleet.Dispose();
                    if (this.GSAI != null)
                        this.GSAI.Dispose();

                }
                this.ForcePool = null;
                this.BorderNodes = null;
                this.SensorNodes = null;
                this.OwnedShips = null;
                this.SensorNodeLocker = null;
                this.BorderNodeLocker = null;
                this.DefensiveFleet = null;
                this.GSAI = null;
                this.disposed = true;

            }
        }