// Byte Serialization
        public virtual void AddToByteStream(VRage.ByteStream stream)
        {
            base.AddToByteStream(stream);

            Log.Trace("Adding Revealed Grid to byte stream", "AddToByteStream");

            if (SpawnOwners == null)
            {
                Log.Error("Serializing with null spawnowners", "AddToByteStream");
                SpawnOwners = new List <long>();
            }

            if (BigOwners == null)
            {
                Log.Error("Serializing with null BigOwners", "AddToByteStream");
                BigOwners = new List <long>();
            }

            Log.Info("Adding spawnowners ", "FromBytes");
            stream.addLongList(SpawnOwners);
            Log.Info("Adding BigOwners ", "FromBytes");
            stream.addLongList(BigOwners);
            stream.addBoolean(NeededForSpawn);
            stream.addBoolean(IsProducing);
            stream.addBoolean(IsChargingBatteries);
            stream.addBoolean(IsPiloted);
        }
        // Byte Deserialization
        public RevealedGrid(ByteStream stream)
            : base(stream)
        {
            Log.ClassName = "GP.Concealment.World.Entities.RevealedGrid";

            Log.Trace("Deserializing revealed grid", "stream ctr");
            //Log.Info("Pos " + stream.Position + " / " + stream.Length, "FromBytes");
            Grid = Entity as IMyCubeGrid;
            //Log.Info("Getting spawnowners ", "FromBytes");
            SpawnOwners = stream.getLongList();
            //Log.Info("Getting bigowners ", "FromBytes");
            BigOwners = stream.getLongList();
            //Log.Info("Finished, pos " + stream.Position + " / " + stream.Length, "FromBytes");

            if (SpawnOwners == null) {
                Log.Error("Deserialized with null spawnowners", "stream ctr");
                SpawnOwners = new List<long>();
            }

            if (BigOwners == null) {
                Log.Error("Deserialized with null BigOwners", "stream ctr");
                BigOwners = new List<long>();
            }

            NeededForSpawn = stream.getBoolean();
            IsProducing = stream.getBoolean();
            IsChargingBatteries = stream.getBoolean();
            IsPiloted = stream.getBoolean();

            Log.Trace("New CubeGrid " + Entity.EntityId + " " + DisplayName, "ctr");
        }
        public void DeserializeList(ByteStream source, List<Vector3I> outList)
        {
            m_tmp.Clear();
            ushort count;
            Segment seg;
            Vector3I pos;
            BlitSerializer<ushort>.Default.Deserialize(source, out count);
            for (int i = 0; i < count; i++)
            {
                BlitSerializer<Segment>.Default.Deserialize(source, out seg);
                for (pos.X = 0; pos.X < seg.Size.X; pos.X++)
                {
                    for (pos.Y = 0; pos.Y < seg.Size.Y; pos.Y++)
                    {
                        for (pos.Z = 0; pos.Z < seg.Size.Z; pos.Z++)
                        {
                            m_tmp.Add(seg.Min + pos);
                        }
                    }
                }
            }

            foreach (var p in m_tmp)
            {
                outList.Add(p);
            }
        }
Example #4
0
        public void AddToByteSteam(ByteStream stream)
        {
            if (stream == null) throw new ArgumentException("null stream");

            stream.addUShort(Major);
            stream.addUShort(Minor);
            stream.addUShort(Patch);
            stream.addString(GitSHA);
        }
Example #5
0
        public AppVersion(ByteStream stream)
        {
            if (stream == null) throw new ArgumentException("null stream");

            Major = stream.getUShort();
            Minor = stream.getUShort();
            Patch = stream.getUShort();
            GitSHA = stream.getString();
        }
        public ItemCountAggregateDefinition(ByteStream stream)
        {
            if (stream == null) throw new ArgumentException("null stream");

            ushort len = stream.getUShort();
            for (ushort i = 0; i < len; ++i) {
                Counts.Add(new ItemCountDefinition(stream));
            }
        }
        public void AddToByteSteam(ByteStream stream)
        {
            if (stream == null) throw new ArgumentException("null stream");

             //Log.Trace("serializing Counts count " + Counts.Count, "AddToByteSteam");
             stream.addUShort((ushort)Counts.Count);
             foreach (var count in Counts) {
                 count.AddToByteSteam(stream);
             }
        }
Example #8
0
        public void AddToByteSteam(ByteStream stream)
        {
            if (stream == null) throw new ArgumentException("null stream");

             //Log.Trace(String.Format("serializing TypeName \"{0}\"",TypeName), "AddToByteSteam");
             stream.addString(TypeName);
             //Log.Trace(String.Format("serializing SubtypeName \"{0}\"", SubtypeName), "AddToByteSteam");
             stream.addString(SubtypeName);
             //Log.Trace(String.Format("serializing Count \"{0}\"", Count), "AddToByteSteam");
             stream.addDouble(Count);
        }
Example #9
0
        public ItemCountDefinition(ByteStream stream)
        {
            if (stream == null) throw new ArgumentException("null stream");

            TypeName = stream.getString();
            //Log.Trace(String.Format("deserialized TypeName \"{0}\"", TypeName), "ctr");
            SubtypeName = stream.getString();
            //Log.Trace(String.Format("deserialized SubtypeName \"{0}\"", SubtypeName), "ctr");
            Count = stream.getDouble();
            //Log.Trace(String.Format("deserialized Count \"{0}\"", Count), "ctr");
        }
 public void SerializeList(ByteStream destination, List<Vector3I> positions, int index = 0, int count = int.MaxValue)
 {
     var segments = GetSegments(positions, index, count);
     ushort itemCount = (ushort)segments.Count;
     Segment seg;
     BlitSerializer<ushort>.Default.Serialize(destination, ref itemCount);
     for (int i = 0; i < itemCount; i++)
     {
         var s = segments[i];
         seg.Min = s.Min;
         var size = s.Size;
         seg.Size = new Vector3Ushort((ushort)size.X, (ushort)size.Y, (ushort)size.Z);
         BlitSerializer<Segment>.Default.Serialize(destination, ref seg);
     }
 }
 private void TestByteSerialization(SpecCase x)
 {
     var stream = new ByteStream(0, true);
     var a = new ItemCountDefinition() {
         TypeName = "some type",
         SubtypeName = "some subtype",
         Count = 47
     };
     a.AddToByteSteam(stream);
     stream = new ByteStream(stream.Data, stream.Data.Length);
     var a2 = new ItemCountDefinition(stream);
     x.Assert(a2.TypeName == "some type",
         "Name serializes/deserializes correctly.");
     x.Assert(a2.SubtypeName == "some subtype",
         "SubtypeName serializes/deserializes correctly.");
     x.Assert(a2.Count == 47,
         "Count serializes/deserializes correctly.");
 }
 private void TestByteSerialization(SpecCase x)
 {
     var stream = new ByteStream(0, true);
     var a = new ItemCountAggregateDefinition() {
         Counts = new List<ItemCountDefinition>() {
             new ItemCountDefinition() {
                 TypeName = "type 1"
             },
             new ItemCountDefinition() {
                 TypeName = "type 2"
             }
         }
     };
     //Log.Trace("serializing", "TestByteSerialization");
     a.AddToByteSteam(stream);
     stream = new ByteStream(stream.Data, stream.Data.Length);
     //Log.Trace("deserializing", "TestByteSerialization");
     var a2 = new ItemCountAggregateDefinition(stream);
     x.Assert(a2.Counts[0].TypeName == "type 1",
         "First item serializes/deserializes correctly.");
     x.Assert(a2.Counts[1].TypeName == "type 2",
         "Second item serializes/deserializes correctly.");
 }