Advertisement
Guest User

Untitled

a guest
Apr 17th, 2013
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.71 KB | None | 0 0
  1. using Firewind.Messages;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6.  
  7. namespace Firewind.HabboHotel.Rooms
  8. {
  9.     // Used for presents & mannequins
  10.     internal class MapStuffData : IRoomItemData
  11.     {
  12.         // 1 = (MapStuffData)         - int i, foreach i { string, string }
  13.         internal Dictionary<string, string> Data;
  14.  
  15.         internal MapStuffData()
  16.         {
  17.             Data = new Dictionary<string, string>();
  18.         }
  19.         public int GetTypeID()
  20.         {
  21.             return 1;
  22.         }
  23.  
  24.         public void Parse(string rawData)
  25.         {
  26.             string[] splitted = rawData.Split(Convert.ToChar(1));
  27.  
  28.             for (int i = 0; i < splitted.Length; i++)
  29.             {
  30.                 Data.Add(splitted[i], splitted[++i]);
  31.             }
  32.         }
  33.  
  34.         public void AppendToMessage(ServerMessage message)
  35.         {
  36.             message.AppendInt32(Data.Count);
  37.             foreach (KeyValuePair<string, string> pair in Data)
  38.             {
  39.                 message.AppendString(pair.Key);
  40.                 message.AppendString(pair.Value);
  41.             }
  42.         }
  43.  
  44.         public override string ToString()
  45.         {
  46.             StringBuilder builder = new StringBuilder();
  47.             foreach (KeyValuePair<string, string> pair in Data)
  48.             {
  49.                 builder.Append(Convert.ToChar(1));
  50.                 builder.Append(pair.Key);
  51.                 builder.Append(Convert.ToChar(1));
  52.                 builder.Append(pair.Value);
  53.             }
  54.  
  55.             return builder.Length > 0 ? builder.ToString().Substring(1) : "";
  56.         }
  57.  
  58.         public object GetData()
  59.         {
  60.             return Data;
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement