예제 #1
0
        private void AddProteanSystemInstance(GameDatabase gamedb, AssetDatabase assetdb, int SystemId)
        {
            GardenerInfo gi = new GardenerInfo();

            gi.SystemId = SystemId;
            List <PlanetInfo> list                = ((IEnumerable <PlanetInfo>)gamedb.GetStarSystemPlanetInfos(SystemId)).ToList <PlanetInfo>();
            int                num1               = 0;
            int                num2               = 0;
            float              num3               = gamedb.GetFactions().Average <FactionInfo>((Func <FactionInfo, float>)(x => x.IdealSuitability));
            Random             safeRandom         = App.GetSafeRandom();
            GardenerGlobalData globalGardenerData = assetdb.GlobalGardenerData;

            foreach (PlanetInfo planet in list)
            {
                if (!gamedb.GetOrbitalObjectInfo(planet.ID).ParentID.HasValue&& planet.Type != "barren" && planet.Type != "gaseous")
                {
                    planet.Biosphere   = safeRandom.Next(globalGardenerData.MinBiosphere, globalGardenerData.MaxBiosphere);
                    planet.Suitability = num3;
                    ++num1;
                    gamedb.UpdatePlanet(planet);
                }
            }
            if (num1 < globalGardenerData.MinPlanets)
            {
                int num4 = globalGardenerData.MinPlanets - num1;
                int num5 = gamedb.GetStarSystemOrbitalObjectInfos(SystemId).Where <OrbitalObjectInfo>((Func <OrbitalObjectInfo, bool>)(x => !x.ParentID.HasValue)).Count <OrbitalObjectInfo>() + 1;
                for (int index = 0; index < num4; ++index)
                {
                    PlanetOrbit planetOrbit = new PlanetOrbit();
                    planetOrbit.OrbitNumber = num5 + index;
                    planetOrbit.Biosphere   = new int?(safeRandom.Next(globalGardenerData.MinBiosphere, globalGardenerData.MaxBiosphere));
                    planetOrbit.Suitability = new float?(num3);
                    PlanetInfo pi = StarSystemHelper.InferPlanetInfo((Kerberos.Sots.Data.StarMapFramework.Orbit)planetOrbit);
                    gamedb.AddPlanetToSystem(SystemId, new int?(), null, pi, new int?(num5 + index));
                }
            }
            List <PlanetInfo> planetInfoList = new List <PlanetInfo>();

            foreach (PlanetInfo planetInfo in list)
            {
                if (planetInfo.Type != "barren" && planetInfo.Type != "gaseous")
                {
                    num2 += (int)planetInfo.Size;
                    planetInfoList.Add(planetInfo);
                }
            }
            int fleetID = gamedb.InsertFleet(this.PlayerId, 0, SystemId, SystemId, "Protean Pod", FleetType.FL_NORMAL);

            gi.FleetId = fleetID;
            gamedb.InsertGardenerInfo(gi);
            int encounterIdAtSystem = gamedb.GetEncounterIDAtSystem(EasterEgg.EE_GARDENERS, gi.SystemId);

            for (int index = 0; index < num2; ++index)
            {
                int shipId = gamedb.InsertShip(fleetID, this._proteanDesignId, null, (ShipParams)0, new int?(), 0);
                int num4   = 0;
                foreach (PlanetInfo planetInfo in planetInfoList)
                {
                    num4 += (int)planetInfo.Size;
                    if (index < num4)
                    {
                        gamedb.InsertProteanShipOrbitMap(encounterIdAtSystem, shipId, planetInfo.ID);
                        break;
                    }
                }
            }
        }