using System; using System.Collections.Generic; using System.Linq; using System.Text; using Chop.User; using System.Threading; using Chop.Game.Rooms.Games; namespace Chop.Game.User { public class RoomUser { //public Habbo mHabbo; public GameClient mClient; public int mDynamicID; public byte mX; public byte mY; public bool mIsWalking; public bool mCanWalk = true; public bool mStatusUpdated; public byte mWalkingX; public byte mWalkingY; public double mHeight; public byte mBodyRotation; public byte mHeadRotation; public bool[] mRoomEnterChecks = new bool[2]; public int mEnteringRoomID; public delegate void StatusDelegate(string pKey, bool pUpdateInRoom, int pSleepTime); public bool mHasRights; public bool mIsOwner; public Dictionary mStatuses; public RoomUser() { mStatuses = new Dictionary(); } //public virtual string ToFuseString() //{ // ResponseBuilder sResponse = new ResponseBuilder(); // sResponse.Append("i:"); // sResponse.AppendString(mDynamicID, 13); // sResponse.Append("n:"); // sResponse.AppendString(mClient.mHabbo.mName, 13); // sResponse.Append("f:"); // sResponse.AppendString(mClient.mHabbo.mFigure, 13); // sResponse.Append("l:"); // sResponse.AppendString(mX, ' '); // sResponse.AppendString(mY, ' '); // sResponse.AppendString(mHeight, 13); // sResponse.Append("s:"); // sResponse.AppendString(mClient.mHabbo.mGender, 13); // sResponse.Append("c:"); // sResponse.AppendString(mClient.mHabbo.mMotto, 13); // if (mClient.mHabbo.mCurrentBadge != null) // { // sResponse.Append("b:"); // sResponse.AppendString(mClient.mHabbo.mCurrentBadge.mID, 13); // } // if (mClient.mHabbo.mClient.mRoom.mShockwaveCasts.Contains("hh_people_pool")) // Room has pool figures loaded // if (mClient.mHabbo.mPoolFigure != "") // { // sResponse.Append("p:"); // sResponse.AppendString(mClient.mHabbo.mPoolFigure, 13); // } // //if (User._groupID > 0) // //{ // // sResponse.Append("g:"); // // sResponse.AppendString(User._groupID, 13); // // sResponse.Append("t:"); // // sResponse.AppendString(User._groupMemberRank, 13); // //} // return sResponse.ToString(); //} public string ToStatusString() { ResponseBuilder sBuilder = new ResponseBuilder(); sBuilder.AppendInt32(mDynamicID); sBuilder.AppendInt32(mX); sBuilder.AppendInt32(mY); sBuilder.AppendString(mHeight.ToString()); sBuilder.AppendInt32(mBodyRotation); sBuilder.AppendInt32(mHeadRotation); string statusString = ""; foreach (string sKey in mStatuses.Keys) { statusString += sKey; if (mStatuses[sKey].ToString() != "") statusString += " " + mStatuses[sKey]; statusString += '/'; } sBuilder.AppendString(statusString); return sBuilder.ToString(); } public void AddStatus(string pKey, object pValue, bool pUpdateInRoom) { // Remove existing if (mStatuses.ContainsKey(pKey)) mStatuses.Remove(pKey); mStatuses.Add(pKey, pValue); if (pUpdateInRoom) mStatusUpdated = true; } public void AddStatus(string pKey, object pValue, bool pUpdateInRoom, int pSleepTime) { // Remove existing if (mStatuses.ContainsKey(pKey)) mStatuses.Remove(pKey); mStatuses.Add(pKey, pValue); if (pUpdateInRoom) mStatusUpdated = true; if (pSleepTime > 0) new StatusDelegate(RemoveStatus).BeginInvoke(pKey, pUpdateInRoom, pSleepTime, null, null); } public void AddStatus(string pKey, bool pUpdateInRoom, int pSleepTime) { // Remove existing if (mStatuses.ContainsKey(pKey)) mStatuses.Remove(pKey); mStatuses.Add(pKey, ""); if (pUpdateInRoom) mStatusUpdated = true; if (pSleepTime > 0) new StatusDelegate(RemoveStatus).BeginInvoke(pKey, pUpdateInRoom, pSleepTime, null, null); } public void RemoveStatus(string pKey, bool pUpdateInRoom) { // Status exists if (mStatuses.ContainsKey(pKey)) mStatuses.Remove(pKey); if (pUpdateInRoom && mClient.mRoom != null) mStatusUpdated = true; } public void RemoveStatus(string pKey, bool pUpdateInRoom, int pSleepTime) { Thread.Sleep(pSleepTime); // Status exists if (mStatuses.ContainsKey(pKey)) mStatuses.Remove(pKey); if (pUpdateInRoom) mStatusUpdated = true; } public void Destroy() { mClient.mRoom.RemoveUser(this); } public void AddToMessage(ResponseBuilder message) { message.AppendInt32(mClient.mHabbo.mID); message.AppendString(mClient.mHabbo.mName); message.AppendString(mClient.mHabbo.mMotto); message.AppendString(mClient.mHabbo.mFigure); message.AppendInt32(mDynamicID); message.AppendInt32(mX); message.AppendInt32(mY); message.AppendString(mHeight.ToString()); // TODO: Specify string format message.AppendInt32(mBodyRotation); message.AppendInt32(1); // 1 = user, 2 = pet, 3 = bot message.AppendString(mClient.mHabbo.mGender.ToString()); message.AppendInt32(155); // xp message.AppendInt32(-1); // groupID message.AppendInt32(-1); // groupStatus message.AppendString(mClient.mRoom.mShockwaveCasts.Contains("hh_people_pool") ? mClient.mHabbo.mPoolFigure : ""); // probably swim figure message.AppendInt32(0); // achievementScore } } }