Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 26, 2009, 2:11:48 PM (15 years ago)
Author:
scheusso
Message:

server may now pause/slow the game (also on clients) with commands setTimeFactor & pause

Location:
code/branches/presentation2/src/orxonox/gamestates
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/orxonox/gamestates/GSRoot.cc

    r6105 r6160  
    4545    GSRoot::GSRoot(const GameStateInfo& info)
    4646        : GameState(info)
    47         , timeFactor_(1.0f)
    4847        , bPaused_(false)
    4948        , timeFactorPauseBackup_(1.0f)
     
    7372    {
    7473        // reset game speed to normal
    75         this->timeFactor_ = 1.0f;
     74        TimeFactorListener::setTimeFactor(1.0f);
    7675
    7776        // time factor console command
     
    102101        }
    103102        for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; )
    104             (it++)->tick(leveldt * this->timeFactor_);
     103            (it++)->tick(leveldt * TimeFactorListener::getTimeFactor());
    105104        /*** HACK *** HACK ***/
    106105    }
     
    119118            if (!this->bPaused_)
    120119            {
    121                 TimeFactorListener::timefactor_s = factor;
    122 
    123                 for (ObjectList<TimeFactorListener>::iterator it = ObjectList<TimeFactorListener>::begin(); it != ObjectList<TimeFactorListener>::end(); ++it)
    124                     it->changedTimeFactor(factor, this->timeFactor_);
    125 
    126                 this->timeFactor_ = factor;
     120                TimeFactorListener::setTimeFactor(factor);
    127121            }
    128122            else
     
    137131            if (!this->bPaused_)
    138132            {
    139                 this->timeFactorPauseBackup_ = this->timeFactor_;
     133                this->timeFactorPauseBackup_ = TimeFactorListener::getTimeFactor();
    140134                this->setTimeFactor(0.0f);
    141135                this->bPaused_ = true;
     
    148142        }
    149143    }
     144
     145    float GSRoot::getTimeFactor()
     146    {
     147        return TimeFactorListener::getTimeFactor();
     148    }
    150149}
  • code/branches/presentation2/src/orxonox/gamestates/GSRoot.h

    r5929 r6160  
    5151        void setTimeFactor(float factor);
    5252        void pause();
    53         float getTimeFactor() { return this->timeFactor_; }
     53        float getTimeFactor();
    5454
    5555    private:
    56         float                 timeFactor_;              //!< A factor that sets the gamespeed. 1 is normal.
    5756        bool                  bPaused_;
    5857        float                 timeFactorPauseBackup_;
Note: See TracChangeset for help on using the changeset viewer.