MCPcopy Create free account
hub / github.com/SpartanJ/eepp / getObjectOver

Method getObjectOver

src/modules/maps/src/eepp/maps/mapobjectlayer.cpp:93–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93GameObject* 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
139MapObjectLayer::ObjList& MapObjectLayer::getObjectList() {
140 return mObjects;

Callers 1

selectPolyObjMethod · 0.80

Calls 7

rbeginMethod · 0.80
rendMethod · 0.80
isTypeMethod · 0.45
pointInsideMethod · 0.45
getPositionMethod · 0.45
getSizeMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected