示例#1
0
        public static void Read(PhysicalObject physicalObject, ref BinaryReader reader)
        {
            AbstractPhysicalObjectHandler.Read(physicalObject.abstractPhysicalObject, ref reader);
            //int numberOfAppendages = reader.ReadInt32();
            //if (physicalObject.appendages.Count < numberOfAppendages)
            //{
            //    physicalObject.appendages = new List<PhysicalObject.Appendage>();
            //}
            //for (int a = 0; a < numberOfAppendages; a++)
            //{
            //    physicalObject.appendages[a] = AppendageHandler.Read(physicalObject.appendages[a], ref reader);
            //}

            int numberOfChunks = reader.ReadInt32();

            BodyChunk[] chunks = physicalObject.bodyChunks;

            if (physicalObject.bodyChunks.Length < numberOfChunks)
            {
                chunks = new BodyChunk[numberOfChunks];
            }
            for (int a = 0; a < numberOfChunks; a++)
            {
                chunks[a] = BodyChunkHandler.Read(chunks[a], ref reader);
            }

            SyncPhysicalObject(physicalObject, chunks);

            int numberOFConnections = reader.ReadInt32();

            if (physicalObject.bodyChunkConnections.Length < numberOFConnections)
            {
                physicalObject.bodyChunkConnections = new PhysicalObject.BodyChunkConnection[numberOFConnections];
            }
            for (int a = 0; a < numberOFConnections; a++)
            {
                physicalObject.bodyChunkConnections[a] = BodyChunkConnectionHandler.Read(physicalObject.bodyChunkConnections[a], ref reader);
            }

            physicalObject.bounce            = reader.ReadSingle();
            physicalObject.canBeHitByWeapons = reader.ReadBoolean();
        }
示例#2
0
 public static void Write(PhysicalObject physicalObject, ref BinaryWriter writer)
 {
     AbstractPhysicalObjectHandler.Write(physicalObject.abstractPhysicalObject, ref writer);
     //writer.Write(physicalObject.appendages.Count);
     //foreach (PhysicalObject.Appendage app in physicalObject.appendages)
     //{
     //    AppendageHandler.Write(app, ref writer);
     //}
     writer.Write(physicalObject.bodyChunks.Length);
     foreach (BodyChunk chunk in physicalObject.bodyChunks)
     {
         BodyChunkHandler.Write(chunk, ref writer);
     }
     writer.Write(physicalObject.bodyChunkConnections.Length);
     foreach (PhysicalObject.BodyChunkConnection con in physicalObject.bodyChunkConnections)
     {
         BodyChunkConnectionHandler.Write(con, ref writer);
     }
     writer.Write(physicalObject.bounce);
     writer.Write(physicalObject.canBeHitByWeapons);
 }