namespace Butterfly.HabboHotel.Users.Messenger { using Butterfly; using Butterfly.HabboHotel.GameClients; using Butterfly.HabboHotel.Rooms; using Butterfly.Messages; using System; internal class MessengerBuddy { private GameClient client; private Room currentRoom; private readonly string mLastOnline; private readonly string mLook; private readonly string mMotto; private readonly string mUsername; private readonly uint UserId; internal MessengerBuddy(uint UserId, string pUsername, string pLook, string pMotto, string pLastOnline) { this.UserId = UserId; this.mUsername = pUsername; this.mLook = pLook; this.mMotto = pMotto; this.mLastOnline = pLastOnline; } internal void Serialize(ServerMessage reply) { reply.AppendInt32(this.UserId); reply.AppendString(this.mUsername); reply.AppendInt32(1); bool isOnline = this.IsOnline; reply.AppendBoolean(isOnline); if (isOnline) { reply.AppendBoolean(this.InRoom); } else { reply.AppendBoolean(false); } reply.AppendString(isOnline ? this.mLook : ""); reply.AppendInt32(0); reply.AppendString(this.mMotto); reply.AppendString(this.mLastOnline); reply.AppendString(string.Empty); reply.AppendBoolean(true); reply.AppendBoolean(true); reply.AppendBoolean(false); } internal void UpdateUser() { this.client = ButterflyEnvironment.GetGame().GetClientManager().GetClient(this.UserId); this.UpdateUser(this.client); } internal void UpdateUser(GameClient client) { this.client = client; if ((client != null) && (client.GetHabbo() != null)) { this.currentRoom = client.GetHabbo().CurrentRoom; } } private GameClient Client { get { return this.client; } set { this.client = value; } } internal Room CurrentRoom { get { return this.currentRoom; } set { this.currentRoom = value; } } internal uint Id { get { return this.UserId; } } internal bool InRoom { get { return (this.currentRoom != null); } } internal bool IsOnline { get { return ((((this.client != null) && (this.client.GetHabbo() != null)) && (this.client.GetHabbo().GetMessenger() != null)) && !this.client.GetHabbo().GetMessenger().AppearOffline); } } } }