Exemplo n.º 1
0
 public static IEnumerable <ColonyFactionInfo> GetColonyFactionInfosFromOrbitalObjectID(
     SQLiteConnection db,
     int orbitalObjectID)
 {
     foreach (Row row in db.ExecuteTableQuery(string.Format(Queries.GetCivilianPopulationsForColony, (object)orbitalObjectID), true))
     {
         yield return(ColoniesCache.GetColonyFactionInfoFromRow(row, orbitalObjectID));
     }
 }
Exemplo n.º 2
0
        private static ColonyInfo GetColonyInfoFromRow(SQLiteConnection db, Row row)
        {
            int   integer = row[1].SQLiteValueToInteger();
            float single1 = row[6].SQLiteValueToSingle();
            float single2 = row[7].SQLiteValueToSingle();
            float single3 = row[8].SQLiteValueToSingle();
            float single4 = row[13].SQLiteValueToSingle();
            int   num     = db.ExecuteIntegerQuery(string.Format(Queries.GetOrbitalObjectStarSystemID, (object)integer.ToSQLiteValue()));

            return(new ColonyInfo()
            {
                ID = row[0].SQLiteValueToInteger(),
                OrbitalObjectID = integer,
                PlayerID = row[2].SQLiteValueToInteger(),
                ImperialPop = row[3].SQLiteValueToDouble(),
                CivilianWeight = row[4].SQLiteValueToSingle(),
                TurnEstablished = row[5].SQLiteValueToInteger(),
                TerraRate = single1,
                InfraRate = single2,
                ShipConRate = single3,
                TradeRate = ((float)(1.0 - ((double)single1 + (double)single2 + (double)single3 + (double)single4))).Saturate(),
                OverharvestRate = row[9].SQLiteValueToSingle(),
                EconomyRating = row[10].SQLiteValueToSingle(),
                CurrentStage = (ColonyStage)row[11].SQLiteValueToInteger(),
                OverdevelopProgress = row[12].SQLiteValueToSingle(),
                OverdevelopRate = single4,
                PopulationBiosphereRate = row[14].SQLiteValueToSingle(),
                isHardenedStructures = row[15].SQLiteValueToBoolean(),
                RebellionType = (RebellionType)row[16].SQLiteValueToInteger(),
                RebellionTurns = row[17].SQLiteValueToInteger(),
                TurnsOverharvested = row[18].SQLiteValueToInteger(),
                RepairPoints = row[19].SQLiteValueToInteger(),
                SlaveWorkRate = row[20].SQLiteValueToSingle(),
                DamagedLastTurn = row[21].SQLiteValueToBoolean(),
                RepairPointsMax = row[22].SQLiteValueToInteger(),
                OwningColony = row[23].SQLiteValueToBoolean(),
                ReplicantsOn = row[24].SQLiteValueToBoolean(),
                Factions = ColoniesCache.GetColonyFactionInfosFromOrbitalObjectID(db, integer).ToArray <ColonyFactionInfo>(),
                CachedStarSystemID = num
            });
        }
Exemplo n.º 3
0
 protected override IEnumerable <KeyValuePair <int, ColonyInfo> > OnSynchronizeWithDatabase(
     SQLiteConnection db,
     IEnumerable <int> range)
 {
     if (range == null)
     {
         foreach (Row row in db.ExecuteTableQuery(Queries.GetColonyInfos, true))
         {
             ColonyInfo o = ColoniesCache.GetColonyInfoFromRow(db, row);
             yield return(new KeyValuePair <int, ColonyInfo>(o.ID, o));
         }
     }
     else
     {
         foreach (int num in range)
         {
             foreach (Row row in db.ExecuteTableQuery(string.Format(Queries.GetColonyInfo, (object)num.ToSQLiteValue()), true))
             {
                 ColonyInfo o = ColoniesCache.GetColonyInfoFromRow(db, row);
                 yield return(new KeyValuePair <int, ColonyInfo>(o.ID, o));
             }
         }
     }
 }