private void HandleGetWorld(NetworkMessage msg) { MsgGetWorld wldChunk = msg as MsgGetWorld; if (Unpacker == null) { Unpacker = new WorldUnpacker(); } Unpacker.AddData(wldChunk.Data); if (wldChunk.Offset > 0) { if (WorldDownloadProgress != null) { WorldDownloadProgress.Invoke(this, new WorldDownloadProgressEventArgs((float)Unpacker.Size() / (float)(((UInt32)wldChunk.Offset + Unpacker.Size())))); } NetClient.SendMessage(new MsgGetWorld((UInt32)Unpacker.Size())); } else { if (WorldDownloadProgress != null) { WorldDownloadProgress.Invoke(this, new WorldDownloadProgressEventArgs(1)); } SetMap(Unpacker.Unpack()); if (WorldCache != null) { WorldCache.SaveMapToCache(WorldHash, Unpacker.GetBuffer()); } SendEnter(); } }
private void worldWWW_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { if (WorldDownloadProgress != null) { WorldDownloadProgress.Invoke(this, new WorldDownloadProgressEventArgs(1.0f)); } if (e.Cancelled || e.Error != null) { SendGetWorld(); } else { WorldUnpacker unpacker = new WorldUnpacker(e.Result); SetMap(unpacker.Unpack()); if (Map == null) { SendGetWorld(); } else { WorldCache.SaveMapToCache(WorldHash, unpacker.GetBuffer()); SendEnter(); } } }