namespace Otaku.Managers { using Otaku; using Otaku.Virtual.Rooms; using System; using System.Collections; public static class roomManager { private static int _peakRoomCount; private static Hashtable _Rooms = new Hashtable(); public static void addRoom(int roomID, virtualRoom Room) { if (!_Rooms.ContainsKey(roomID)) { _Rooms.Add(roomID, Room); Out.WriteLine(string.Concat(new object[] { "Room [", roomID, ", publicroom: ", Room.isPublicroom.ToString().ToLower(), "] loaded." }), Out.logFlags.StandardAction); if (_Rooms.Count > _peakRoomCount) { _peakRoomCount = _Rooms.Count; } } } public static bool containsRoom(int roomID) { return _Rooms.ContainsKey(roomID); } public static virtualRoom getRoom(int roomID) { return (virtualRoom) _Rooms[roomID]; } public static string getRoomState(int State) { if (State == 1) { return "closed"; } if (State == 2) { return "password"; } return "open"; } public static int getRoomState(string State) { if (State == "closed") { return 1; } if (State == "password") { return 2; } return 0; } public static void refreshWallitem(int roomID, int itemID, string cctName, string wallPosition, string itemVariable) { getRoom(roomID).sendData(string.Concat(new object[] { "AU", itemID, Convert.ToChar(9), cctName, Convert.ToChar(9), " ", wallPosition, Convert.ToChar(9), itemVariable })); } public static void removeRoom(int roomID) { if (_Rooms.ContainsKey(roomID)) { bool isPublicroom = ((virtualRoom) _Rooms[roomID]).isPublicroom; _Rooms.Remove(roomID); updateRoomVisitorCount(roomID, 0); Out.WriteLine(string.Concat(new object[] { "Room [", roomID, ", publicroom: ", isPublicroom.ToString().ToLower(), "] destroyed." }), Out.logFlags.StandardAction); GC.Collect(); } } public static void updateRoomVisitorCount(int roomID, int visitorCount) { DB.runQuery(string.Concat(new object[] { "UPDATE rooms SET visitors_now = '", visitorCount, "' WHERE id = '", roomID, "' LIMIT 1" })); } public static int peakRoomCount { get { return _peakRoomCount; } } public static int roomCount { get { return _Rooms.Count; } } public static class moodlight { public static string getSettings(int roomID) { try { string[] strArray = DB.runReadRow("SELECT preset_cur,preset_1,preset_2,preset_3 FROM furniture_moodlight WHERE roomid = '" + roomID + "'"); string str = Encoding.encodeVL64(3) + Encoding.encodeVL64(int.Parse(strArray[0])); for (int i = 1; i <= 3; i++) { string[] strArray2 = strArray[i].Split(new char[] { char.Parse(",") }); object obj2 = str; str = string.Concat(new object[] { obj2, Encoding.encodeVL64(i), Encoding.encodeVL64(int.Parse(strArray2[0])), strArray2[1], Convert.ToChar(2), Encoding.encodeVL64(int.Parse(strArray2[2])) }); } return str; } catch { return null; } } public static void setSettings(int roomID, bool isEnabled, int presetID, int bgState, string presetColour, int alphaDarkF) { string str; int itemID = DB.runRead("SELECT id FROM furniture_moodlight WHERE roomid = '" + roomID + "'", null); if (!isEnabled) { string str2 = DB.runRead("SELECT var FROM furniture WHERE id = '" + itemID + "'"); if (str2.Substring(0, 1) == "2") { str = "1" + str2.Substring(1); } else { str = "2" + str2.Substring(1); } DB.runQuery("UPDATE furniture SET var = '" + str + "' WHERE id = '" + itemID.ToString() + "' LIMIT 1"); } else { str = "2," + presetID.ToString() + "," + bgState.ToString() + "," + presetColour + "," + alphaDarkF.ToString(); DB.runQuery("UPDATE furniture SET var = '" + str + "' WHERE id = '" + itemID.ToString() + "' LIMIT 1"); DB.runQuery("UPDATE furniture_moodlight SET preset_cur = '" + presetID.ToString() + "',preset_" + presetID.ToString() + "= '" + bgState.ToString() + "," + presetColour + "," + alphaDarkF.ToString() + "' WHERE id = '" + itemID.ToString() + "' LIMIT 1"); } string wallPosition = DB.runRead("SELECT wallpos FROM furniture WHERE id = '" + itemID + "'"); roomManager.refreshWallitem(roomID, itemID, "roomdimmer", wallPosition, str); } } } }