using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; namespace Chop.Game.Rooms { public class RoomTemplate { public string ModelName; public bool HC_only; public byte Door_x; public byte Door_y; public double Door_h; public byte Door_z; public string Heightmap; public string Publicroom_items; public bool Swimmingpool; public string Specialcast_emitter; public uint Specialcast_interval; public uint Specialcast_rnd_min; public uint Specialcast_rnd_max; public byte[,] mDynamicHeightmap; public float[,] mDynamicHeight; public SquareState[,] mSquares; public static RoomTemplate Parse(DataRow row) { RoomTemplate template = new RoomTemplate(); template.ModelName = row["model"].ToString(); template.HC_only = row["roomomatic_subscr_only"].ToString() == "1"; template.Door_x = Convert.ToByte(row["door_x"]); template.Door_y = Convert.ToByte(row["door_y"]); template.Door_h = Convert.ToDouble(row["door_h"]); template.Door_z = Convert.ToByte(row["door_z"]); template.Heightmap = row["heightmap"].ToString(); template.Publicroom_items = row["publicroom_items"].ToString(); template.Swimmingpool = row["swimmingpool"].ToString() == "1"; template.Specialcast_emitter = row["specialcast_emitter"].ToString(); template.Specialcast_interval = Convert.ToUInt32(row["specialcast_interval"]); template.Specialcast_rnd_min = Convert.ToUInt32(row["specialcast_rnd_min"]); template.Specialcast_rnd_max = Convert.ToUInt32(row["specialcast_rnd_max"]); string[] sTempHeightmap = template.Heightmap.Split(Convert.ToChar(13)); int sLengthX = sTempHeightmap[0].Length; int sLengthY = sTempHeightmap.Length - 1; template.mDynamicHeightmap = new byte[sLengthX, sLengthY]; template.mDynamicHeight = new float[sLengthX, sLengthY]; template.mSquares = new SquareState[sLengthX, sLengthY]; for (int x = 0; x < sLengthX; x++) for (int y = 0; y < sLengthY; y++) if (sTempHeightmap[y] != "") { char c = sTempHeightmap[y][x]; if (c != 'x') { template.mDynamicHeightmap[x, y] = 1; template.mSquares[x, y] = SquareState.Open; if (char.IsNumber(c)) template.mDynamicHeight[x, y] = int.Parse(c.ToString()); } else { template.mDynamicHeightmap[x, y] = 0; template.mSquares[x, y] = SquareState.Closed; } } if (template.Publicroom_items != "") { string[] sItems = template.Publicroom_items.Split('\n'); template.Publicroom_items = ""; for (int i = 0; i < sItems.Length; i++) { string[] sData = sItems[i].Split(' '); int sX = Convert.ToInt32(sData[2]); int sY = Convert.ToInt32(sData[3]); template.mDynamicHeightmap[sX, sY] = 0; template.mSquares[sX, sY] = SquareState.Closed; template.mDynamicHeight[sX, sY] = 1.0F; template.Publicroom_items += sData[0] + " " + sData[1] + " " + sData[2] + " " + sData[3] + " " + sData[4] + " " + sData[5] + Convert.ToChar(13); } } return template; } } }