using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MudEngine.Core;
namespace MudEngine.World
{
public class Room : BaseEnvironment
{
///
/// Gets or Sets the type of terrain that this room contains.
///
public TerrainTypes Terrain { get; set; }
///
/// Gets a reference to the collection of doorways present within this room
///
public List Doorways { get; private set; }
public Room(BaseGame game) : base(game)
{
Doorways = new List();
}
///
/// Installs a doorway into the room. Multiple doorways for the same travel direction is not allowed.
///
///
///
public bool InstallDoor(Door door)
{
//Anonymous method to check if a door already exists for the travel direction supplied.
Door dr = Doorways.Find(delegate(Door d)
{
return d.TravelDirection == door.TravelDirection;
}
);
if (dr != null)
return false;
Doorways.Add(door);
return true;
}
///
/// Removes a doorway from the room.
///
///
public void RemoveDoor(AvailableTravelDirections travelDirection)
{
Door dr = Doorways.Find(delegate(Door d)
{
return d.TravelDirection == travelDirection;
}
);
if (dr != null)
Doorways.Remove(dr);
}
///
/// Checks to see if a doorway exists for the supplied travel direction.
///
///
///
public bool DoorwayExists(AvailableTravelDirections travelDirection)
{
return Doorways.Exists(d => d.TravelDirection == travelDirection);
}
///
/// Returns a reference to an installed doorway, for the supplied travel direction.
///
///
///
public Door GetDoorway(AvailableTravelDirections travelDirection)
{
return Doorways.Find(d => d.TravelDirection == travelDirection);
}
}
}