Пример #1
0
        public void DeserializeData(object[] Target, int ItemsToExpect, ArcenDeserializationBuffer Buffer, bool IsLoadingFromNetwork, GameVersion DeserializingFromGameVersion)
        {
            for (Items itemEnum = 0; itemEnum < Items.Length && (int)itemEnum < ItemsToExpect; itemEnum++)
            {
                if (!Buffer.ReadBool())
                {
                    continue;
                }
                switch (itemEnum)
                {
                case Items.Primitives:
                {
                    Primitives item = ( Primitives)Target[(int)itemEnum];

                    item.SecondsUntilNextDoomAttack          = Buffer.ReadInt32();
                    item.LastDoomAttackLaunchedAgainstPlayer = Buffer.ReadBool();
                    item.SecondsUntilNextDoomPlanetPick      = Buffer.ReadInt32();
                }
                break;

                case Items.DoomedPlanetIndices:
                {
                    List <int> item = new List <int>();
                    Target[(int)Items.DoomedPlanetIndices] = item;

                    int countToExpect = Buffer.ReadInt32();
                    for (int i = 0; i < countToExpect; i++)
                    {
                        item.Add(Buffer.ReadInt32());
                    }
                }
                break;
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Used to load our data from the buffer.
        /// </summary>
        /// <remarks>
        /// Make sure that laoding order is the same as the saving order.</remarks>
        /// <param name="Buffer"></param>
        public CivilianCargo(ArcenDeserializationBuffer Buffer)
        {
            this.Version = Buffer.ReadInt32(ReadStyle.NonNeg);
            // Lists require a special touch to load.
            // We'll have saved the number of items stored up above to be used here to determine the number of items to load.
            // ADDITIONALLY we'll need to recreate our arrays beforehand, as loading does not call the Initialization function.
            // Can't add values to an array that doesn't exist, after all.
            // Its more important to be accurate than it is to be update safe here, so we'll always use our stored value to figure out the number of resources.
            int savedCount        = Buffer.ReadInt32(ReadStyle.NonNeg);
            int resourceTypeCount = (int)CivilianResource.Length;

            for (int x = 0; x < resourceTypeCount; x++)
            {
                if (x >= savedCount)
                {
                    this.Amount[x]    = 0;
                    this.Capacity[x]  = 100;
                    this.PerSecond[x] = 0;
                }
                else
                {
                    this.Amount[x]    = Buffer.ReadInt32(ReadStyle.NonNeg);
                    this.Capacity[x]  = Buffer.ReadInt32(ReadStyle.NonNeg);
                    this.PerSecond[x] = Buffer.ReadInt32(ReadStyle.Signed);
                }
            }
        }
Пример #3
0
 /// <summary>
 /// Loading our data. Make sure the loading order is the same as the saving order.
 /// </summary>
 public CivilianStatus(ArcenDeserializationBuffer Buffer)
 {
     this.Version = Buffer.ReadInt32(ReadStyle.NonNeg);
     if (this.Version < 2)
     {
         Buffer.ReadInt32(ReadStyle.Signed);
     }
     this.Origin      = Buffer.ReadInt32(ReadStyle.Signed);
     this.Destination = Buffer.ReadInt32(ReadStyle.Signed);
     this.LoadTimer   = Buffer.ReadInt32(ReadStyle.Signed);
 }
Пример #4
0
        /// <summary>
        /// Used to load our data from buffer.
        /// </summary>
        /// <param name="Buffer"></param>
        public CivilianMilitia(ArcenDeserializationBuffer Buffer)
        {
            this.Version     = Buffer.ReadInt32(ReadStyle.NonNeg);
            this.Centerpiece = Buffer.ReadInt32(ReadStyle.Signed);
            this.Status      = (CivilianMilitiaStatus)Buffer.ReadByte(ReadStyleByte.Normal);
            if (this.Version < 2)
            {
                this.PlanetFocus = (short)Buffer.ReadInt32(ReadStyle.Signed);
            }
            else
            {
                this.PlanetFocus = Buffer.ReadInt16(ReadStyle.Signed);
            }
            this.EntityFocus = Buffer.ReadInt32(ReadStyle.Signed);
            int count = Buffer.ReadInt32(ReadStyle.NonNeg);

            for (int x = 0; x < count; x++)
            {
                this.ShipTypeData.Add(x, Buffer.ReadString());
                this.Ships[x] = new List <int>();
                int subCount = Buffer.ReadInt32(ReadStyle.NonNeg);
                for (int y = 0; y < subCount; y++)
                {
                    this.Ships[x].Add(Buffer.ReadInt32(ReadStyle.NonNeg));
                }
                this.ShipCapacity[x] = Buffer.ReadInt32(ReadStyle.NonNeg);
            }
            if (this.ShipTypeData.Count < (int)CivilianResource.Length)
            {
                for (int x = count; x < (int)CivilianResource.Length; x++)
                {
                    this.ShipTypeData.Add(x, "none");
                    this.Ships.Add(x, new List <int>());
                    this.ShipCapacity.Add(x, 0);
                }
            }
            this.CostMultiplier = Buffer.ReadInt32(ReadStyle.NonNeg);
            this.CapMultiplier  = Buffer.ReadInt32(ReadStyle.NonNeg);
        }
Пример #5
0
 /// <summary>
 /// Used to load our data.
 /// </summary>
 /// <remarks>
 /// Make sure that loading order is the same as the saving order.
 /// </remarks>
 /// <param name="Buffer"></param>
 public CivilianWorld(ArcenDeserializationBuffer Buffer)
 {
     Version = Buffer.ReadInt32(ReadStyle.NonNeg);
     this.GeneratedResources = Buffer.ReadBool();
 }
Пример #6
0
 /// <summary>
 /// Used to load data. Make sure the loading order is the same as the saving order.
 /// </summary>
 public CivilianPlanet(ArcenDeserializationBuffer Buffer)
 {
     this.Version  = Buffer.ReadInt32(ReadStyle.NonNeg);
     this.Resource = (CivilianResource)Buffer.ReadByte(ReadStyleByte.Normal);
 }
Пример #7
0
 public void DeserializeData(object[] Target, int ItemsToExpect, ArcenDeserializationBuffer Buffer, bool IsLoadingFromNetwork, GameVersion DeserializingFromGameVersion)
 {
     //reverses SerializeData; gets the date out of the buffer and populates the variables
     fleetID   = Buffer.ReadInt32();
     Target[0] = fleetID;
 }