diff --git a/source/platform/platform.h b/source/platform/platform.h index fe15dfde8..0dfd18f06 100644 --- a/source/platform/platform.h +++ b/source/platform/platform.h @@ -132,7 +132,7 @@ public: static CNpcPlatform *Create(int Type); static CNpcPlatform *Create(sThingPlatform *ThisPlatform); - void setSpeed( s16 newSpeed ) {m_speed = newSpeed;} + virtual void setSpeed( s16 newSpeed ) {m_speed = newSpeed;} protected: // NPC data structure definitions // @@ -177,7 +177,7 @@ protected: // functions - void reinit(); + virtual void reinit(); bool processSensor(); virtual void processMovement( int _frames ); virtual void processLifetime( int _frames ); diff --git a/source/platform/pretract.cpp b/source/platform/pretract.cpp index e22a5d76f..279ff2fc7 100644 --- a/source/platform/pretract.cpp +++ b/source/platform/pretract.cpp @@ -36,12 +36,39 @@ void CNpcRetractingPlatform::postInit() m_timer = NPC_PLATFORM_TIMER_RETRACT; m_extension = ONE; + + m_initDelay = 0; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcRetractingPlatform::setSpeed( s16 newSpeed ) +{ + m_speed = newSpeed; + + m_initDelay = ( m_speed * GameState::getOneSecondInFrames() ) >> 2; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcRetractingPlatform::reinit() +{ + CNpcPlatform::reinit(); + + m_initDelay = ( m_speed * GameState::getOneSecondInFrames() ) >> 2; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CNpcRetractingPlatform::processTimer( int _frames ) { + if ( m_initDelay > 0 ) + { + m_initDelay -= _frames; + + return; + } + switch( m_timerType ) { case NPC_PLATFORM_TIMER_RETRACT: diff --git a/source/platform/pretract.h b/source/platform/pretract.h index 338a8b93f..8e05d9c2f 100644 --- a/source/platform/pretract.h +++ b/source/platform/pretract.h @@ -23,9 +23,15 @@ class CNpcRetractingPlatform : public CNpcPlatform public: void postInit(); void render(); + bool alwaysThink() {return(true);} + + void setSpeed( s16 newSpeed ); protected: + void reinit(); void processTimer( int _frames ); + s32 m_initDelay; + enum NPC_PLATFORM_TIMER_TYPE { NPC_PLATFORM_TIMER_RETRACT = 0,