namespace Holo.Source.Managers { using Holo; using Holo.Virtual.Rooms; using Ion.Storage; using System; using System.Collections; using System.Data; using System.Threading; public static class modeldataManager { private static Hashtable ModeldataStorage; internal static void ChacheData(string _Model) { DataRow row; using (DatabaseClient client = Eucalypt.dbManager.GetClient()) { row = client.getRow("SELECT room_modeldata.modelID, room_modeldata.model, room_modeldata.roomomatic_subscr_only, room_modeldata.door_x, room_modeldata.door_y, room_modeldata.door_h, room_modeldata.door_z, room_modeldata.heightmap, room_modeldata.publicroom_items, room_modeldata.swimmingpool, room_modeldata.specialcast_emitter, room_modeldata.specialcast_interval, room_modeldata.specialcast_rnd_min, room_modeldata.specialcast_rnd_max FROM room_modeldata WHERE model = '" + _Model + "' LIMIT 1"); } ModeldataStructure structure = new ModeldataStructure { HeightMap = Convert.ToString(row["heightmap"]), PublicRoomItems = Convert.ToString(row["publicroom_items"]), DoorX = Convert.ToInt32(row["door_x"]), DoorY = Convert.ToInt32(row["door_y"]), DoorZ = Convert.ToByte(row["door_z"]), DoorH = Convert.ToInt32(row["door_h"]), RoomomaticSuscr = Convert.ToInt32(row["roomomatic_subscr_only"]), IsSwimmingpool = Convert.ToInt32(row["swimmingpool"]) == 1, SpecialcastEmitter = Convert.ToString(row["specialcast_emitter"]) }; if (Convert.ToString(row["specialcast_interval"]).Length > 0) { structure.SpecialcastInterval = Convert.ToInt32(row["specialcast_interval"]); } if (Convert.ToString(row["specialcast_rnd_max"]).Length > 0) { structure.SpecialcastRndMAX = Convert.ToInt32(row["specialcast_rnd_max"]); } if (Convert.ToString(row["specialcast_rnd_min"]).Length > 0) { structure.SpecialcastRndMIN = Convert.ToInt32(row["specialcast_rnd_min"]); } string[] strArray = structure.HeightMap.Split("\r".ToCharArray()); int length = strArray[0].Length; int num2 = strArray.Length - 1; structure.ModelsqSTATE = new virtualRoom.squareState[length, num2]; structure.ModelsqFLOORHEIGHT = new byte[length, num2]; for (int i = 0; i < num2; i++) { for (int j = 0; j < length; j++) { try { string s = strArray[i].Substring(j, 1).Trim().ToLower(); if (s == "x") { structure.ModelsqSTATE[j, i] = virtualRoom.squareState.Blocked; } else { structure.ModelsqSTATE[j, i] = virtualRoom.squareState.Open; try { structure.ModelsqFLOORHEIGHT[j, i] = byte.Parse(s); } catch { } } } catch { } } } ModeldataStorage.Add(_Model, structure); } public static int door_h(string _Model) { ModeldataStructure structure = (ModeldataStructure) ModeldataStorage[_Model]; return structure.DoorH; } public static int door_x(string _Model) { ModeldataStructure structure = (ModeldataStructure) ModeldataStorage[_Model]; return structure.DoorX; } public static int door_y(string _Model) { ModeldataStructure structure = (ModeldataStructure) ModeldataStorage[_Model]; return structure.DoorY; } public static byte door_z(string _Model) { ModeldataStructure structure = (ModeldataStructure) ModeldataStorage[_Model]; return structure.DoorZ; } public static byte[,] GetFloorgeight(string _Model) { ModeldataStructure structure = (ModeldataStructure) ModeldataStorage[_Model]; return structure.ModelsqFLOORHEIGHT; } public static virtualRoom.squareState[,] GetSQState(string _Model) { ModeldataStructure structure = (ModeldataStructure) ModeldataStorage[_Model]; virtualRoom.squareState[,] modelsqSTATE = structure.ModelsqSTATE; virtualRoom.squareState[,] destinationArray = new virtualRoom.squareState[modelsqSTATE.GetLength(0), modelsqSTATE.GetLength(1)]; Array.Copy(modelsqSTATE, destinationArray, (int) (modelsqSTATE.GetLength(0) * modelsqSTATE.GetLength(1))); return destinationArray; } public static ModeldataStructure GetStructureInstance(string RoomModel) { return (ModeldataStructure) ModeldataStorage[RoomModel]; } public static string Heightmap(string _Model) { ModeldataStructure structure = (ModeldataStructure) ModeldataStorage[_Model]; return structure.HeightMap; } internal static void Init(bool Update) { DataColumn column; Out.WriteLine("Starting caching of room_modeldata..."); using (DatabaseClient client = Eucalypt.dbManager.GetClient()) { column = client.getColumn("SELECT model FROM room_modeldata ORDER BY modelID"); } ModeldataStorage = new Hashtable(); foreach (DataRow row in column.Table.Rows) { ChacheData(row["model"].ToString()); } Out.WriteLine("Modeldata cached"); if (Update) { Thread.CurrentThread.Abort(); } } public static string publicroom_items(string _Model) { ModeldataStructure structure = (ModeldataStructure) ModeldataStorage[_Model]; return structure.PublicRoomItems; } public static int roomomatic_suscr(string _Model) { ModeldataStructure structure = (ModeldataStructure) ModeldataStorage[_Model]; return structure.RoomomaticSuscr; } public static string specialcast_emitter(string _Model) { ModeldataStructure structure = (ModeldataStructure) ModeldataStorage[_Model]; return structure.SpecialcastEmitter; } public static int specialcast_interval(string _Model) { ModeldataStructure structure = (ModeldataStructure) ModeldataStorage[_Model]; return structure.SpecialcastInterval; } public static int specialcast_rnd_max(string _Model) { ModeldataStructure structure = (ModeldataStructure) ModeldataStorage[_Model]; return structure.SpecialcastRndMAX; } public static int specialcast_rnd_min(string _Model) { ModeldataStructure structure = (ModeldataStructure) ModeldataStorage[_Model]; return structure.SpecialcastRndMIN; } public static bool swimmingpool(string _Model) { ModeldataStructure structure = (ModeldataStructure) ModeldataStorage[_Model]; return structure.IsSwimmingpool; } } }