Commit f0c24de6 authored by Gerhard Stein's avatar Gerhard Stein

Some nice code reductions for EventContainer

parent ae6bdcc7
......@@ -96,7 +96,7 @@ public:
{ return m_TeleporterTable; }
CEventContainer &EventList()
{ return m_EventList; }
{ return gEventManager; }
void setEpisode(size_t Episode);
......@@ -106,8 +106,6 @@ public:
bool paused()
{ return mPausedGamePlay; }
// TODO: EventList must an own singleton Container, as it very often used.
CEventContainer m_EventList;
CExeFile m_ExeFile;
bool m_is_a_mod;
stOption m_option[NUM_OPTIONS];
......
......@@ -52,7 +52,7 @@ void CGameLauncherMenu::init()
SDL_Surface *blit = g_pVideoDriver->getBlitSurface();
SDL_FillRect( blit, nullptr, SDL_MapRGB(blit->format, 0, 0, 0) );
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
// If game was started for the first time, also open the firsttime dialog with configs.
if(m_firsttime)
......@@ -307,7 +307,7 @@ void CGameLauncherMenu::ponder()
if( loadResources(DataDirectory, Episode) )
{
// Now look if there are any old savegames that need to be converted
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
CSaveGameController &savedgames = *gpSaveGameController;
savedgames.setGameDirectory(DataDirectory);
savedgames.setEpisode(Episode);
......@@ -333,7 +333,7 @@ void CGameLauncherMenu::ponder()
else if(mp_GameLauncher->getQuit())
{
// User chose "exit". So make CG quit...
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
EventContainer.add( new GMQuit() );
}
}
......
......@@ -29,7 +29,7 @@ void CGameMain::switchToGamePlayMode()
const int Numplayers = g_pBehaviorEngine->mPlayers;
std::string DataDirectory = g_pBehaviorEngine->m_ExeFile.getDataDirectory();
g_pBehaviorEngine->m_EventList.add( new GMSwitchToPlayGameMode( episode, Numplayers, DataDirectory ) );
gEventManager.add( new GMSwitchToPlayGameMode( episode, Numplayers, DataDirectory ) );
}
......
......@@ -29,7 +29,7 @@ void CGamePassiveMode::init()
if( mpPassive->init() ) return;
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
EventContainer.add( new GMSwitchToGameLauncher(-1, -1) );
}
......@@ -41,7 +41,7 @@ void CGamePassiveMode::ponder()
// Process Events
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
// check here what the player chose from the menu over the passive mode.
// NOTE: Demo is not part of playgame anymore!!
......
......@@ -30,7 +30,7 @@ m_DataDirectory(gpmode.m_DataDirectory)
void CGamePlayMode::init()
{
CExeFile &ExeFile = g_pBehaviorEngine->m_ExeFile;
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
// If no level has been set or is out of bound, set it to map.
if(m_startLevel > 100 || m_startLevel < 0 )
......@@ -86,7 +86,7 @@ void CGamePlayMode::pumpEvent(const CEvent *evPtr)
void CGamePlayMode::ponder()
{
// The player is playing the game. It also includes scenes like ending
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
mp_PlayGame->ponder();
......
......@@ -52,8 +52,6 @@ struct EventDieKeenPlayer : CEvent
levelObj(lo), levelName(ln){}
};
struct EventPlayerTeleportFromLevel : CEvent
{};
struct EventExitLevel : CEvent {
const uint16_t levelObject;
......@@ -78,9 +76,12 @@ struct EventPlayerEndLevel : CEvent {
const uint16_t levelObject;
const bool sucess;
const int who;
const bool teleport;
EventPlayerEndLevel(const EventExitLevel &ev) :
levelObject(ev.levelObject), sucess(ev.sucess),
who(ev.who) {}
levelObject(ev.levelObject),
sucess(ev.sucess),
who(ev.who),
teleport(ev.teleport){}
};
struct EventPlayerRideFoot : CEvent {
......
......@@ -10,126 +10,8 @@
#ifndef CEVENTCONTAINER_H_
#define CEVENTCONTAINER_H_
#include <lib/base/GsEvent.h>
/*#include "CEvent.h"
#include <deque>
#include <vector>
#include <ctime>
class CEventContainer
{
public:
CEventContainer() :
pausetime(0),
timepoint(0)
{}
size_t size() { return m_EventList.size(); }
bool empty() { return m_EventList.empty(); }
void clear() { m_EventList.clear(); }*/
/**
* @brief regSink will register the sink in the Container
* when you are destroying the object, you must call unregSink() first!
* Otherwise app might crash.
* @param pSink pointer to the sink to be registered
*/
/*void regSink(GsEventSink *pSink)
{
mSinkPtrList.push_back(pSink);
}
void unregSink(GsEventSink *pSink)
{
// TODO: Code for unregistering the Sink
}
void processSinks()
{
// First check if there are pendingEvents to be processed
if(m_EventList.empty())
return;
// Make a copy of that list, because the original
// could change, while pumping happens
for(auto &ev : m_EventList)
mPumpEventPtrs.push_back(ev);
// We don't need anything from this list anymore
m_EventList.clear();
for( GsEventSink* sink : mSinkPtrList )
{
for( auto &event : mPumpEventPtrs )
{
sink->pumpEvent( event.get() );
}
}
mPumpEventPtrs.clear();
}
void add(std::shared_ptr<CEvent>& ev)
{
m_EventList.push_back(ev);
}
void add(CEvent *ev)
{
m_EventList.push_back(std::shared_ptr<CEvent>(ev));
}
void wait(const float time)
{
timepoint = clock();
pausetime = static_cast<clock_t>(time*static_cast<float>(CLOCKS_PER_SEC));
}
void update()
{
if(pausetime<=0.0f)
return;
const clock_t newTime = clock();
const clock_t passed = newTime-timepoint;
timepoint = newTime;
pausetime -= passed;
return;
}
std::deque< std::shared_ptr<CEvent> >::iterator erase(std::deque< std::shared_ptr<CEvent> >::iterator &it)
{ return m_EventList.erase(it); }
std::deque< std::shared_ptr<CEvent> >::iterator begin() { return m_EventList.begin(); }
std::deque< std::shared_ptr<CEvent> >::iterator end() { return m_EventList.end(); }
template<typename T> T* occurredEvent();
void pop_Event() { m_EventList.pop_front(); }
// Spawning Event for the Foes // TODO: Workaround. I think it should go into another section
void spawnObj(const CSpriteObject *obj)
{
add(new EventSpawnObject( obj ));
}
private:
std::list< GsEventSink* > mSinkPtrList;
std::deque< std::shared_ptr<CEvent> > m_EventList;
std::vector< std::shared_ptr<CEvent> > mPumpEventPtrs;
clock_t pausetime;
clock_t timepoint;
};
template<typename T>
T* CEventContainer::occurredEvent()
{
if(m_EventList.empty() || pausetime > 0 )
return NULL;
// TODO: To be removed soon enough!
#include <lib/base/GsEvent.h>
return dynamic_cast<T*> (m_EventList.front().get());
}
*/
#endif /* CEVENTCONTAINER_H_ */
......@@ -67,10 +67,8 @@ bool CLevelPlay::loadLevel(const Uint16 level)
const std::string level_text = "LEVEL" + itoa(level) + "_LOAD_TEXT";
const std::string loading_text = g_pBehaviorEngine->getString(level_text);
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
g_pGfxEngine->setupEffect(new CDimDark(8));
EventContainer.add( new EventSendBitmapDialogMsg(*g_pGfxEngine->getBitmapFromStr("KEENTHUMBSUP"),
gEventManager.add( new EventSendBitmapDialogMsg(*g_pGfxEngine->getBitmapFromStr("KEENTHUMBSUP"),
loading_text, LEFT) );
mMap.drawAll();
......
......@@ -145,7 +145,7 @@ void CMapPlayGalaxy::ponder()
CEventContainer &EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer &EventContainer = gEventManager;
if( EventSpawnObject *ev = EventContainer.occurredEvent<EventSpawnObject>() )
{
std::shared_ptr<CGalaxySpriteObject> obj( static_cast<CGalaxySpriteObject*>(
......
......@@ -112,7 +112,7 @@ bool CPassiveGalaxy::init(char mode)
// Here it will execute the mode we are currently running
void CPassiveGalaxy::ponder()
{
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
if( EventContainer.occurredEvent<EventEndGamePlay>() )
{
......
......@@ -247,7 +247,7 @@ void CPlayGameGalaxy::looseManagement( const int playerID,
const int levelObj,
const std::string &levelName )
{
CEventContainer &eventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer &eventContainer = gEventManager;
// Check if all players are dead
bool allDead = true;
......@@ -313,7 +313,7 @@ void CPlayGameGalaxy::pumpEvent(const CEvent *evPtr)
// In this part we will poll all the relevant Events that are important for the
// Galaxy Main Engine itself. For example, load map, setup world map, show Highscore
// are some of those events.
CEventContainer &eventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer &eventContainer = gEventManager;
if( const EventSendBitmapDialogMsg *ev = dynamic_cast<const EventSendBitmapDialogMsg*>(evPtr) )
{
......@@ -406,12 +406,6 @@ void CPlayGameGalaxy::pumpEvent(const CEvent *evPtr)
const EventExitLevel &evCopy = *ev;
eventContainer.add( new EventPlayerEndLevel(evCopy) );
// Should only happen in Keen 5. This should trigger on map teleportation
if(evCopy.teleport)
{
eventContainer.add( new EventPlayerTeleportFromLevel() );
}
}
else if( const EventDieKeenPlayer *ev = dynamic_cast<const EventDieKeenPlayer*>(evPtr) )
{
......@@ -453,7 +447,7 @@ void CPlayGameGalaxy::ponder()
if(g_pSound->pauseGamePlay() )
return;
CEventContainer &eventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer &eventContainer = gEventManager;
//eventContainer.update();
if( !gpMenuController->active() )
......
......@@ -33,13 +33,12 @@ void CWorldMap::init()
g_pBehaviorEngine->mapLevelName = MapLoader->getLevelName();
const std::string loading_text = g_pBehaviorEngine->getString("WORLDMAP_LOAD_TEXT");
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
g_pGfxEngine->setupEffect(new CColorMerge(8));
if(!gpSaveGameController->busy())
{
EventContainer.add( new EventSendBitmapDialogMsg(*g_pGfxEngine->getBitmapFromStr("KEENTHUMBSUP"), loading_text, LEFT) );
gEventManager.add( new EventSendBitmapDialogMsg(*g_pGfxEngine->getBitmapFromStr("KEENTHUMBSUP"), loading_text, LEFT) );
}
mMap.drawAll();
......
......@@ -187,7 +187,7 @@ void CPlayerBase::getAnotherLife(const int lc_x, const int lc_y, const bool disp
const int ep = g_pBehaviorEngine->getEpisode();
const int id = alt ? 12 : 10;
CItemEffect *lifeUp = new CItemEffect(mp_Map, 0, lc_x<<CSF, lc_y<<CSF, got_sprite_item_pics[ep-4][id], FADEOUT);
g_pBehaviorEngine->m_EventList.add( new EventSpawnObject( lifeUp ) );
gEventManager.add( new EventSpawnObject( lifeUp ) );
}
}
......@@ -557,7 +557,7 @@ void CPlayerBase::processDead()
m_camera.forbidLead(mPlayerNum);
m_camera.cycleCamlead();
g_pBehaviorEngine->m_EventList.add( new EventDieKeenPlayer(mPlayerNum,
gEventManager.add( new EventDieKeenPlayer(mPlayerNum,
m_Inventory.Item.m_lifes<0,
levelObj,
levelName) );
......
......@@ -1429,7 +1429,7 @@ void CPlayerLevel::processExiting()
{
g_pSound->playSound( SOUND_LEVEL_DONE );
g_pMusicPlayer->stop();
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
const std::string loading_text = g_pBehaviorEngine->getString("WORLDMAP_LOAD_TEXT");
EventContainer.add( new EventExitLevel(mp_Map->getLevel(), true, false, mSprVar) );
g_pGfxEngine->setupEffect(new CDimDark(8));
......@@ -1739,11 +1739,11 @@ void CPlayerLevel::processEnterDoor()
// TODO: Figure out what this does
g_pMusicPlayer->stop();
g_pSound->playSound( SOUND_LEVEL_DONE );
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
const std::string loading_text = g_pBehaviorEngine->getString("WORLDMAP_LOAD_TEXT");
EventContainer.add( new EventSendBitmapDialogMsg(*g_pGfxEngine->getBitmapFromStr("KEENTHUMBSUP"), loading_text, LEFT) );
g_pBehaviorEngine->m_EventList.add( new EventExitLevel(mp_Map->getLevel(), true, mustTeleportOnMap, mSprVar) );
gEventManager.add( new EventExitLevel(mp_Map->getLevel(), true, mustTeleportOnMap, mSprVar) );
dontdraw = true;
m_Inventory.Item.m_gem.clear();
......@@ -1756,10 +1756,10 @@ void CPlayerLevel::processEnterDoor()
//o->action = ACTION_KEENENTEREDDOOR;
g_pMusicPlayer->stop();
g_pSound->playSound( SOUND_LEVEL_DONE );
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
const std::string loading_text = g_pBehaviorEngine->getString("WORLDMAP_LOAD_TEXT");
EventContainer.add( new EventSendBitmapDialogMsg(*g_pGfxEngine->getBitmapFromStr("KEENTHUMBSUP"), loading_text, LEFT) );
g_pBehaviorEngine->m_EventList.add( new EventExitLevel(mp_Map->getLevel(), true, false, mSprVar) );
gEventManager.add( new EventExitLevel(mp_Map->getLevel(), true, false, mSprVar) );
dontdraw = true;
m_Inventory.Item.m_gem.clear();
return;
......@@ -2614,11 +2614,11 @@ void CPlayerLevel::process()
// TODO: Need to spawn other messages here!
g_pMusicPlayer->stop();
g_pSound->playSound( SOUND_LEVEL_DONE );
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
const std::string loading_text = g_pBehaviorEngine->getString("WORLDMAP_LOAD_TEXT");
EventContainer.wait(1.0f);
EventContainer.add( new EventSendBitmapDialogMsg(*g_pGfxEngine->getBitmapFromStr("KEENTHUMBSUP"), loading_text, LEFT) );
g_pBehaviorEngine->m_EventList.add( new EventExitLevel(mp_Map->getLevel(), true, false, mSprVar) );
gEventManager.add( new EventExitLevel(mp_Map->getLevel(), true, false, mSprVar) );
m_Inventory.Item.m_gem.clear();
m_Inventory.Item.fuse_levels_completed++;
mp_Map->mFuseInLevel = false;
......
......@@ -136,7 +136,8 @@ void CPlayerWM::pumpEvent(const CEvent *evPtr)
{
// enough fuses broken, in fact of all the fuses levels, except the secret one.
// then open the elevator door for the last level!
// NOTE: I'm not sure, if there is a better way to do it. if you know one, go ahead and improve this!
// NOTE: I'm not sure, if there is a better way to do it.
// if you know one, go ahead and improve this!
if(m_Inventory.Item.fuse_levels_completed >= 4)
{
// Must happen only once!
......@@ -167,9 +168,26 @@ void CPlayerWM::pumpEvent(const CEvent *evPtr)
}
}
}
if(ev->teleport)
{
// 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;
m_Pos.x = newX;
m_Pos.y = newY;
m_camera.setPosition(m_Pos);
}
}
if( const EventPlayerRideFoot* ev = dynamic_cast<const EventPlayerRideFoot*>(evPtr) )
else if( const EventPlayerRideFoot* ev = dynamic_cast<const EventPlayerRideFoot*>(evPtr) )
{
finishLevel(ev->levelObject);
solid = false;
......@@ -182,23 +200,6 @@ void CPlayerWM::pumpEvent(const CEvent *evPtr)
setActionSprite();
mProcessPtr = &CPlayerWM::processRiding;
}
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;
m_Pos.x = newX;
m_Pos.y = newY;
m_camera.setPosition(m_Pos);
}
}
......@@ -314,7 +315,7 @@ void CPlayerWM::processMoving()
else
{
// Tell the player he cannot climb yet
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
EventContainer.add( new EventSendBitmapDialogMsg(
g_pGfxEngine->getBitmapFromId(29),
g_pBehaviorEngine->getString("KEEN_ROPE_REQUIRED"), RIGHT) );
......@@ -428,7 +429,7 @@ void CPlayerWM::processMoving()
{
if( !m_cantswim )
{
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
g_pSound->playSound( SOUND_CANT_DO, PLAY_PAUSEALL );
EventContainer.add( new EventSendBitmapDialogMsg(g_pGfxEngine->getBitmapFromId(105),
......@@ -956,7 +957,7 @@ void CPlayerWM::startLevel(Uint16 object)
if(mp_Map->findTile(flag_dest, &x, &y, 2) || g_pBehaviorEngine->m_option[OPT_LVLREPLAYABILITY].value || level >= shipLevel)
{
g_pBehaviorEngine->m_EventList.add(new EventEnterLevel(object));
gEventManager.add(new EventEnterLevel(object));
}
}
......
......@@ -151,12 +151,10 @@ void CMessageBoxSelection::ponder()
// Look, if somebody pressed a button, and close this dialog!
if(g_pInput->getPressedCommand(IC_JUMP) || g_pInput->getPressedKey(KENTER) )
{
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
for( int c=0 ; c<m_selection ; c++ )
m_Options.pop_front();
EventContainer.add( m_Options.front().event );
gEventManager.add( m_Options.front().event );
mMustClose = true;
g_pInput->flushCommands();
......
......@@ -105,7 +105,7 @@ void CBerkeloid::processMoving()
setAction( A_BERKELOID_THROW );
playSound( SOUND_BERKELOID_WINDUP );
CBerkFlame *flame = new CBerkFlame( getMapPtr(), getXMidPos(), getYUpPos(), xDirection );
g_pBehaviorEngine->m_EventList.add( new EventSpawnObject( flame ) );
gEventManager.add( new EventSpawnObject( flame ) );
return;
}
......
......@@ -118,7 +118,7 @@ void CCouncilMember::process()
void CCouncilMember::performJanitorMode()
{
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
std::string elder_text[4];
......@@ -160,7 +160,7 @@ void CCouncilMember::getTouchedBy(CSpriteObject &theObject)
{
int &rescuedelders = player->m_Inventory.Item.m_special.ep4.elders;
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
// TODO: In this part we have to check which level we are and send the proper messages
......
......@@ -114,7 +114,7 @@ void CDevilSprite::processShoot()
x_coord += (xDirection == LEFT) ? -(8<<STC) : +(8<<STC);
CEnemyShot *Spark = new CEnemyShot(mp_Map, 0, x_coord, getYMidPos()-(8<<STC),
0x3818, xDirection, 0, 100, 0);
g_pBehaviorEngine->m_EventList.add( new EventSpawnObject( Spark ) );
gEventManager.add( new EventSpawnObject( Spark ) );
}
if( m_timer <= 0 )
......
......@@ -32,7 +32,7 @@ void CDiveSuit::getTouchedBy(CSpriteObject &theObject)
{
bool &swimsuit = player->m_Inventory.Item.m_special.ep4.swimsuit;
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
g_pSound->playSound( SOUND_GET_WETSUIT, PLAY_PAUSEALL );
taken = swimsuit = true;
......
......@@ -144,7 +144,7 @@ void CDopeFish::processBurp()
{
g_pSound->playSound(SOUND_DOPEFISH_BURP);
CBubbles *Bubble = new CBubbles(mp_Map, 0, getXMidPos()+(1<<CSF), getYMidPos()+(1<<CSF), true);
g_pBehaviorEngine->m_EventList.add( new EventSpawnObject( Bubble ) );
gEventManager.add( new EventSpawnObject( Bubble ) );
m_burped = true;
}
......
......@@ -53,12 +53,12 @@ void CEgg::hatch()
shard2->setActionSprite();
shard3->setActionSprite();
g_pBehaviorEngine->m_EventList.add( new EventSpawnObject( shard1 ) );
g_pBehaviorEngine->m_EventList.add( new EventSpawnObject( shard2 ) );
g_pBehaviorEngine->m_EventList.add( new EventSpawnObject( shard3 ) );
gEventManager.add( new EventSpawnObject( shard1 ) );
gEventManager.add( new EventSpawnObject( shard2 ) );
gEventManager.add( new EventSpawnObject( shard3 ) );
CBlueBird *blueBird = new CBlueBird( getMapPtr(), mFoeID, getXMidPos(), getYMidPos() );
g_pBehaviorEngine->m_EventList.add( new EventSpawnObject( blueBird ) );
gEventManager.add( new EventSpawnObject( blueBird ) );
}
......
......@@ -28,7 +28,7 @@ void CFoot::getTouchedBy(CSpriteObject &theObject)
if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) )
{
// TODO: This is not all. He exits the level but must also transport to the secret level. Add this event.
g_pBehaviorEngine->m_EventList.add( new EventExitLevelWithFoot(mp_Map->getLevel(), player->getSpriteVariantId()) );
gEventManager.add( new EventExitLevelWithFoot(mp_Map->getLevel(), player->getSpriteVariantId()) );
player->m_Inventory.Item.m_gem.clear();
}
}
......
......@@ -61,7 +61,7 @@ bool CInchWorm::isNearby(CSpriteObject &theObject)
if(mInchWormContacts >= 11)
{
g_pBehaviorEngine->m_EventList.add( new EventSpawnFoot( getXMidPos(), getYUpPos(), 67 ) );
gEventManager.add( new EventSpawnFoot( getXMidPos(), getYUpPos(), 67 ) );
}
}
......
......@@ -60,7 +60,7 @@ void CLindsey::getTouchedBy(CSpriteObject &theObject)
// When Keen touches the pincess give that hint
if( dynamic_cast<CPlayerLevel*>(&theObject) )
{
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
g_pSound->playSound(SOUND_GET_WETSUIT, PLAY_PAUSEALL);
......
......@@ -139,7 +139,7 @@ void CPlayerDive::processDiving()
playSound(SOUND_BUBBLE);
int dir_offset = (xDirection==RIGHT) ? +(1<<CSF) : -(1<<CSF) ;
CBubbles *Bubble = new CBubbles(mp_Map, 0, getXMidPos()+dir_offset, getYMidPos(), false);
g_pBehaviorEngine->m_EventList.add( new EventSpawnObject( Bubble ) );
gEventManager.add( new EventSpawnObject( Bubble ) );
m_breathtimer = 0;
}
else
......
......@@ -84,7 +84,7 @@ void CPoisonSlug::processCrawling()
setAction( A_SLUG_POOING );
playSound( SOUND_SLUG_DEFECATE );
CSlugSlime *slime = new CSlugSlime(mp_Map, 0, getXMidPos(), getYDownPos()-(1<<CSF), 0);
g_pBehaviorEngine->m_EventList.add( new EventSpawnObject( slime ) );
gEventManager.add( new EventSpawnObject( slime ) );
xDirection = -xDirection;
return;
......
......@@ -502,7 +502,7 @@ void CMineShards::process()
}
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
const std::string end_text("End of Episode.\n"
"The game will be restarted.\n"
......
......@@ -48,7 +48,7 @@ void CGrabbiter::getTouchedBy(CSpriteObject& theObject)
const int diffX = getXMidPos()-player->getXMidPos();
player->moveXDir(-diffX/4);
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
if(player->m_Inventory.Item.m_special.ep6.sandwich > 0)
{
......
......@@ -46,7 +46,7 @@ void CMolly::getTouchedBy(CSpriteObject& theObject)
//if( typeid(theObject) == typeid(CPlayerLevel) )
if( /*CPlayerBase *player = */dynamic_cast<CPlayerBase*>(&theObject) )
{
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
std::vector< std::shared_ptr<EventSendBitmapDialogMsg> > msgs;
......
......@@ -235,7 +235,7 @@ void CNospike::getTouchedBy(CSpriteObject& theObject)
{
if( mCanFinishGame && getActionNumber(A_NOSPIKE_STUNNED) ) // This will only happen in the Keen 8 Mod!
{
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
std::vector< std::shared_ptr<EventSendBitmapDialogMsg> > msgs;
......
......@@ -135,7 +135,7 @@ void CRocket::getTouchedBy(CSpriteObject& theObject)
else
{
// Tell the player he cannot climb yet
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
EventContainer.add( new EventSendBitmapDialogMsg(
g_pGfxEngine->getBitmapFromId(29),
g_pBehaviorEngine->getString("KEEN_KEYCARD_REQUIRED"),
......
......@@ -25,7 +25,7 @@ void CSpecialItem::getTouchedBy(CSpriteObject& theObject)
mTaken = true;
auto &item = player->m_Inventory.Item.m_special.ep6;
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
// Sound play
g_pSound->playSound(SOUND_GET_SPECIAL_ITEM, PLAY_PAUSEALL);
......
......@@ -64,7 +64,7 @@ bool CPassiveVort::init(char mode)
void CPassiveVort::ponder()
{
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = gEventManager;
if(!EventContainer.empty())
{
......
......@@ -92,7 +92,7 @@ void CVorticonSpriteObjectAI::process()
}