public static DynamicElement GetDynamicElementAround( Scenario scenario, Point charPos, MapElements type, Func <Scenario, Point, DynamicElement> GetElem ) { var obj = GetElem(scenario, DirUtils.GetNorthFromPos(charPos)); if (obj != null && obj.Type == type) { return(obj); } obj = GetElem(scenario, DirUtils.GetEastFromPos(charPos)); if (obj != null && obj.Type == type) { return(obj); } obj = GetElem(scenario, DirUtils.GetSouthFromPos(charPos)); if (obj != null && obj.Type == type) { return(obj); } obj = GetElem(scenario, DirUtils.GetWestFromPos(charPos)); if (obj != null && obj.Type == type) { return(obj); } return(null); }