Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 14, 2016, 4:03:16 PM (9 years ago)
Author:
plehmann
Message:

changed the NewScriptController and Task classes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.cc

    r11165 r11167  
    6161
    6262
    63         /* Set default values for all variables */
    64         /* - pointers to zero */
     63        // Set default values for all variables
     64        // - pointers to zero
    6565        this->player_ = nullptr;
    6666        this->entity_ = nullptr;
    6767
    68         /* - times */
     68        // - times
    6969        this->scTime_ = 0.0f;
     70
     71        //taskList_->push(new DebugTask);
    7072
    7173    }
    7274
     75
     76
    7377    void NewScriptController::takeControl(int ctrlid)
    7478    {
    75         /* Output some debugging information */
     79        // Output some debugging information
    7680        orxout(verbose) << "NewScriptController: Taking control" << endl;
    7781        orxout(verbose) << "This-pointer: " << this << endl;
    7882
    7983
    80         /* Store the entity pointer in a private variable */
     84        // Store the entity pointer in a private variable
    8185        this->entity_ = this->player_->getControllableEntity();
    8286        assert(this->entity_);
     87
     88        this->ctrlid_ = ctrlid;
     89        if (ctrlid_ == 0)
     90        {
     91          ctrlid_ = 1;
     92        }
    8393         
    84         /* Add the controller here to this entity. Apparently this still leaves
    85          * any preexisting human controllers in place.
    86          */
     94        // Add the controller here to this entity. Apparently this still leaves
     95        // any preexisting human controllers in place.
     96         
    8797        this->entity_->setDestroyWhenPlayerLeft(false);
    8898        this->player_->stopTemporaryControl();
     
    98108    void NewScriptController::tick(float dt)
    99109    {
    100         /* Call the tick function of the classes we derive from */
    101         SUPER(ScriptController, tick, dt);
     110        // Call the tick function of the classes we derive from
     111        SUPER(NewScriptController, tick, dt);
    102112
    103         /* If this controller has no entity entry, do nothing */
     113/*
     114        // If this controller has no entity entry, do nothing
    104115        if( !(this->entity_) ) return;
    105116
    106         /* See if time has come for the next event to be run */
     117        // See if time has come for the next event to be run
    107118        if(this->taskList_->size() > 0 && this->taskList_->front().getStartTime() <= scTime_)
    108         { /* Execute the next event on the list */
     119        { // Execute the next event on the list
    109120          activeTasks_->push_back(taskList_->front());
    110121          taskList_->pop();
    111122        }
    112123
    113         /* Update the local timers in this object */
     124        // Update the local timers in this object
    114125        scTime_ += dt;
    115126
    116         /* tick active tasks and delete completed tasks */
     127        // tick active tasks and delete completed tasks
    117128        for(std::vector<Task>::iterator it = activeTasks_->begin(); it != activeTasks_->end(); it++)
    118129        {
     
    125136
    126137        }
    127 
     138*/
    128139    }
    129140
     
    134145    }
    135146
     147    void NewScriptController::debugOut()
     148    {
     149      orxout() << "NewScriptController: Taking control" << endl;
     150    }
     151
     152    NewScriptController* NewScriptController::getNewScriptController()
     153    {
     154      /* Output a message that confirms this function was called */
     155      orxout() << "Great success!" << std::endl;
     156
     157      /* Debugging: print all the scriptcontroller object pointers */
     158      for(NewScriptController* controller : ObjectList<NewScriptController>())
     159      { orxout() << "Have object in list: " << controller << endl; }
     160
     161      /* Find the first one with a nonzero ID */
     162      for(NewScriptController* controller : ObjectList<NewScriptController>())
     163      {
     164        // TODO: do some selection here. Currently just returns the first one
     165        if( controller->getID() > 0 )
     166        { orxout() << "Controller to return: " << controller << endl;
     167          return controller;
     168        }
     169     
     170      }
     171      return nullptr;
     172    }
    136173
    137174}
Note: See TracChangeset for help on using the changeset viewer.