Exemplo n.º 1
0
        public static void ReadEntities(BinaryReader reader, ref List <BPEntityData> entities)
        {
            int count = reader.ReadInt32();

            entities.Capacity = count;
            for (int i = 0; i < count; ++i)
            {
                BPEntityData bpEntityData = new BPEntityData();
                ReadBPEntityData(reader, ref bpEntityData);
                entities.Add(bpEntityData);
            }
        }
Exemplo n.º 2
0
        public static void WriteEntities(BinaryWriter writer, List <BPEntityData> entities)
        {
            int count = 0;

            if (entities == null || entities.Count == 0)
            {
                writer.Write(count);
            }
            else
            {
                count = entities.Count;
                writer.Write(count);
                for (int i = 0; i < count; ++i)
                {
                    BPEntityData bpEntityData = entities[i];
                    WriteBPEntityData(writer, bpEntityData);
                }
            }
        }
Exemplo n.º 3
0
        public static void ReadBPEntityData(BinaryReader reader, ref BPEntityData bpEntityData)
        {
            bpEntityData.entityId = reader.ReadInt32();
            bpEntityData.protoId  = reader.ReadInt32();
            bpEntityData.type     = (BPEntityType)reader.ReadByte();
            BinaryHelper.TryReadVector3(reader, ref bpEntityData.pos);
            BinaryHelper.TryReadQuaternion(reader, ref bpEntityData.rot);
            BinaryHelper.TryReadVector2(reader, ref bpEntityData.grid);
            bpEntityData.offsetGround = reader.ReadSingle();
            bpEntityData.pickOffset   = reader.ReadInt16();
            bpEntityData.insertOffset = reader.ReadInt16();
            bpEntityData.recipeId     = reader.ReadInt32();
            bpEntityData.filterId     = reader.ReadInt32();
            BinaryHelper.TryReadVector3(reader, ref bpEntityData.pos2);
            BinaryHelper.TryReadQuaternion(reader, ref bpEntityData.rot2);
            BinaryHelper.TryReadVector2(reader, ref bpEntityData.grid2);
            bpEntityData.offsetGround2 = reader.ReadSingle();

            bpEntityData.parameters = BinaryHelper.ReadIntArray(reader, ref bpEntityData.paramCount);
        }
Exemplo n.º 4
0
        public static void WriteBPEntityData(BinaryWriter writer, BPEntityData bpEntityData)
        {
            writer.Write(bpEntityData.entityId);
            writer.Write(bpEntityData.protoId);
            writer.Write((byte)bpEntityData.type);
            BinaryHelper.WriteVector3(writer, ref bpEntityData.pos);
            BinaryHelper.WriteQuaternion(writer, ref bpEntityData.rot);
            BinaryHelper.WriteVector2(writer, ref bpEntityData.grid);

            writer.Write(bpEntityData.offsetGround);
            writer.Write(bpEntityData.pickOffset);
            writer.Write(bpEntityData.insertOffset);
            writer.Write(bpEntityData.recipeId);
            writer.Write(bpEntityData.filterId);

            BinaryHelper.WriteVector3(writer, ref bpEntityData.pos2);
            BinaryHelper.WriteQuaternion(writer, ref bpEntityData.rot2);
            BinaryHelper.WriteVector2(writer, ref bpEntityData.grid2);
            writer.Write(bpEntityData.offsetGround2);
            BinaryHelper.WriteIntArr(writer, bpEntityData.parameters, 0, bpEntityData.paramCount);
        }