Example #1
0
 private static CityData GetCityData(this City city, byte id)
 {
     return(new CityData {
         Id = city.GetId(),
         NameId = (byte)city.NameId,
         Status = 0,
         Buildings = city.Buildings.Select(b => b.Id).ToArray(),
         X = city.X,
         Y = city.Y,
         ActualSize = city.Size,
         CurrentProduction = city.CurrentProduction.ProductionId,
         Owner = city.Owner,
         Food = (ushort)city.Food,
         Shields = (ushort)city.Shields,
         ResourceTiles = city.GetResourceTiles()
     });
 }
Example #2
0
        private static CityData GetCityData(this City city, byte id)
        {
            IUnit[] units = city.Tile?.Units.Where(x => x.Home == city && x.Fortify).Take(2).ToArray();

            return(new CityData {
                Id = city.GetId(),
                NameId = (byte)city.NameId,
                Status = 0,
                Buildings = city.Buildings.Select(b => b.Id).ToArray(),
                X = city.X,
                Y = city.Y,
                ActualSize = city.Size,
                CurrentProduction = city.CurrentProduction.ProductionId,
                Owner = city.Owner,
                Food = (ushort)city.Food,
                Shields = (ushort)city.Shields,
                ResourceTiles = city.GetResourceTiles(),
                FortifiedUnits = units?.Select(x => (byte)x.Type).ToArray()
            });
        }
Example #3
0
        // TODO move to a save/load specific file?
        private static CityData GetCityData(this City city, byte id)
        {
            // TODO fire-eggs fails to take 'fortifyING' into account?
            IUnit[] units = city.Tile?.Units.Where(x => x.Home == city && x.Fortify).Take(2).ToArray();

            return(new CityData {
                Id = city.GetId(),
                NameId = (byte)city.NameId,
                Status = 0,
                Buildings = city.Buildings.Select(b => b.Id).ToArray(),
                X = city.X,
                Y = city.Y,
                ActualSize = city.Size,
                CurrentProduction = city.CurrentProduction.ProductionId,
                Owner = city.Owner,
                Food = (ushort)city.Food,
                Shields = (ushort)city.Shields,
                ResourceTiles = city.GetResourceTiles(),
                // fire-eggs 20190622 make sure to save fortify/veteran status as per Microprose
                FortifiedUnits = units?.Select(x => (byte)((int)x.Type | 0x40 | (x.Veteran ? 0x80 : 0))).ToArray()
            });
        }