Beispiel #1
0
        public void ReadFromFile(BinaryReader reader)
        {
            uint CarTuningPackAvailabilityValue = reader.ReadUInt32();
            uint count0  = reader.ReadUInt32();
            uint count1  = reader.ReadUInt32();
            uint unknown = reader.ReadUInt32();

            availabilitys = new CarTuningPackAvailabilityItem[count0];

            for (int i = 0; i < count1; i++)
            {
                CarTuningPackAvailabilityItem Item = new CarTuningPackAvailabilityItem();
                Item.ID = reader.ReadInt32();
                Item.OverrideTuningItemsOffset = reader.ReadUInt32();
                Item.TuningItemsCount1         = reader.ReadInt32();
                Item.TuningItemsCount2         = reader.ReadInt32();
                Item.VehicleID   = reader.ReadInt32();
                Item.Zero        = reader.ReadInt32();
                Item.PackageName = reader.ReadUInt64();

                availabilitys[i] = Item;
            }

            for (int i = 0; i < count1; i++)
            {
                var Item = availabilitys[i];
                Item.TuningItems = new int[Item.TuningItemsCount1];
                for (int z = 0; z < Item.TuningItemsCount1; z++)
                {
                    Item.TuningItems[z] = reader.ReadInt32();
                }
                availabilitys[i] = Item;
            }
        }
Beispiel #2
0
        public void SetFromTreeNodes(TreeNode Root)
        {
            PackAvailability = new CarTuningPackAvailabilityItem[Root.Nodes.Count];

            for (int i = 0; i < PackAvailability.Length; i++)
            {
                TreeNode ChildNode = Root.Nodes[i];
                CarTuningPackAvailabilityItem Entry = (CarTuningPackAvailabilityItem)ChildNode.Tag;
                PackAvailability[i] = Entry;
            }
        }
Beispiel #3
0
        public void WriteToFile(XBinWriter writer)
        {
            writer.Write(16);
            writer.Write(availabilitys.Length);
            writer.Write(availabilitys.Length);
            writer.Write(0);

            int i = 0;

            long[] offsets = new long[availabilitys.Length];
            foreach (var availability in availabilitys)
            {
                CarTuningPackAvailabilityItem Item = availabilitys[i];
                writer.Write(Item.ID);
                offsets[i] = writer.BaseStream.Position;
                writer.Write(0); //placeholder
                writer.Write(Item.TuningItemsCount1);
                writer.Write(Item.TuningItemsCount2);
                writer.Write(Item.VehicleID);
                writer.Write(Item.Zero);
                writer.Write(Item.PackageName);
                i++;
            }

            for (int j = 0; j < availabilitys.Length; j++)
            {
                CarTuningPackAvailabilityItem Item = availabilitys[j];

                if (Item.TuningItemsCount1 != 0)
                {
                    uint thisPosition = (uint)(writer.BaseStream.Position);
                    for (int z = 0; z < Item.TuningItemsCount1; z++)
                    {
                        writer.Write(Item.TuningItems[z]);
                    }

                    long currentPosition = writer.BaseStream.Position;
                    writer.BaseStream.Position = offsets[j];
                    var offset = (uint)(thisPosition - offsets[j]);
                    writer.Write(offset);
                    writer.BaseStream.Position = currentPosition;
                }
            }
            offsets = new long[0];
        }