Changeset 11855 for code/branches/ScriptableController_FS18
- Timestamp:
- Apr 12, 2018, 2:07:03 PM (7 years ago)
- Location:
- code/branches/ScriptableController_FS18
- Files:
-
- 17 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ScriptableController_FS18
- Property svn:mergeinfo changed
/code/branches/ScriptableController_HS17 (added) merged: 11462,11518-11519,11549,11552,11562,11583,11606,11638,11662,11673-11674,11684,11852,11854
- Property svn:mergeinfo changed
-
code/branches/ScriptableController_FS18/src/libraries/core/BaseObject.h
r11071 r11855 58 58 class Gametype; 59 59 class Level; 60 class ScriptableController; 60 61 61 62 /// The BaseObject is the parent of all classes representing an instance in the game. … … 191 192 192 193 static void loadAllEventStates(Element& xmlelement, XMLPort::Mode mode, BaseObject* object, Identifier* identifier); 194 193 195 194 196 protected: -
code/branches/ScriptableController_FS18/src/libraries/tools/Timer.cc
r11071 r11855 158 158 } 159 159 160 Timer::Timer(float interval, bool bLoop, std::function<void ()> func, bool bKillAfterCall) 161 { 162 this->init(); 163 RegisterObject(Timer); 164 165 this->setTimer(interval, bLoop, func, bKillAfterCall); 166 } 167 160 168 /** 161 169 @brief Initializes the Timer … … 193 201 this->executor_ = executor; 194 202 this->bActive_ = true; 203 this->isStdFunction_ = false; 195 204 196 205 this->time_ = this->interval_; 197 206 this->bKillAfterCall_ = bKillAfterCall; 198 207 199 executor->getFunctor()->setSafeMode(true); 208 if(executor != nullptr) 209 executor->getFunctor()->setSafeMode(true); 210 } 211 212 void Timer::setTimer(float interval, bool bLoop, std::function<void ()> func, bool bKillAfterCall) 213 { 214 // Without the cast, the call would be ambiguous, because nullptr is castable to 215 // both, ExecutorPtr and std::function. 216 this->setTimer(interval, bLoop, static_cast<ExecutorPtr>(nullptr), bKillAfterCall); 217 this->function_ = func; 218 this->isStdFunction_ = true; 200 219 } 201 220 … … 207 226 bool temp = this->bKillAfterCall_; // to avoid errors with bKillAfterCall_=false and an exutors which destroy the timer 208 227 209 (*this->executor_)(); 228 if(this->isStdFunction_) 229 this->function_(); 230 else 231 (*this->executor_)(); 210 232 211 233 if (temp) -
code/branches/ScriptableController_FS18/src/libraries/tools/Timer.h
r11071 r11855 108 108 109 109 Timer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false); 110 Timer(float interval, bool bLoop, std::function<void (void)> func, bool bKillAfterCall = false); 110 111 111 112 void setTimer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false); 113 void setTimer(float interval, bool bLoop, std::function<void (void)> func, bool bKillAfterCall = false); 112 114 113 115 void run(); … … 153 155 154 156 ExecutorPtr executor_; //!< The executor of the function that will be called when the time expires 157 std::function<void (void)> function_; 155 158 159 bool isStdFunction_; 156 160 long long interval_; //!< The time-interval in micro seconds 157 161 bool bLoop_; //!< If true, the executor gets called every @a interval seconds -
code/branches/ScriptableController_FS18/src/orxonox/CMakeLists.txt
r11704 r11855 51 51 ADD_SUBDIRECTORY(items) 52 52 ADD_SUBDIRECTORY(overlays) 53 ADD_SUBDIRECTORY(scriptablecontroller) 53 54 ADD_SUBDIRECTORY(sound) 54 55 ADD_SUBDIRECTORY(weaponsystem) -
code/branches/ScriptableController_FS18/src/orxonox/Level.cc
r11071 r11855 42 42 #include "overlays/OverlayGroup.h" 43 43 #include "LevelManager.h" 44 #include "scriptablecontroller/scriptable_controller.h" 44 45 45 46 namespace orxonox … … 56 57 this->xmlfilename_ = this->getFilename(); 57 58 this->xmlfile_ = nullptr; 59 this->controller_.reset(new ScriptableController()); 58 60 } 59 61 … … 78 80 XMLPortParam(Level, "plugins", setPluginsString, getPluginsString, xmlelement, mode); 79 81 XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype"); 82 83 XMLPortParamLoadOnly(Level, "script", setScript, xmlelement, mode); 80 84 81 85 XMLPortObject(Level, MeshLodInformation, "lodinformation", addLodInfo, getLodInfo, xmlelement, mode); -
code/branches/ScriptableController_FS18/src/orxonox/Level.h
r11071 r11855 42 42 namespace orxonox 43 43 { 44 class ScriptableController; 45 44 46 class _OrxonoxExport Level : public BaseObject, public Synchronisable, public Context 45 47 { … … 54 56 55 57 MeshLodInformation* getLodInfo(std::string meshName) const; 58 59 inline ScriptableController *getScriptableController(void) 60 { return this->controller_.get(); } 61 62 inline const std::string &getScript(void) 63 { return this->level_script_; } 56 64 57 65 … … 78 86 void networkcallback_applyXMLFile(); 79 87 88 inline void setScript(const std::string &script) 89 { this->level_script_ = script; } 90 91 80 92 std::string pluginsString_; 81 93 std::list<PluginReference*> plugins_; 82 83 94 std::string gametype_; 84 95 std::string xmlfilename_; … … 86 97 std::list<BaseObject*> objects_; 87 98 std::map<std::string,MeshLodInformation*> lodInformation_; 99 100 std::unique_ptr<ScriptableController> controller_; 101 std::string level_script_; 88 102 }; 89 103 } -
code/branches/ScriptableController_FS18/src/orxonox/infos/GametypeInfo.cc
r11099 r11855 43 43 #include "interfaces/GametypeMessageListener.h" 44 44 #include "interfaces/NotificationListener.h" 45 #include "scriptablecontroller/scriptable_controller.h" 46 #include "Level.h" 45 47 46 48 #include "PlayerInfo.h" … … 76 78 this->spawned_ = false; 77 79 this->readyToSpawn_ = false; 80 this->isFirstSpawn_ = true; 78 81 79 82 this->registerVariables(); … … 310 313 { 311 314 if(this->hasStarted() && !this->hasEnded()) 312 313 315 this->setSpawnedHelper(player, true); 316 } 317 318 // TODO We might want to handle the subsequent spawns as well somehow 319 if(player->isHumanPlayer() && player->isLocalPlayer() && this->isFirstSpawn_) 320 { 321 this->isFirstSpawn_ = false; 322 this->getLevel()->getScriptableController()->setPlayer(player); 323 324 // This handles paths relative to the 'level' directory 325 std::string script = this->getLevel()->getScript(); 326 if(script.at(0) != '/') 327 script = "../levels/" + script; // Not very dynamic 328 this->getLevel()->getScriptableController()->runScript(script); 314 329 } 315 330 } -
code/branches/ScriptableController_FS18/src/orxonox/infos/GametypeInfo.h
r11720 r11855 83 83 inline bool isStartCountdownRunning() const 84 84 { return this->bStartCountdownRunning_; } 85 85 86 void changedStartCountdownRunning(void); // Is called when the start countdown has been either started or stopped. 86 87 … … 166 167 bool spawned_; //!< Whether the local Player is currently spawned. 167 168 bool readyToSpawn_; //!< Whether the local Player is ready to spawn. 169 bool isFirstSpawn_; 168 170 }; 169 171 } -
code/branches/ScriptableController_FS18/src/orxonox/infos/HumanPlayer.cc
r11071 r11855 38 38 #include "gametypes/Gametype.h" 39 39 #include "overlays/OverlayGroup.h" 40 #include "Level.h" 41 #include "scriptablecontroller/scriptable_controller.h" 40 42 41 43 namespace orxonox -
code/branches/ScriptableController_FS18/src/orxonox/items/ShipPart.cc
r11099 r11855 42 42 #include "items/PartDestructionEvent.h" 43 43 #include "chat/ChatManager.h" 44 #include "Level.h" 45 #include "scriptablecontroller/scriptable_controller.h" 44 46 45 47 … … 215 217 } 216 218 } 219 220 // This is a bit hacky, but it takes away damage control from the pawn, so it has to handle 221 // that as well. 222 this->getLevel()->getScriptableController()->pawnHit(parent_, originator, parent_->getHealth(), parent_->getShieldHealth()); 223 217 224 if (this->health_ < 0) 218 225 this->death(); -
code/branches/ScriptableController_FS18/src/orxonox/worldentities/ControllableEntity.cc
r11071 r11855 39 39 40 40 #include "Scene.h" 41 #include "Level.h" 41 42 #include "infos/PlayerInfo.h" 42 43 #include "controllers/NewHumanController.h" … … 67 68 this->camera_ = nullptr; 68 69 this->xmlcontroller_ = nullptr; 69 //this->controller_ = nullptr;70 70 this->reverseCamera_ = nullptr; 71 71 this->bDestroyWhenPlayerLeft_ = false; -
code/branches/ScriptableController_FS18/src/orxonox/worldentities/ControllableEntity.h
r11071 r11855 175 175 inline int getTeam() const 176 176 { return this->team_; } 177 177 178 178 179 protected: -
code/branches/ScriptableController_FS18/src/orxonox/worldentities/MobileEntity.cc
r11071 r11855 36 36 37 37 #include "Scene.h" 38 #include "Level.h" 39 #include "scriptablecontroller/scriptable_controller.h" 38 40 39 41 namespace orxonox … … 72 74 this->setAngularVelocity(rotationAxis.normalisedCopy() * rotationRate.valueRadians()); 73 75 } 76 77 if(!this->id_.empty() && this->getLevel() != nullptr) 78 this->getLevel()->getScriptableController()->registerMobileEntity(this->id_, this); 74 79 } 75 80 -
code/branches/ScriptableController_FS18/src/orxonox/worldentities/WorldEntity.cc
r11083 r11855 44 44 #include "core/XMLPort.h" 45 45 #include "Scene.h" 46 #include "Level.h" 46 47 #include "collisionshapes/WorldEntityCollisionShape.h" 48 #include "scriptablecontroller/scriptable_controller.h" 47 49 48 50 namespace orxonox … … 79 81 this->parentID_ = OBJECTID_UNKNOWN; 80 82 this->bDeleteWithParent_ = true; 83 this->id_ = -1; 81 84 82 85 this->node_->setPosition(Vector3::ZERO); … … 160 163 XMLPortParamTemplate(WorldEntity, "scale3D", setScale3D, getScale3D, xmlelement, mode, const Vector3&); 161 164 XMLPortParam (WorldEntity, "scale", setScale, getScale, xmlelement, mode); 165 XMLPortParamLoadOnly(WorldEntity, "id", setID, xmlelement, mode); 162 166 XMLPortParamLoadOnly(WorldEntity, "lookat", lookAt_xmlport, xmlelement, mode); 163 167 XMLPortParamLoadOnly(WorldEntity, "direction", setDirection_xmlport, xmlelement, mode); … … 181 185 // Attached collision shapes 182 186 XMLPortObject(WorldEntity, CollisionShape, "collisionShapes", attachCollisionShape, getAttachedCollisionShape, xmlelement, mode); 187 188 if(!this->id_.empty() && this->getLevel() != nullptr) 189 this->getLevel()->getScriptableController()->registerWorldEntity(this->id_, this); 183 190 } 184 191 -
code/branches/ScriptableController_FS18/src/orxonox/worldentities/WorldEntity.h
r11099 r11855 110 110 virtual void changedActivity(void) override; 111 111 virtual void changedVisibility(void) override; 112 113 inline std::string getID(void) 114 { return this->id_; } 115 116 inline void setID(std::string id) 117 { this->id_ = id; } 112 118 113 119 virtual void setPosition(const Vector3& position) = 0; … … 442 448 443 449 btRigidBody* physicalBody_; //!< Bullet rigid body. Everything physical is applied to this instance. 450 std::string id_; //!< Used by the ScriptableController to identify objects 444 451 445 452 private: -
code/branches/ScriptableController_FS18/src/orxonox/worldentities/pawns/Pawn.cc
r11783 r11855 50 50 #include "sound/WorldSound.h" 51 51 #include "core/object/ObjectListIterator.h" 52 #include "Level.h" 53 #include "scriptablecontroller/scriptable_controller.h" 52 54 53 55 #include "controllers/FormationController.h" … … 160 162 161 163 XMLPortParam ( RadarViewable, "radarname", setRadarName, getRadarName, xmlelement, mode ); 164 165 if(!this->id_.empty() && this->getLevel() != nullptr) 166 this->getLevel()->getScriptableController()->registerPawn(this->id_, this); 162 167 } 163 168 … … 282 287 { 283 288 // Health-damage cannot be absorbed by shields. 284 // Shield-damage only reduces shield health. 289 // Shield-damage only reduces shield health. 285 290 // Normal damage can be (partially) absorbed by shields. 286 291 … … 302 307 this->setHealth(this->health_ - (damage - shielddamage) - healthdamage); 303 308 } 309 this->getLevel()->getScriptableController()->pawnHit(this, originator, this->health_, this->shieldHealth_); 304 310 305 311 this->lastHitOriginator_ = originator; … … 402 408 } 403 409 } 410 411 this->getLevel()->getScriptableController()->pawnKilled(this); 404 412 } 405 413 void Pawn::goWithStyle() … … 625 633 { 626 634 // delete all debug models 627 for(Model* model : debugWeaponSlotModels_) 635 for(Model* model : debugWeaponSlotModels_) 628 636 { 629 637 model->destroy();
Note: See TracChangeset
for help on using the changeset viewer.