Changeset 11606 for code/branches/ScriptableController_HS17/src/orxonox/scriptablecontroller/scriptable_controller.h
- Timestamp:
- Nov 27, 2017, 4:38:50 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ScriptableController_HS17/src/orxonox/scriptablecontroller/scriptable_controller.h
r11583 r11606 18 18 { 19 19 20 /** 21 * @brief Runs a scripts on a per-level basis and handles the connection to orxonox 22 * 23 * The script is an attribute of the <Level> element with the name 'script' and should be 24 * the path to a lua script. The script will be run as soon as the player spawns. It can 25 * then register on various events and react to them. See ScriptableControllerAPI for 26 * the complete API. 27 * 28 * \sa ScriptableControllerAPI 29 */ 20 30 class ScriptableController 21 31 { 22 32 public: 33 /** 34 * @brief Run a lua script 35 * @param file_path Path to the script 36 * @return A lua error code (0 for success) 37 * 38 * Constructs an API for the script and runs it. 39 */ 23 40 int runScript(const std::string &file_path); 24 41 42 /** 43 * @brief Set the player object of the current game 44 * @param player The player 45 * 46 * The player is a special object and can perfom special actions. 47 */ 25 48 void setPlayer(PlayerInfo *player); 49 50 /** 51 * @brief Register a WorldEntity to the ScriptableController 52 * @param id The ID of the WorldEntity 53 * @param entity The WorldEntity 54 * 55 * The ScriptableController needs a list of all WorldEntity's so it can 56 * convert an ID to a WorldEntity. 57 */ 26 58 void registerWorldEntity(std::string id, WorldEntity *entity); 27 void registerControllableEntity(std::string id, ControllableEntity *entity);28 59 60 /** 61 * @brief Register a Pawn to the ScriptableController 62 * @param id The ID of the Pawn 63 * @param pawn The Pawn 64 * 65 * The ScriptableController needs a list of all Pawn's in addition to 66 * the WorldEntity's, because they have additional actions available. 67 */ 68 void registerPawn(std::string id, Pawn *pawn); 69 70 /** 71 * @brief Called when a Pawn is killed 72 * @param pawn The Pawn 73 * 74 * Called by the Pawn itself as soon as it's killed. 75 */ 76 void pawnKilled(Pawn *pawn); 77 78 /** 79 * @brief Called when a Pawn is hit 80 * @param target The hit Pawn 81 * @param source The shooting Pawn 82 * @param new_health The new health of the hit Pawn 83 * @param new_shield The new shield health of the hit Pawn 84 * 85 * Called by the Pawn itself as soon as it's hit. 86 */ 87 void pawnHit(Pawn *target, Pawn *source, double new_health, double new_shield); 88 89 /** 90 * @brief Kill a Pawn 91 * @param id The Pawn to kill 92 */ 93 void killPawn(std::string id); 94 95 /** 96 * @brief Convert an ID to a WorldEntity pointer 97 * @param id The ID of the WorldEntity 98 * @return A pointer to the WorldEntity, nullptr if it's not found 99 */ 29 100 WorldEntity *getWorldEntityByID(std::string id) const; 30 ControllableEntity *getControllableEntityByID(std::string id) const; 101 102 /** 103 * @brief Convert an ID to a Pawt pointer 104 * @param id The ID of the Pawn 105 * @return A pointer to the Pawn, nullptr if it's not found 106 */ 107 Pawn *getPawnByID(std::string id) const; 31 108 32 109 private: … … 34 111 PlayerInfo *player_; 35 112 std::map<std::string, WorldEntity*> worldEntities_; 113 std::map<std::string, Pawn*> pawns_; 114 std::map<Pawn*, std::string> pawnsReverse_; 36 115 std::map<std::string, ControllableEntity*> controllabelEntities_; 37 116 117 /** 118 * @brief Prints a human readable error message if a lua error occurs 119 * @param lua The lua state where the error occured 120 */ 38 121 void printLuaError(lua_State *lua); 39 122 };
Note: See TracChangeset
for help on using the changeset viewer.