Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 30, 2015, 10:31:43 PM (8 years ago)
Author:
landauf
Message:

using strongly typed enum in various classes in orxonox-library

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/orxonox/items/MultiStateEngine.cc

    r10919 r11005  
    124124                this->state_ = 0;
    125125                if (this->getShip()->isBoosting() && forward)
    126                     this->state_ = Boost;
     126                    this->state_ = EngineState::Boost;
    127127                else if (forward && !this->state_) // this->state_ == Boost
    128                     this->state_ = Normal;
     128                    this->state_ = EngineState::Normal;
    129129                else if (direction.z > 0.0 && velocity.z < 0.0)
    130                     this->state_ = Brake;
     130                    this->state_ = EngineState::Brake;
    131131                else
    132                     this->state_ = Idle;
    133 
    134                 if (this->state_ == Idle && this->getSpeedAdd() > 0)
    135                     this->state_ = Normal;
     132                    this->state_ = EngineState::Idle;
     133
     134                if (this->state_ == EngineState::Idle && this->getSpeedAdd() > 0)
     135                    this->state_ = EngineState::Normal;
    136136            }
    137137
     
    141141
    142142                float pitch = velocity.length();
    143                 if (this->state_ & Normal)
     143                if (this->state_ & EngineState::Normal)
    144144                    defEngineSndNormal_->setPitch(clamp(pitch/MAX_VELOCITY_NORMAL + 1, 0.5f, 2.0f));
    145                 if (this->state_ & Boost)
     145                if (this->state_ & EngineState::Boost)
    146146                    defEngineSndBoost_->setPitch(clamp(pitch/MAX_VELOCITY_BOOST + 1, 0.5f, 2.0f));
    147147
    148                 if (changes & Idle)
    149                 {
    150                     lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Idle);
     148                if (changes & EngineState::Idle)
     149                {
     150                    lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & EngineState::Idle);
    151151                    lua_setglobal(this->lua_->getInternalLuaState(), "idle");
    152152                }
    153                 if (changes & Normal)
    154                 {
    155                     lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Normal);
     153                if (changes & EngineState::Normal)
     154                {
     155                    lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & EngineState::Normal);
    156156                    lua_setglobal(this->lua_->getInternalLuaState(), "normal");
    157                     if (this->state_ & Normal)
     157                    if (this->state_ & EngineState::Normal)
    158158                        defEngineSndNormal_->play();
    159159                    else
    160160                        defEngineSndNormal_->stop();
    161161                }
    162                 if (changes & Brake)
    163                 {
    164                     lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Brake);
     162                if (changes & EngineState::Brake)
     163                {
     164                    lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & EngineState::Brake);
    165165                    lua_setglobal(this->lua_->getInternalLuaState(), "brake");
    166166                }
    167                 if (changes & Boost)
    168                 {
    169                     lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Boost);
     167                if (changes & EngineState::Boost)
     168                {
     169                    lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & EngineState::Boost);
    170170                    lua_setglobal(this->lua_->getInternalLuaState(), "boost");
    171                     if (this->state_ & Boost)
     171                    if (this->state_ & EngineState::Boost)
    172172                        defEngineSndBoost_->play();
    173173                    else
Note: See TracChangeset for help on using the changeset viewer.