Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 27, 2017, 4:38:50 PM (7 years ago)
Author:
kohlia
Message:

Pawn killing works too now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ScriptableController_HS17/src/orxonox/scriptablecontroller/scriptable_controller.h

    r11583 r11606  
    1818{
    1919
     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 */
    2030class ScriptableController
    2131{
    2232public:
     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     */
    2340    int runScript(const std::string &file_path);
    2441
     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     */
    2548    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     */
    2658    void registerWorldEntity(std::string id, WorldEntity *entity);
    27     void registerControllableEntity(std::string id, ControllableEntity *entity);
    2859
     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     */
    29100    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;
    31108
    32109private:
     
    34111    PlayerInfo *player_;
    35112    std::map<std::string, WorldEntity*> worldEntities_;
     113    std::map<std::string, Pawn*> pawns_;
     114    std::map<Pawn*, std::string> pawnsReverse_;
    36115    std::map<std::string, ControllableEntity*> controllabelEntities_;
    37116
     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     */
    38121    void printLuaError(lua_State *lua);
    39122};
Note: See TracChangeset for help on using the changeset viewer.