diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index 00e026cfa..770915b36 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -50,7 +50,7 @@ s32 CNpc::playerXDist; s32 CNpc::playerYDist; s32 CNpc::playerXDistSqr; s32 CNpc::playerYDistSqr; - +class CLayerCollision *CNpc::m_layerCollision; void CNpc::init() { @@ -72,6 +72,8 @@ void CNpc::init() m_controlFunc = NPC_CONTROL_MOVEMENT; + m_layerCollision = NULL; + switch ( m_data[this->m_type].initFunc ) { case NPC_INIT_DEFAULT: diff --git a/source/enemy/npc.h b/source/enemy/npc.h index b85820685..6f8b2c9c8 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -81,6 +81,7 @@ public: void think(int _frames); virtual void render(); void processEvent( GAME_EVENT evt, CThing *sourceThing ); + void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;} protected: @@ -363,6 +364,8 @@ protected: static s32 playerXDistSqr; static s32 playerYDistSqr; + static class CLayerCollision *m_layerCollision; + // internal variables NPC_UNIT_TYPE m_type; diff --git a/source/game/game.cpp b/source/game/game.cpp index ef4e956bf..a4c7c07ef 100644 --- a/source/game/game.cpp +++ b/source/game/game.cpp @@ -96,6 +96,7 @@ void CGameScene::init() C2dEnemy *enemy; enemy=new ("test enemy") C2dEnemy; enemy->init(); + enemy->setLayerCollision( Level.getCollisionLayer() ); #endif createPlayer();