Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11183


Ignore:
Timestamp:
May 12, 2016, 3:28:30 PM (8 years ago)
Author:
plehmann
Message:

moved the task classes to the scriptTasks folder. modified the NewScriptController to execute tasks when their time has come modified the tasks so that they tell the controller when they are done

Location:
code/branches/plehmannFS16
Files:
8 added
6 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/plehmannFS16/data/gui/scripts/testscript.lua

    r11178 r11183  
    2323if ctrl ~= nil then
    2424
    25     --ctrl:printDebug()
    26   --ctrl:debugOut(1000)
    27   --ctrl:stringOut(10000, "hello")
     25  ctrl:printDebug()
     26  ctrl:debugOut(5)
     27  ctrl:stringOut(3, "hello")
    2828  --ctrl:eventScheduler("mal", xl,yl,zl, xl,yl,zl, 10)
    2929  -- ctrl:eventScheduler("ral", xl, yl, zl, 3, 3000, 0, math.pi)
  • code/branches/plehmannFS16/src/orxonox/controllers/CMakeLists.txt

    r11178 r11183  
    1919  MasterController.cc
    2020  NewScriptController.cc
    21   Task.cc
    22   DebugTask.cc
    23   stringOutTask.cc
    2421)
     22ADD_SUBDIRECTORY(scriptTasks)
  • code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.cc

    r11178 r11183  
    4444#include "NewScriptController.h"
    4545
    46 #include "DebugTask.h"
    47 #include "stringOutTask.h"
    48 #include "Task.h"
     46#include "scriptTasks/DebugTask.h"
     47#include "scriptTasks/stringOutTask.h"
     48#include "scriptTasks/Task.h"
    4949#include "infos/PlayerInfo.h"
    5050#include "core/CoreIncludes.h"
     
    7171
    7272        this->context_ = context;
     73
     74       
    7375    }
    7476
     
    8789
    8890        this->ctrlid_ = ctrlid;
    89         if (ctrlid_ == 0)
    90         {
    91           ctrlid_ = 1;
     91        if (this->ctrlid_ == 0)
     92        {
     93          this->ctrlid_ = 1;
    9294        }
    9395         
     
    128130        }*/
    129131
    130         if(taskQueue_.front() != nullptr)
    131         {
    132           orxout() << taskQueue_.front() << endl;
    133           //taskQueue_.front()->tick(dt);
    134         }
     132        if(this->taskList_.size() != 0)
     133        {
     134
     135          orxout() << this->scTime_ << endl;
     136
     137          if(this->taskList_.front()->getStartTime() < this->scTime_)
     138          {
     139             activeTasks_.push_back(this->taskList_.front());
     140             this->taskList_.pop_front();
     141          }
     142        }
     143        else
     144        {
     145          //orxout() << "no tasks in taskList_" << endl;
     146        }
     147       
     148        for (std::vector<Task*>::iterator it = activeTasks_.begin(); it != activeTasks_.end(); it++)
     149        {
     150          if( !((*it)->update(dt)) )
     151          {
     152            delete (*it); // delete the task that was created with new
     153            activeTasks_.erase(it);
     154            it--; // set back the iterator so we continue with the next element and not with the one after that
     155          }
     156        }
     157
     158
     159        scTime_ += dt;
    135160    }
    136161
     
    145170      DebugTask* task = new DebugTask(context_);
    146171      task->initialize(startTime);
    147       taskQueue_.push(task);
     172
     173      if(taskList_.empty())
     174      {
     175        taskList_.push_front(task);
     176      }
     177
     178      else
     179      {
     180        for (std::list<Task*>::iterator it = taskList_.begin(); it != taskList_.end(); it++) // insert sorted by starttime
     181        {
     182          orxout() << taskList_.empty() << endl;
     183
     184          if(task->getStartTime() < (*it)->getStartTime() )
     185          {
     186            taskList_.insert(it, task);
     187          }
     188        }
     189      }
    148190    }
    149191
     
    152194      stringOutTask* task = new stringOutTask(context_);
    153195      task->initialize(startTime, output);
    154       taskQueue_.push(task);
     196
     197      if(taskList_.empty())
     198      {
     199        taskList_.push_front(task);
     200      }
     201
     202      else
     203      {
     204        for (std::list<Task*>::iterator it = taskList_.begin(); it != taskList_.end(); it++) // insert sorted by starttime
     205        {
     206          orxout() << taskList_.empty() << endl;
     207
     208          if(task->getStartTime() < (*it)->getStartTime() )
     209          {
     210            taskList_.insert(it, task);
     211          }
     212        }
     213      }
    155214    }
    156215
  • code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.h

    r11178 r11183  
    3030#define _NewScriptController_H__
    3131
    32 #include "DebugTask.h"
    33 #include "stringOutTask.h"
    34 #include "Task.h"
     32#include "scriptTasks/DebugTask.h"
     33#include "scriptTasks/stringOutTask.h"
     34#include "scriptTasks/Task.h"
    3535#include "OrxonoxPrereqs.h"                 /* die ganzen tolua, kopiert aus Dock.h*/
    3636#include "ArtificialController.h"
     
    8484            int ctrlid_;
    8585
    86             // List of events to walk through
    87             std::queue<Task*> taskQueue_;
     86            // List of events to walk through sorted by starting times
     87            std::list<Task*> taskList_;
    8888
    8989
Note: See TracChangeset for help on using the changeset viewer.