Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 14, 2017, 4:04:14 PM (7 years ago)
Author:
kohlia
Message:

The ScriptableController should work now. A demo level called scriptableControllerTest exists as well.

File:
1 edited

Legend:

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

    r11662 r11673  
    5050    }
    5151
    52     // Remeber the api
     52    // Remember the api
    5353    this->apis_.push_back(std::unique_ptr<ScriptableControllerAPI>(api));
    5454
     
    7373void ScriptableController::registerPawn(std::string id, Pawn *pawn)
    7474{
    75     this->worldEntities_[id] = pawn;
    7675    this->pawns_[id] = pawn;
    7776    this->pawnsReverse_[pawn] = id;
     
    8786    }
    8887
    89     for(auto &api : this->apis_)
    90         api->pawnKilled(pawn_id_iter->second, pawn);
    91 
     88    // The ID of the pawn should already be invalid when we call the callback
     89    std::string id = pawn_id_iter->second;
    9290    this->pawns_.erase(pawn_id_iter->second);
    9391    this->pawnsReverse_.erase(pawn_id_iter);
     92
     93    for(auto &api : this->apis_)
     94        api->pawnKilled(id, pawn);
    9495}
    9596
     
    110111}
    111112
    112 void ScriptableController::killPawn(std::string id)
    113 {
    114     auto pawn = this->getPawnByID(id);
    115     if(pawn == nullptr)
    116     {
    117         orxout(user_warning) << "Tried to destroy unknown pawn " << id << std::endl;
    118         return;
    119     }
    120 
    121     pawn->kill();
    122 }
    123 
    124113WorldEntity *ScriptableController::getWorldEntityByID(std::string id) const
    125114{
     
    138127    auto entity = this->mobileEntities_.find(id);
    139128    return entity != this->mobileEntities_.end() ? entity->second : nullptr;
    140 
    141129}
    142130
Note: See TracChangeset for help on using the changeset viewer.