Changeset 11005 for code/branches/cpp11_v2/src/orxonox/items
- Timestamp:
- Dec 30, 2015, 10:31:43 PM (9 years ago)
- Location:
- code/branches/cpp11_v2/src/orxonox/items
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/orxonox/items/MultiStateEngine.cc
r10919 r11005 124 124 this->state_ = 0; 125 125 if (this->getShip()->isBoosting() && forward) 126 this->state_ = Boost;126 this->state_ = EngineState::Boost; 127 127 else if (forward && !this->state_) // this->state_ == Boost 128 this->state_ = Normal;128 this->state_ = EngineState::Normal; 129 129 else if (direction.z > 0.0 && velocity.z < 0.0) 130 this->state_ = Brake;130 this->state_ = EngineState::Brake; 131 131 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; 136 136 } 137 137 … … 141 141 142 142 float pitch = velocity.length(); 143 if (this->state_ & Normal)143 if (this->state_ & EngineState::Normal) 144 144 defEngineSndNormal_->setPitch(clamp(pitch/MAX_VELOCITY_NORMAL + 1, 0.5f, 2.0f)); 145 if (this->state_ & Boost)145 if (this->state_ & EngineState::Boost) 146 146 defEngineSndBoost_->setPitch(clamp(pitch/MAX_VELOCITY_BOOST + 1, 0.5f, 2.0f)); 147 147 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); 151 151 lua_setglobal(this->lua_->getInternalLuaState(), "idle"); 152 152 } 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); 156 156 lua_setglobal(this->lua_->getInternalLuaState(), "normal"); 157 if (this->state_ & Normal)157 if (this->state_ & EngineState::Normal) 158 158 defEngineSndNormal_->play(); 159 159 else 160 160 defEngineSndNormal_->stop(); 161 161 } 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); 165 165 lua_setglobal(this->lua_->getInternalLuaState(), "brake"); 166 166 } 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); 170 170 lua_setglobal(this->lua_->getInternalLuaState(), "boost"); 171 if (this->state_ & Boost)171 if (this->state_ & EngineState::Boost) 172 172 defEngineSndBoost_->play(); 173 173 else -
code/branches/cpp11_v2/src/orxonox/items/MultiStateEngine.h
r10817 r11005 41 41 { 42 42 public: 43 enumEngineState43 struct EngineState 44 44 { 45 Idle = 1,46 Normal = 2,47 Brake = 4,48 Boost = 845 static constexpr int Idle = 1; 46 static constexpr int Normal = 2; 47 static constexpr int Brake = 4; 48 static constexpr int Boost = 8; 49 49 }; 50 50 -
code/branches/cpp11_v2/src/orxonox/items/PartDestructionEvent.cc
r10262 r11005 98 98 { 99 99 switch (this->targetParam_) { 100 case shieldhealth:100 case TargetParam::shieldhealth: 101 101 this->parent_->getParent()->setShieldHealth(operate(this->parent_->getParent()->getShieldHealth())); 102 102 break; 103 case boostpower:103 case TargetParam::boostpower: 104 104 this->parent_->getParent()->setInitialBoostPower(operate(this->parent_->getParent()->getInitialBoostPower())); 105 105 break; 106 case boostpowerrate:106 case TargetParam::boostpowerrate: 107 107 this->parent_->getParent()->setBoostPowerRate(operate(this->parent_->getParent()->getBoostPowerRate())); 108 108 break; 109 case rotationthrust:109 case TargetParam::rotationthrust: 110 110 this->parent_->getParent()->setRotationThrust(operate(this->parent_->getParent()->getRotationThrust())); 111 111 break; … … 120 120 { 121 121 switch (this->targetParam_) { 122 case null:122 case TargetParam::null: 123 123 this->parent_->getParent()->getEngineByName(targetName_)->destroy(); 124 124 break; 125 case boostfactor:125 case TargetParam::boostfactor: 126 126 this->parent_->getParent()->getEngineByName(targetName_)->setBoostFactor(operate(this->parent_->getParent()->getEngineByName(targetName_)->getBoostFactor())); 127 127 break; 128 case speedfront:128 case TargetParam::speedfront: 129 129 this->parent_->getParent()->getEngineByName(targetName_)->setMaxSpeedFront(operate(this->parent_->getParent()->getEngineByName(targetName_)->getMaxSpeedFront())); 130 130 break; 131 case accelerationfront:131 case TargetParam::accelerationfront: 132 132 this->parent_->getParent()->getEngineByName(targetName_)->setAccelerationFront(operate(this->parent_->getParent()->getEngineByName(targetName_)->getAccelerationFront())); 133 133 break; … … 142 142 { 143 143 switch (this->targetParam_) { 144 case null:144 case TargetParam::null: 145 145 if (!this->parent_->getParent()->getShipPartByName(targetName_)) 146 146 return; … … 214 214 if (param == "NULL") 215 215 { 216 this->targetParam_ = null;216 this->targetParam_ = TargetParam::null; 217 217 return; 218 218 } 219 219 if (param == "boostfactor") 220 220 { 221 this->targetParam_ = boostfactor;221 this->targetParam_ = TargetParam::boostfactor; 222 222 return; 223 223 } 224 224 if (param == "speedfront") 225 225 { 226 this->targetParam_ = speedfront;226 this->targetParam_ = TargetParam::speedfront; 227 227 return; 228 228 } 229 229 if (param == "accelerationfront") 230 230 { 231 this->targetParam_ = accelerationfront;231 this->targetParam_ = TargetParam::accelerationfront; 232 232 return; 233 233 } … … 244 244 if (param == "shieldhealth") 245 245 { 246 this->targetParam_ = shieldhealth;246 this->targetParam_ = TargetParam::shieldhealth; 247 247 return; 248 248 } 249 249 if (param == "boostpower") 250 250 { 251 this->targetParam_ = boostpower;251 this->targetParam_ = TargetParam::boostpower; 252 252 return; 253 253 } 254 254 if (param == "boostpowerrate") 255 255 { 256 this->targetParam_ = boostpowerrate;256 this->targetParam_ = TargetParam::boostpowerrate; 257 257 return; 258 258 } 259 259 if (param == "rotationthrust") 260 260 { 261 this->targetParam_ = rotationthrust;261 this->targetParam_ = TargetParam::rotationthrust; 262 262 return; 263 263 } … … 271 271 if (param == "NULL") 272 272 { 273 this->targetParam_ = null;273 this->targetParam_ = TargetParam::null; 274 274 return; 275 275 } -
code/branches/cpp11_v2/src/orxonox/items/PartDestructionEvent.h
r10817 r11005 82 82 List of all allowed parameters. 83 83 */ 84 enum TargetParam84 enum class TargetParam 85 85 { 86 86 shieldhealth,
Note: See TracChangeset
for help on using the changeset viewer.