From fde86e47925e1b51fa7922041f28def3bef3ed0f Mon Sep 17 00:00:00 2001 From: Budoray_cp Date: Tue, 13 Sep 2011 19:52:17 -0700 Subject: [PATCH] A little Lamda to reduce code a bit. --- MudEngine/GameObjects/Environment/Room.cs | 26 ++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/MudEngine/GameObjects/Environment/Room.cs b/MudEngine/GameObjects/Environment/Room.cs index d65939e..f46d460 100644 --- a/MudEngine/GameObjects/Environment/Room.cs +++ b/MudEngine/GameObjects/Environment/Room.cs @@ -160,13 +160,14 @@ namespace MudEngine.GameObjects.Environment /// public Boolean DoorwayExist(AvailableTravelDirections travelDirection) { - foreach (Door door in Doorways) - { - if (door.TravelDirection == travelDirection) - return true; - } + return Doorways.Exists(d => d.TravelDirection == travelDirection); + //foreach (Door door in Doorways) + //{ + // if (door.TravelDirection == travelDirection) + // return true; + //} - return false; + //return false; } /// @@ -176,12 +177,13 @@ namespace MudEngine.GameObjects.Environment /// public Door GetDoor(AvailableTravelDirections travelDirection) { - foreach (Door door in this.Doorways) - { - if (door.TravelDirection == travelDirection) - return door; - } - return null; + return Doorways.First(d => d.TravelDirection == travelDirection); + //foreach (Door door in this.Doorways) + //{ + // if (door.TravelDirection == travelDirection) + // return door; + //} + //return null; } } }