| 91 | } |
| 92 | |
| 93 | GameObject* MapObjectLayer::getObjectOver( const Vector2i& pos, SEARCH_TYPE type ) { |
| 94 | GameObject* tObj; |
| 95 | Vector2f tPos; |
| 96 | Sizei tSize; |
| 97 | |
| 98 | for ( ObjList::reverse_iterator it = mObjects.rbegin(); it != mObjects.rend(); ++it ) { |
| 99 | tObj = ( *it ); |
| 100 | |
| 101 | if ( type & SEARCH_POLY ) { |
| 102 | if ( tObj->isType( GAMEOBJECT_TYPE_OBJECT ) ) { |
| 103 | GameObjectObject* tObjObj = reinterpret_cast<GameObjectObject*>( tObj ); |
| 104 | |
| 105 | if ( tObjObj->pointInside( Vector2f( pos.x, pos.y ) ) ) |
| 106 | return tObj; |
| 107 | } |
| 108 | } else if ( type & SEARCH_OBJECT ) { |
| 109 | if ( !tObj->isType( GAMEOBJECT_TYPE_OBJECT ) ) { |
| 110 | tPos = tObj->getPosition(); |
| 111 | tSize = tObj->getSize(); |
| 112 | |
| 113 | Rect objR( tPos.x, tPos.y, tPos.x + tSize.x, tPos.y + tSize.y ); |
| 114 | |
| 115 | if ( objR.contains( pos ) ) |
| 116 | return tObj; |
| 117 | } |
| 118 | } else { |
| 119 | if ( tObj->isType( GAMEOBJECT_TYPE_OBJECT ) ) { |
| 120 | GameObjectObject* tObjObj = reinterpret_cast<GameObjectObject*>( tObj ); |
| 121 | |
| 122 | if ( tObjObj->pointInside( Vector2f( pos.x, pos.y ) ) ) |
| 123 | return tObj; |
| 124 | } else { |
| 125 | tPos = tObj->getPosition(); |
| 126 | tSize = tObj->getSize(); |
| 127 | |
| 128 | Rect objR( tPos.x, tPos.y, tPos.x + tSize.x, tPos.y + tSize.y ); |
| 129 | |
| 130 | if ( objR.contains( pos ) ) |
| 131 | return tObj; |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | return NULL; |
| 137 | } |
| 138 | |
| 139 | MapObjectLayer::ObjList& MapObjectLayer::getObjectList() { |
| 140 | return mObjects; |
no test coverage detected