Advertisement
krock186

Dynamic World Deserializer

Mar 14th, 2015
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. /* A dynamic World Deserializer
  2. Created by Krock
  3. License: BSD 3-Clause
  4.  
  5. First, define the variables "c" and "m".
  6.  
  7. Variable "m" is a PlayerIOClient.Message
  8. For the "init" message:
  9.     uint c = 20; // EE
  10.     uint c = 13; // EE CM
  11. For the "reset"/loadlevel message:
  12.     uint c = 0;
  13. */
  14.  
  15. while (c < m.Count) {
  16.     if (m[c].ToString() == "we")
  17.         break;
  18.  
  19.     int b = m.GetInt(c),
  20.         l = m.GetInt(c + 1);
  21.     byte[] pX = m.GetByteArray(c + 2),
  22.         pY = m.GetByteArray(c + 3);
  23.  
  24.     var arg3 = null;
  25.     // Get additional information about the current block
  26.     // if (b == 43) {
  27.     //  arg3 = m.GetInt(c + 4)
  28.     // }
  29.  
  30.     for (int n = 0; n < pX.Length; n += 2) {
  31.         int x = pX[n] << 8 | pX[n + 1];
  32.         int y = pY[n] << 8 | pY[n + 1];
  33.        
  34.         // Add the blocks to your block array here
  35.         // Variables l, b, x and y are defined
  36.     }
  37.  
  38.     ushort argC = 4;
  39.     for (uint i = c + 4; i < m.Count; i++) {
  40.         if (m[i] is byte[]) {
  41.             argC -= 2;
  42.             break;
  43.         } else if (m[i].ToString() != "we") {
  44.             argC++;
  45.         } else break;
  46.     }
  47.     c += argC;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement