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() { Response sResponse = new Response(); 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() { Response sBuilder = new Response(); sBuilder.AppendString(mDynamicID, ' '); sBuilder.AppendString(mX, ','); sBuilder.AppendString(mY, ','); sBuilder.AppendString(mHeight, ','); sBuilder.AppendString(mBodyRotation, ','); sBuilder.AppendString(mHeadRotation, '/'); foreach (string sKey in mStatuses.Keys) { sBuilder.Append(sKey); if (mStatuses[sKey].ToString() != "") sBuilder.Append(" " + mStatuses[sKey]); sBuilder.Append('/'); } 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); } } }