6 #include "DAnimation.h"
12 Tileset
Object::OBJECTS_TILESET( "objects.png" );
14 Object::Object( ObjectClass
*CLASS
, Sint16 X
, Sint16 Y
) : MapObject( X
, Y
)
20 Object::Object( ObjectClass
*CLASS
) : MapObject( 0, 0 )
25 void Object::Init( ObjectClass
*CLASS
)
29 oLoc
= Object::LOC_GROUND
;
31 switch( oclass
->graphic
)
33 case ObjectClass::GRA_TILE
:
34 graphic
= new DTile( &Object::OBJECTS_TILESET
, oclass
->tile_id
);
36 case ObjectClass::GRA_ANIMATION
:
47 void Object::OnActivation( Player
*p
)
49 if( oclass
->OnActivation
!= LUA_REFNIL
)
51 lua_rawgeti( Game::LUA
, LUA_REGISTRYINDEX
, oclass
->OnActivation
);
52 lua_pushlightuserdata( Game::LUA
, this );
53 lua_call( Game::LUA
, 1, 0 );
57 void Object::OnPickup( Player
*p
)
59 if( oclass
->OnPickup
!= LUA_REFNIL
)
61 lua_rawgeti( Game::LUA
, LUA_REGISTRYINDEX
, oclass
->OnPickup
);
62 lua_pushlightuserdata( Game::LUA
, this );
63 lua_call( Game::LUA
, 1, 0 );
67 void Object::OnDrop( Player
*p
)
69 if( oclass
->OnDrop
!= LUA_REFNIL
)
71 lua_rawgeti( Game::LUA
, LUA_REGISTRYINDEX
, oclass
->OnDrop
);
72 lua_pushlightuserdata( Game::LUA
, this );
73 lua_call( Game::LUA
, 1, 0 );
77 void Object::OnPlayerOnTile( Player
*p
)
79 if( oclass
->OnPlayerOnTile
!= LUA_REFNIL
)
81 lua_rawgeti( Game::LUA
, LUA_REGISTRYINDEX
, oclass
->OnPlayerOnTile
);
82 lua_pushlightuserdata( Game::LUA
, this );
83 lua_call( Game::LUA
, 1, 0 );
85 else //standard action
91 /* bool Object::checkID( std::string id )
93 return oclass->id == id;
96 std::string & Object::getID( )