Ejemplo n.º 1
0
        public string GetEmail(IRoomData item)
        {
            var ca = Session
                     .Query <ClientAccountInfo>()
                     .First(x => x.ClientID == item.ClientID && x.AccountID == item.AccountID);

            return(ca.Email);
        }
Ejemplo n.º 2
0
        internal Room(IRoomData roomData, IRoomModel model)
        {
            RoomData  = roomData;
            RoomModel = model;

            _cancellationToken = new CancellationTokenSource();
            RoomGrid           = new RoomGrid(RoomModel);
            _entityHandler     = new EntityHandler(this);
        }
Ejemplo n.º 3
0
        public static void InitData()
        {
            leaguesData = new LeaguesByDB();
            playersData = new PlayersByDB();
            roomsData   = new RoomsByDB();
            Service service = new Service(leaguesData, roomsData, playersData);

            Log.InfoLog("Service Layer initiated");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Fills a data object with data from a data row
        /// </summary>
        /// <param name="dr">the data row to fill from</param>
        public override void Fill(DataRow dr)
        {
            ID          = DataUtility.GetFromDataRow <long>(dr, "ID");
            Created     = DataUtility.GetFromDataRow <DateTime>(dr, "Created");
            LastRevised = DataUtility.GetFromDataRow <DateTime>(dr, "LastRevised");
            Name        = DataUtility.GetFromDataRow <string>(dr, "Name");

            var armsId     = DataUtility.GetFromDataRow <long>(dr, "ArmsId");
            var armsAmount = DataUtility.GetFromDataRow <short>(dr, "ArmsAmount");

            Arms = new Tuple <IInanimateData, short>(DataWrapper.GetOne <InanimateData>(armsId), armsAmount);

            var LegsId     = DataUtility.GetFromDataRow <long>(dr, "LegsId");
            var LegsAmount = DataUtility.GetFromDataRow <short>(dr, "LegsAmount");

            Legs = new Tuple <IInanimateData, short>(DataWrapper.GetOne <InanimateData>(LegsId), LegsAmount);

            var torsoId = DataUtility.GetFromDataRow <long>(dr, "Torso");

            Torso = DataWrapper.GetOne <InanimateData>(torsoId);

            var headId = DataUtility.GetFromDataRow <long>(dr, "Head");

            Head = DataWrapper.GetOne <InanimateData>(headId);

            var bodyPartJson = DataUtility.GetFromDataRow <string>(dr, "BodyParts");

            BodyParts = DeserializeBodyParts(bodyPartJson);

            DietaryNeeds = (DietType)DataUtility.GetFromDataRow <short>(dr, "DietaryNeeds");

            var bloodId = DataUtility.GetFromDataRow <long>(dr, "SanguinaryMaterial");

            SanguinaryMaterial = ReferenceWrapper.GetOne <Material>(bloodId);

            var visionLow  = DataUtility.GetFromDataRow <short>(dr, "VisionRangeLow");
            var visionHigh = DataUtility.GetFromDataRow <short>(dr, "VisionRangeHigh");

            VisionRange = new Tuple <short, short>(visionLow, visionHigh);

            var tempLow  = DataUtility.GetFromDataRow <short>(dr, "TemperatureToleranceLow");
            var tempHigh = DataUtility.GetFromDataRow <short>(dr, "TemperatureToleranceHigh");

            TemperatureTolerance = new Tuple <short, short>(tempLow, tempHigh);

            Breathes = (RespiratoryType)DataUtility.GetFromDataRow <short>(dr, "Breathes");

            TeethType = (DamageType)DataUtility.GetFromDataRow <short>(dr, "TeethType");

            var startRoomId = DataUtility.GetFromDataRow <long>(dr, "StartingLocation");

            StartingLocation = DataWrapper.GetOne <RoomData>(startRoomId);

            var recallRoomId = DataUtility.GetFromDataRow <long>(dr, "EmergencyLocation");

            EmergencyLocation = DataWrapper.GetOne <RoomData>(recallRoomId);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// News up an entity with its backing data
        /// </summary>
        /// <param name="room">the backing data</param>
        public Room(IRoomData room)
        {
            ObjectsInRoom = new EntityContainer <IInanimate>();
            MobilesInside = new EntityContainer <IMobile>();
            Pathways      = new EntityContainer <IPathway>();

            DataTemplate = room;

            GetFromWorldOrSpawn();
        }
Ejemplo n.º 6
0
        public Service(ILeaguesData leaguesData, IRoomData roomsData, IPlayersData playersData)
        {
            this.LeaguesData = leaguesData;
            this.roomsData   = roomsData;
            this.playersData = playersData;

            this.userService   = new UserService(this);
            this.centerService = new CenterService(this);
            this.gameService   = new GameService(this);
            Service.instance   = this;
        }
Ejemplo n.º 7
0
        public bool UpdateRoomData(string serverId, IRoomData roomData)
        {
            lock (_roomDatas)
            {
                //Check if gameServer exists
                if (_roomDatas.ContainsKey(serverId))
                {
                    //Update information about the room
                    var room = _roomDatas[serverId].Single(r => r.RoomID == roomData.RoomID);
                    room.CurrentUsers = roomData.CurrentUsers;
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 8
0
        internal async Task <IRoomData> GetRoomData(int id)
        {
            IRoomData roomData = null;

            await CreateTransaction(async transaction =>
            {
                await Select(transaction, async reader =>
                {
                    if (await reader.ReadAsync())
                    {
                        roomData = new RoomData(reader);
                    }
                }, "SELECT id, score, owner, name, password, model_name FROM rooms WHERE id = @0 LIMIT 1", id);
            });

            return(roomData);
        }
Ejemplo n.º 9
0
        public void AddRoomData(string serverId, IRoomData roomData)
        {
            lock (_roomDatas)
            {
                //Check if gameServer does not exists
                if (!_roomDatas.ContainsKey(serverId))
                {
                    _roomDatas[serverId] = new List <IRoomData> {
                        roomData
                    };
                }

                //Check if room already exists
                if (!_roomDatas[serverId].Contains(roomData))
                {
                    _roomDatas[serverId].Add(roomData);
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// insert this into the db
        /// </summary>
        /// <returns>the object with ID and other db fields set</returns>
        public override IData Create()
        {
            var parms = new Dictionary <string, object>();

            IRoomData returnValue = default(IRoomData);
            var       sql         = new StringBuilder();

            sql.Append("insert into [dbo].[RoomData]([Name], [DimensionalModelLength], [DimensionalModelHeight], [DimensionalModelWidth], [Medium], [Borders], [Zone])");
            sql.Append(" values(@Name,@DimensionalModelLength,@DimensionalModelHeight,@DimensionalModelWidth,@Medium,@Borders,@Zone)");
            sql.Append(" select * from [dbo].[RoomData] where ID = Scope_Identity()");

            parms.Add("Name", Name);
            parms.Add("DimensionalModelLength", Model.Length);
            parms.Add("DimensionalModelHeight", Model.Height);
            parms.Add("DimensionalModelWidth", Model.Width);
            parms.Add("Medium", Medium.ID);
            parms.Add("Borders", SerializeBorders());
            parms.Add("Zone", ZoneAffiliation.ID);

            try
            {
                var ds = SqlWrapper.RunDataset(sql.ToString(), CommandType.Text, parms);

                if (ds.Rows != null)
                {
                    foreach (DataRow dr in ds.Rows)
                    {
                        Fill(dr);
                        returnValue = this;
                    }
                }
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
            }

            return(returnValue);
        }
Ejemplo n.º 11
0
        internal async Task <IRoom> GetRoomByIdAsync(int id)
        {
            //There's already a cached version of this room.
            if (_rooms.TryGetValue(id, out IRoom room))
            {
                return(room);
            }

            //Initialize the new room & cache it.
            IRoomData roomData = await _roomDao.GetRoomData(id);

            if (roomData != null)
            {
                if (_roomModels.TryGetValue(roomData.ModelName, out IRoomModel model))
                {
                    //TODO: Error if the room model doesn't exist.
                    room = new Room(roomData, model);
                    _rooms.Add(id, room);
                    return(room);
                }
            }

            return(null);
        }
Ejemplo n.º 12
0
 public HomeController(IRoomData roomData)
 {
     this.roomData = roomData;
 }
 public RoomController(IRoomData data)
 {
     _data = data;
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Renders a map from a single z,y plane
        /// </summary>
        /// <param name="map">The map to render</param>
        /// <param name="forAdmin">is this for admin (with edit links)</param>
        /// <param name="withPathways">include pathway symbols</param>
        /// <param name="centerRoom">the room considered "center"</param>
        /// <returns>the rendered map</returns>
        public static string RenderMap(long[,] map, bool forAdmin, bool withPathways, IRoomData centerRoom)
        {
            var sb = new StringBuilder();

            if (!withPathways)
            {
                int x, y;
                for (y = map.GetUpperBound(1); y >= 0; y--)
                {
                    var rowString = String.Empty;
                    for (x = 0; x < map.GetUpperBound(0); x++)
                    {
                        var roomData = BackingDataCache.Get<IRoomData>(map[x, y]);

                        if (roomData != null)
                            rowString += RenderRoomToAscii(roomData, centerRoom.Equals(roomData), forAdmin);
                        else
                            rowString += "&nbsp;";
                    }

                    sb.AppendLine(rowString);
                }
            }
            else
            {
                var expandedMap = new string[(map.GetUpperBound(0) + 1) * 3 + 1, (map.GetUpperBound(1) + 1) * 3 + 1];

                int x, y;
                for (y = map.GetUpperBound(1); y >= 0; y--)
                {
                    for (x = 0; x <= map.GetUpperBound(0); x++)
                    {
                        var roomData = BackingDataCache.Get<IRoomData>(map[x, y]);

                        if (roomData != null)
                        {
                            var pathways = roomData.GetPathways();
                            var ePath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.East);
                            var nPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.North);
                            var nePath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.NorthEast);
                            var nwPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.NorthWest);
                            var sPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.South);
                            var sePath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.SouthEast);
                            var swPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.SouthWest);
                            var wPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.West);

                            var expandedRoomX = x * 3 + 1;
                            var expandedRoomY = y * 3 + 1;

                            //The room
                            expandedMap[expandedRoomX, expandedRoomY] = RenderRoomToAscii(roomData, centerRoom.Equals(roomData), forAdmin);

                            expandedMap[expandedRoomX - 1, expandedRoomY + 1] = RenderPathwayToAsciiForModals(nwPath, roomData.ID, MovementDirectionType.NorthWest
                                                                                                , Cartographer.GetRoomInDirection(roomData, MovementDirectionType.NorthWest), forAdmin);
                            expandedMap[expandedRoomX, expandedRoomY + 1] = RenderPathwayToAsciiForModals(nPath, roomData.ID, MovementDirectionType.North
                                                                                                , Cartographer.GetRoomInDirection(roomData, MovementDirectionType.North), forAdmin);
                            expandedMap[expandedRoomX + 1, expandedRoomY + 1] = RenderPathwayToAsciiForModals(nePath, roomData.ID, MovementDirectionType.NorthEast
                                                                                                , Cartographer.GetRoomInDirection(roomData, MovementDirectionType.NorthEast), forAdmin);
                            expandedMap[expandedRoomX - 1, expandedRoomY] = RenderPathwayToAsciiForModals(wPath, roomData.ID, MovementDirectionType.West
                                                                                                , Cartographer.GetRoomInDirection(roomData, MovementDirectionType.West), forAdmin);
                            expandedMap[expandedRoomX + 1, expandedRoomY] = RenderPathwayToAsciiForModals(ePath, roomData.ID, MovementDirectionType.East
                                                                                                , Cartographer.GetRoomInDirection(roomData, MovementDirectionType.East), forAdmin);
                            expandedMap[expandedRoomX - 1, expandedRoomY - 1] = RenderPathwayToAsciiForModals(swPath, roomData.ID, MovementDirectionType.SouthWest
                                                                                                , Cartographer.GetRoomInDirection(roomData, MovementDirectionType.SouthWest), forAdmin);
                            expandedMap[expandedRoomX, expandedRoomY - 1] = RenderPathwayToAsciiForModals(sPath, roomData.ID, MovementDirectionType.South
                                                                                                , Cartographer.GetRoomInDirection(roomData, MovementDirectionType.South), forAdmin);
                            expandedMap[expandedRoomX + 1, expandedRoomY - 1] = RenderPathwayToAsciiForModals(sePath, roomData.ID, MovementDirectionType.SouthEast
                                                                                                , Cartographer.GetRoomInDirection(roomData, MovementDirectionType.SouthEast), forAdmin);
                        }
                    }
                }

                for (y = expandedMap.GetUpperBound(1); y >= 0; y--)
                {
                    var rowString = String.Empty;
                    for (x = 0; x <= expandedMap.GetUpperBound(0); x++)
                        rowString += expandedMap[x, y];

                    sb.AppendLine(rowString);
                }
            }

            return sb.ToString();
        }
Ejemplo n.º 15
0
        private static string RenderRoomToAscii(IRoomData destination, bool centered, bool forAdmin = false)
        {
            var character = centered ? "0" : "*";

            if (forAdmin)
                return String.Format("<a href='#' class='editData AdminEditRoom' roomId='{0}' title='Edit - {2}'>{1}</a>", destination.ID, character, destination.Name);
            else
                return character;
        }
Ejemplo n.º 16
0
        private static string RenderPathwayToAsciiForModals(IPathwayData path, long originId, MovementDirectionType directionType, IRoomData destination, bool forAdmin = false)
        {
            var returnValue = String.Empty;
            var asciiCharacter = Utilities.TranslateDirectionToAsciiCharacter(directionType);

            if (!forAdmin)
                return "&nbsp;";

            if (path != null)
                destination = BackingDataCache.Get<IRoomData>(int.Parse(path.ToLocationID));

            long destinationId = -1;
            var destinationName = String.Empty;
            if (destination != null)
            {
                destinationName = destination.Name;
                destinationId = destination.ID;
            }

            if (path != null)
            {
                returnValue = String.Format("<a href='#' class='editData pathway AdminEditPathway' pathwayId='{0}' fromRoom='{3}' toRoom='{4}' title='Edit - {5} path to {1}' data-id='{0}'>{2}</a>",
                    path.ID, destinationName, asciiCharacter, originId, destinationId, directionType.ToString());
            }
            else
            {
                var roomString = String.Format("Add - {0} path and room", directionType.ToString());

                if (!string.IsNullOrWhiteSpace(destinationName))
                    roomString = String.Format("Add {0} path to {1}", directionType.ToString(), destinationName);

                returnValue = String.Format("<a href='#' class='addData pathway AdminAddPathway' pathwayId='-1' fromRoom='{0}' toRoom='{3}' data-direction='{1}' title='{2}'>+</a>",
                    originId, Utilities.TranslateDirectionToDegrees(directionType), roomString, destinationId);
            }

            return returnValue;
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Gets the remaining distance to the destination room
 /// </summary>
 /// <param name="destination">The room you're heading for</param>
 /// <returns>distance (in rooms) between here and there</returns>
 public int GetDistanceToRoom(IRoomData destination)
 {
     return -1;
 }
Ejemplo n.º 18
0
 public string GetEmail(IRoomData item)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 19
0
        //It's just easier to pass the ints we already calculated along instead of doing the math every single time, this cascades each direction fully because it calls itself for existant rooms
        private static long[, ,] AddFullRoomToMap(long[, ,] dataMap, IRoomData origin, int diameter, int centerX, int centerY, int centerZ, HashSet<IRoomData> roomPool)
        {
            if (roomPool != null && roomPool.Count > 0 && roomPool.Contains(origin))
                roomPool.Remove(origin);

            //Render the room itself
            dataMap[centerX - 1, centerY - 1, centerZ - 1] = origin.ID;
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.North, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.NorthEast, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.NorthWest, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.East, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.West, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.South, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.SouthEast, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.SouthWest, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.Up, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.UpNorth, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.UpNorthEast, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.UpNorthWest, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.UpEast, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.UpWest, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.UpSouth, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.UpSouthEast, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.UpSouthWest, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.Down, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.DownNorth, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.DownNorthEast, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.DownNorthWest, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.DownEast, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.DownWest, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.DownSouth, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.DownSouthEast, origin, diameter, centerX, centerY, centerZ, roomPool);
            dataMap = AddDirectionToMap(dataMap, MovementDirectionType.DownSouthWest, origin, diameter, centerX, centerY, centerZ, roomPool);

            return dataMap;
        }
Ejemplo n.º 20
0
 public RoomDataEventArgs(IRoomData data)
 {
     Data = data;
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Generate a room map starting in a room backing data with a radius around it
        /// </summary>
        /// <param name="room">the starting room</param>
        /// <param name="radius">the radius of rooms to go out to. -1 means "generate the entire world"</param>
        /// <param name="recenter">find the center node of the array and return an array with that node at absolute center</param>
        /// <returns>a 3d array of rooms</returns>
        public static long[, ,] GenerateMapFromRoom(IRoomData room, int radius, HashSet<IRoomData> roomPool, bool shrink = false)
        {
            if (room == null || radius < 0)
                throw new InvalidOperationException("Invalid inputs.");

            var diameter = radius * 2;
            var center = radius;

            //+1 for center room
            diameter++;
            center++;

            var returnMap = new long[diameter, diameter, diameter];

            //The origin room
            returnMap = AddFullRoomToMap(returnMap, room, diameter, center, center, center, roomPool);

            if (shrink)
                returnMap = ShrinkMap(returnMap);

            return returnMap;
        }
Ejemplo n.º 22
0
 public BusinessLogic(IRoomData roomData, ICustomerData customerData, IReservationData reservationData)
 {
     this.roomData        = roomData;
     this.customerData    = customerData;
     this.reservationData = reservationData;
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Gets the opposite room from the origin based on direction
        /// </summary>
        /// <param name="origin">The room we're looking to oppose</param>
        /// <param name="direction">The direction the room would be in (this method will reverse the direction itself)</param>
        /// <returns>The room that is in the direction from our room</returns>
        public static IRoomData GetOpposingRoom(IRoomData origin, MovementDirectionType direction)
        {
            //There is no opposite of none directionals
            if (origin == null || direction == MovementDirectionType.None)
                return null;

            var oppositeDirection = ReverseDirection(direction);

            var paths = BackingDataCache.GetAll<IPathwayData>();

            var ourPath = paths.FirstOrDefault(pt => pt.ToLocationType == "Room"
                                            && origin.ID.Equals(int.Parse(pt.ToLocationID))
                                            && pt.DirectionType == oppositeDirection);

            if(ourPath != null)
                return BackingDataCache.Get<IRoomData>(long.Parse(ourPath.ToLocationID));

            return null;
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Gets a room in a direction if there is one based on the world map the room belongs to
        /// </summary>
        /// <param name="origin">The room we're starting in</param>
        /// <param name="direction">The direction we're moving in</param>
        /// <returns>null or a RoomData</returns>
        public static IRoomData GetRoomInDirection(IRoomData origin, MovementDirectionType direction)
        {
            //We can't find none directions on a map
            if (origin == null || direction == MovementDirectionType.None)
                return null;

            var worldMap = origin.ZoneAffiliation.World.WorldMap.CoordinatePlane;

            var steps = Utilities.GetDirectionStep(direction);
            var newX = origin.Coordinates.Item1 + steps.Item1;
            var newY = origin.Coordinates.Item2 + steps.Item2;
            var newZ = origin.Coordinates.Item3 + steps.Item3;

            //out of bounds
            if (Utilities.IsOutOfBounds(new Tuple<int,int,int>(newX, newY, newZ), worldMap))
                return null;

            if (worldMap[newX, newY, newZ] > -1)
                return BackingDataCache.Get<IRoomData>(worldMap[newX, newY, newZ]);

            return null;
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Render an ascii map of stored data rooms around a specific radius
        /// </summary>
        /// <param name="room">the room to render the radius around</param>
        /// <param name="radius">the radius around the room to render</param>
        /// <param name="forAdmin">include edit links for paths and rooms?</param>
        /// <param name="withPathways">include paths at all?</param>
        /// <returns>a single string that is an ascii map</returns>
        public static string RenderRadiusMap(IRoomData room, int radius, bool forAdmin = true, bool withPathways = true)
        {
            var asciiMap = new StringBuilder();

            //1. Get world map
            var ourWorld = room.ZoneAffiliation.World;

            //2. Get slice of room from world map
            var map = Cartographer.TakeSliceOfMap(new Tuple<int, int>(Math.Max(room.Coordinates.Item1 - radius, 0), room.Coordinates.Item1 + radius)
                                                , new Tuple<int, int>(Math.Max(room.Coordinates.Item2 - radius, 0), room.Coordinates.Item2 + radius)
                                                , new Tuple<int, int>(Math.Max(room.Coordinates.Item3 - 1, 0), room.Coordinates.Item3 + 1)
                                                , ourWorld.WorldMap.CoordinatePlane, true);

            //3. Flatten the map
            var flattenedMap = Cartographer.GetSinglePlane(map, room.Coordinates.Item3);

            //4. Render slice of room
            return RenderMap(flattenedMap, forAdmin, withPathways, room);
        }
Ejemplo n.º 26
0
 public RoomsController(IRoomData roomData)
 {
     this.roomData = roomData;
 }
Ejemplo n.º 27
0
        //We have to render our pathway out, an empty space for the potential pathway back and the destination room
        private static long[, ,] AddDirectionToMap(long[, ,] dataMap, MovementDirectionType transversalDirection, IRoomData origin, int diameter, int centerX, int centerY, int centerZ, HashSet<IRoomData> roomPool)
        {
            var pathways = origin.GetPathways(true);
            var directionalSteps = Utilities.GetDirectionStep(transversalDirection);

            var xStepped = centerX + directionalSteps.Item1;
            var yStepped = centerY + directionalSteps.Item2;
            var zStepped = centerZ + directionalSteps.Item3;

            //If we're not over diameter budget and there is nothing there already (we might have already rendered the path and room) then render it
            //When the next room tries to render backwards it'll run into the existant path it came from and stop the chain here
            if (xStepped < diameter && xStepped > 0
                && yStepped > 0 && yStepped < diameter
                && zStepped > 0 && zStepped < diameter
                && dataMap[xStepped - 1, yStepped - 1, zStepped - 1] <= 0)
            {
                var thisPath = pathways.FirstOrDefault(path =>
                                                        (path.DirectionType == transversalDirection && path.FromLocationID.Equals(origin.ID.ToString()))
                                                        || (path.DirectionType == Utilities.ReverseDirection(transversalDirection) && path.ToLocationID.Equals(origin.ID.ToString()))
                                                        );
                if (thisPath != null)
                {
                    var locId = long.Parse(thisPath.ToLocationID);
                    if (thisPath.ToLocationID.Equals(origin.ID.ToString()))
                        locId = long.Parse(thisPath.FromLocationID);

                    var passdownOrigin = BackingDataCache.Get<IRoomData>(locId);

                    if (passdownOrigin != null)
                    {
                        dataMap[xStepped - 1, yStepped - 1, zStepped - 1] = passdownOrigin.ID;
                        dataMap = AddFullRoomToMap(dataMap, passdownOrigin, diameter, xStepped, yStepped, zStepped, roomPool);
                    }
                }
            }

            return dataMap;
        }