Commit c57bf385 authored by Gerhard Stein's avatar Gerhard Stein

More pumped events

parent bef3b117
......@@ -112,6 +112,8 @@ public:
int yDirection; // same for vertical
int scrx, scry; // x,y pixel position on screen
virtual void pumpEvent(const CEvent *evPtr) {}
// Bounding Boxes
BoundingBox m_BBox;
......
......@@ -60,7 +60,14 @@ std::string CMapPlayGalaxy::getLevelName()
void CMapPlayGalaxy::pumpEvent(const CEvent *evPtr)
{
for( auto obj = mObjectPtr.begin(); obj != mObjectPtr.end() ; obj++)
{
auto &objRef = *(obj->get());
objRef.pumpEvent(evPtr);
}
}
......
......@@ -42,6 +42,8 @@ public:
*/
std::string getLevelName();
void pumpEvent(const CEvent *evPtr);
void ponder();
void render(const float deltaT);
......
......@@ -441,6 +441,9 @@ void CPlayGameGalaxy::pumpEvent(const CEvent *evPtr)
}
}
m_WorldMap.pumpEvent(evPtr);
m_LevelPlay.pumpEvent(evPtr);
}
/**
......
......@@ -87,6 +87,7 @@ public:
stCheat &Cheatmode,
int playerID);
/**
* Pushes the players by the given object Reference
*/
......
......@@ -119,31 +119,10 @@ VectorD2<int> CPlayerWM::fetchFootDestCoord()
/**
* The main process cycle for the player itself only on the map
*/
void CPlayerWM::process()
void CPlayerWM::pumpEvent(const CEvent *evPtr)
{
if(mp_Map->locked())
return;
processInput();
// Perform animation cycle
if(m_animation_ticker >= m_animation_time)
{
m_animation++;
m_animation_ticker = 0;
}
else m_animation_ticker++;
(this->*mProcessPtr)();
// Events for the Player are processed here.
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
if( EventPlayerEndLevel* ev = EventContainer.occurredEvent<EventPlayerEndLevel>() )
if( const EventPlayerEndLevel* ev = dynamic_cast<const EventPlayerEndLevel*>(evPtr) )
{
if(ev->who == mSprVar)
{
......@@ -185,43 +164,63 @@ void CPlayerWM::process()
}
}
}
EventContainer.pop_Event();
}
}
}
if( EventPlayerRideFoot* ev = EventContainer.occurredEvent<EventPlayerRideFoot>() )
{
finishLevel(ev->levelObject);
solid = false;
if( const EventPlayerRideFoot* ev = dynamic_cast<const EventPlayerRideFoot*>(evPtr) )
{
finishLevel(ev->levelObject);
solid = false;
// Here we need to set the coordinates calculated to where Keen has to go.
target = fetchFootDestCoord();
// Here we need to set the coordinates calculated to where Keen has to go.
target = fetchFootDestCoord();
// Make Keen ride on the foot
m_Action.setActionFormat(0x1492);
setActionSprite();
mProcessPtr = &CPlayerWM::processRiding;
EventContainer.pop_Event();
}
// Make Keen ride on the foot
m_Action.setActionFormat(0x1492);
setActionSprite();
mProcessPtr = &CPlayerWM::processRiding;
}
if( EventContainer.occurredEvent<EventPlayerTeleportFromLevel>() )
{
// Find the spot of the teleportation destination
// TODO: This part is only meant for Episode 5. We should catch exception
// Whenever another episode tries to trigger this call.
int x,y;
mp_Map->findTile( 0x1A, &x, &y, 2);
if( dynamic_cast<const EventPlayerTeleportFromLevel*>(evPtr) )
{
// Find the spot of the teleportation destination
// TODO: This part is only meant for Episode 5. We should catch exception
// Whenever another episode tries to trigger this call.
int x,y;
mp_Map->findTile( 0x1A, &x, &y, 2);
const int newX = x<<CSF;
const int newY = y<<CSF;
const int newX = x<<CSF;
const int newY = y<<CSF;
m_Pos.x = newX;
m_Pos.y = newY;
m_camera.setPosition(m_Pos);
}
}
m_Pos.x = newX;
m_Pos.y = newY;
m_camera.setPosition(m_Pos);
EventContainer.pop_Event();
/**
* The main process cycle for the player itself only on the map
*/
void CPlayerWM::process()
{
if(mp_Map->locked())
return;
processInput();
// Perform animation cycle
if(m_animation_ticker >= m_animation_time)
{
m_animation++;
m_animation_ticker = 0;
}
else m_animation_ticker++;
(this->*mProcessPtr)();
processCamera();
}
......
......@@ -25,6 +25,8 @@ public:
const int playerID);
VectorD2<int> fetchFootDestCoord();
void pumpEvent(const CEvent *evPtr);
void deserialize(CSaveGameController &savedGame)
{
......
......@@ -192,6 +192,22 @@ bool CPlayGameVorticon::StatusScreenOpen()
}
void CPlayGameVorticon::pumpEvent(const CEvent *evPtr)
{
// Process Related Events.
if( dynamic_cast<const ResetScrollSurface*>(evPtr) )
{
g_pVideoDriver->updateScrollBuffer(mMap);
return;
}
else if( dynamic_cast<const EventEndGamePlay*>(evPtr) )
{
m_endgame = true;
}
}
////
// Process Routine
////
......@@ -303,12 +319,6 @@ void CPlayGameVorticon::ponder()
handleFKeys();
}
auto &eventContainer = g_pBehaviorEngine->EventList();
if( eventContainer.occurredEvent<EventEndGamePlay>() )
{
m_endgame = true;
eventContainer.pop_Event();
}
}
void CPlayGameVorticon::render(const float deltaT)
......@@ -630,18 +640,6 @@ void CPlayGameVorticon::drawAllElements()
}
// Process Related Events.
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
if(!EventContainer.empty())
{
if( EventContainer.occurredEvent<ResetScrollSurface>() )
{
g_pVideoDriver->updateScrollBuffer(mMap);
EventContainer.pop_Event();
return;
}
}
}
////
// Cleanup Routine
......
......@@ -57,6 +57,8 @@ public:
bool loadXMLGameState();
bool saveXMLGameState();
void pumpEvent(const CEvent *evPtr);
void ponder();
void processOnWorldMap();
void processInLevel();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment