Ejemplo n.º 1
0
        byte[] BuildShipsUpdateBuffer()
        {
            List <MeshObject> UpdateList = new List <MeshObject>();

            foreach ((var key, var value) in _sws.swSystem.Objects)
            {
                if (value.PhysicsUpdated)
                {
                    UpdateList.Add(value);
                    value.PhysicsUpdated = false;
                }
            }
            int           size   = 1 + sizeof(UInt16) + ShipPacketSize + (UpdateList.Count * MeshUpdatePacketSize);
            PacketEncoder packet = new PacketEncoder(size);

            packet.Write((byte)ListOf_ClientSendFlags.ShipUpdate);
            packet.Write((UInt16)UpdateList.Count);

            packet.Write(_sws.PCShip.Id);
            packet.Write(_sws.PCShip.Location);
            packet.Write(_sws.PCShip.Rotation);

            foreach (var item in UpdateList)
            {
                packet.Write(item.Id);
                packet.Write(item.Location);
                packet.Write(item.Rotation);
            }
            return(packet.GetBuffer());
        }
Ejemplo n.º 2
0
        byte[] BuildFirstUpdateBuffer()
        {
            UInt16 count = (UInt16)_sws.swSystem.Objects.Count;
            int    size  = 1 +              //Header
                           sizeof(UInt16) + //Count of Objects
                           count * MeshFirstPacketSize;

            PacketEncoder packet = new PacketEncoder(size);

            packet.Write((byte)ListOf_ClientSendFlags.FirstUpdate);
            packet.Write(count);
            foreach (var item in _sws.swSystem.Objects)
            {
                packet.Write(item.Value.Id);
                packet.Write((UInt16)item.Value.CollisionMesh);
                packet.Write(item.Value.Location);
                packet.Write(item.Value.Scale);
                packet.Write(item.Value.Rotation);
            }
            return(packet.GetBuffer());
        }