using System; using System.Collections.Generic; using System.Linq; using System.Text; using DuckEmulator.HabboHotel.Outside.Messages.Types; using DuckEmulator.HabboHotel.Outside.Rooms.Movement; namespace DuckEmulator.HabboHotel.Outside.Rooms { class RoomModel { internal readonly string Id; internal string RawMap; internal List Lines; internal int MaxX = new int(); internal int MaxY = new int(); internal int DoorX = new int(); internal int DoorY = new int(); internal int DoorZ = new int(); internal int DoorRot = new int(); internal RoomModel(string Id, string Map, int DoorX, int DoorY, int DoorZ, int DoorRot) { this.Id = Id; this.RawMap = Map; this.DoorX = DoorX; this.DoorY = DoorY; this.DoorZ = DoorZ; this.DoorRot = DoorRot; Setup(); } internal void Setup() { Lines = new List(); RawMap = RawMap.Replace(Convert.ToChar(10).ToString(), ""); RawMap.Split("\r\n".ToCharArray()).ToList().ForEach(Lines.Add); this.MaxX = Lines[0].Length; this.MaxY = Lines.Count; } internal void SerializeRe(ServerMessage Message) { for (int y = 0; y < MaxY; y++) { Message.AppendString(Lines[y]); Message.AppendString(Convert.ToChar(13).ToString()); } Message.AppendStringWithBreak(""); } internal void Serialize(ServerMessage Message) { for (int y = 0; y < MaxY; y++) { for (int x = 0; x < MaxX; x++) { string Square = Lines[y].Substring(x, 1).Trim().ToLower(); if (DoorX == x && DoorY == y) { Square = DoorZ.ToString(); } Message.AppendString(Square); } Message.AppendStringWithBreak("", 13); } Message.AppendStringWithBreak(""); } } }