[Orxonox-commit 6522] r11165 - code/branches/plehmannFS16/src/orxonox/controllers

plehmann at orxonox.net plehmann at orxonox.net
Thu Apr 14 13:24:08 CEST 2016


Author: plehmann
Date: 2016-04-14 13:24:08 +0200 (Thu, 14 Apr 2016)
New Revision: 11165

Added:
   code/branches/plehmannFS16/src/orxonox/controllers/DebugTask.cc
   code/branches/plehmannFS16/src/orxonox/controllers/DebugTask.h
   code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.cc
   code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.h
   code/branches/plehmannFS16/src/orxonox/controllers/Task.cc
   code/branches/plehmannFS16/src/orxonox/controllers/Task.h
Modified:
   code/branches/plehmannFS16/src/orxonox/controllers/CMakeLists.txt
Log:
added new files for newScriptController
--This lines, and those below, will be ignored--

M    src/orxonox/controllers/CMakeLists.txt
A    src/orxonox/controllers/DebugTask.cc
A    src/orxonox/controllers/DebugTask.h
A    src/orxonox/controllers/NewScriptController.cc
A    src/orxonox/controllers/NewScriptController.h
A    src/orxonox/controllers/Task.cc
A    src/orxonox/controllers/Task.h


Modified: code/branches/plehmannFS16/src/orxonox/controllers/CMakeLists.txt
===================================================================
--- code/branches/plehmannFS16/src/orxonox/controllers/CMakeLists.txt	2016-04-14 11:11:00 UTC (rev 11164)
+++ code/branches/plehmannFS16/src/orxonox/controllers/CMakeLists.txt	2016-04-14 11:24:08 UTC (rev 11165)
@@ -18,4 +18,6 @@
   FlyingController.cc
   FightingController.cc
   MasterController.cc
+  NewScriptController.cc
+  Task.cc
 )

Added: code/branches/plehmannFS16/src/orxonox/controllers/DebugTask.cc
===================================================================
--- code/branches/plehmannFS16/src/orxonox/controllers/DebugTask.cc	                        (rev 0)
+++ code/branches/plehmannFS16/src/orxonox/controllers/DebugTask.cc	2016-04-14 11:24:08 UTC (rev 11165)
@@ -0,0 +1,54 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Paul Lehmann
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#include "DebugTask.h"
+
+#include "infos/PlayerInfo.h"
+#include "controllers/ArtificialController.h"
+#include "tools/interfaces/Tickable.h"
+
+namespace orxonox
+{
+   
+    RegisterClass(DebugTask);
+
+    DebugTask::DebugTask() : isRunning_(false)
+    {
+        RegisterObject(DebugTask);
+    }
+    DebugTask::DebugTask(float startTime) : isRunning_(false)
+    {
+        RegisterObject(DebugTask);
+        startTime_ = startTime;
+    }
+
+
+    
+
+}
\ No newline at end of file

Added: code/branches/plehmannFS16/src/orxonox/controllers/DebugTask.h
===================================================================
--- code/branches/plehmannFS16/src/orxonox/controllers/DebugTask.h	                        (rev 0)
+++ code/branches/plehmannFS16/src/orxonox/controllers/DebugTask.h	2016-04-14 11:24:08 UTC (rev 11165)
@@ -0,0 +1,52 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Paul Lehmann
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _DebugTask_H__
+#define _DebugTask_H__
+
+#include "infos/PlayerInfo.h"
+#include "controllers/ArtificialController.h"
+#include "tools/interfaces/Tickable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Task : public Task
+    {
+        public:
+            DebugTask();
+            DebugTask(float startTime)
+            virtual ~Task();
+
+            virtual void tick(float dt) override;
+
+        private:
+
+    };
+}
+
+#endif /* _DebugTask_H__ */

Added: code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.cc
===================================================================
--- code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.cc	                        (rev 0)
+++ code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.cc	2016-04-14 11:24:08 UTC (rev 11165)
@@ -0,0 +1,137 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Paul Lehmann
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+ /*
+  * Currently available lua commands:
+  *
+  * IMPORTANT: ALL COMMANDS DO REQUIRE 7 PARAMETERS TO BE PROVIDED. FILL UP WITH ZEROES IN UNIMPORTANT PLACES.
+  *
+  * Command             | Abbreviation | Parameter 1          | '' 2     | '' 3    | '' 4                 | '' 5     | '' 6     | '' 7
+  *
+  * "Move And Look"     | mal          | GoTo X Coordinate    |  '' Y ''  | '' Z '' | LookAt X Coordinate  |  '' Y '' |  '' Y '' | Duration
+  * "Rotate And Look"   | ral          | GoTo X Coordinate    |  '' Y ''  | '' Z '' | Axis (1=x, 2=y, 3=z) |     -    |     -    | Duration
+  * "Spiral"            | spi          | GoTo X Coordinate    |  '' Y ''  | '' Z '' |          -           |     -    |     -    | Duration
+  * "Transition Look"   | chl          | From X Coordinate    |  '' Y ''  | '' Z '' | To X Coordinate      |  '' Y '' |  '' Y '' | Duration
+  * "rotate round X crd"| rotX         | anchor coordinate    | angle(rad)|    -    |                      |          |          | Duration
+  * "Idle (Do nothing)" | idle         | Duration
+  */
+
+#include "NewScriptController.h"
+
+#include "Task.h"
+#include "infos/PlayerInfo.h"
+#include "core/CoreIncludes.h"
+#include "worldentities/ControllableEntity.h"
+#include "core/LuaState.h"
+#include "core/LuaState.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    RegisterClass(NewScriptController);
+
+    NewScriptController::NewScriptController(Context* context) : ArtificialController(context)
+    {
+        RegisterObject(NewScriptController);
+
+
+        /* Set default values for all variables */
+        /* - pointers to zero */
+        this->player_ = nullptr;
+        this->entity_ = nullptr;
+
+        /* - times */
+        this->scTime_ = 0.0f;
+
+    }
+
+    void NewScriptController::takeControl(int ctrlid)
+    {
+        /* Output some debugging information */
+        orxout(verbose) << "NewScriptController: Taking control" << endl;
+        orxout(verbose) << "This-pointer: " << this << endl; 
+
+
+        /* Store the entity pointer in a private variable */
+        this->entity_ = this->player_->getControllableEntity();
+        assert(this->entity_);
+         
+        /* Add the controller here to this entity. Apparently this still leaves
+         * any preexisting human controllers in place. 
+         */
+        this->entity_->setDestroyWhenPlayerLeft(false);
+        this->player_->stopTemporaryControl();
+        this->entity_->setController(this);
+        this->setControllableEntity(this->entity_);
+        this->entity_->mouseLook();
+        this->entity_->setVisible(false);
+        
+        // TODO take the human Controllers control  dont forget to give it back in the destructor
+    }
+
+
+    void NewScriptController::tick(float dt)
+    {
+        /* Call the tick function of the classes we derive from */
+        SUPER(ScriptController, tick, dt);
+
+        /* If this controller has no entity entry, do nothing */
+        if( !(this->entity_) ) return;
+
+        /* See if time has come for the next event to be run */
+        if(this->taskList_->size() > 0 && this->taskList_->front().getStartTime() <= scTime_)
+        { /* Execute the next event on the list */
+          activeTasks_->push_back(taskList_->front());
+          taskList_->pop();
+        }
+
+        /* Update the local timers in this object */
+        scTime_ += dt;
+
+        /* tick active tasks and delete completed tasks */
+        for(std::vector<Task>::iterator it = activeTasks_->begin(); it != activeTasks_->end(); it++)
+        {
+          it->tick(dt);
+          if ( !(it->getIsRunning()) )
+          {
+            activeTasks_->erase(it);
+            it--;
+          }
+
+        }
+
+    }
+
+
+    void NewScriptController::createAndAddTask(Task newTask)
+    {
+      taskList_->push(newTask);
+    }
+
+
+}

Added: code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.h
===================================================================
--- code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.h	                        (rev 0)
+++ code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.h	2016-04-14 11:24:08 UTC (rev 11165)
@@ -0,0 +1,86 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Paul Lehmann
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _NewScriptController_H__
+#define _NewScriptController_H__
+
+#include "Task.h"
+#include "OrxonoxPrereqs.h"                 /* die ganzen tolua, kopiert aus Dock.h*/
+#include "ArtificialController.h"
+#include "core/EventIncludes.h"
+
+
+
+namespace orxonox  // tolua_export
+{  // tolua_export
+
+
+
+    class _OrxonoxExport NewScriptController // tolua_export 
+       : public ArtificialController, public Tickable
+    {  // tolua_export
+        public:
+            NewScriptController(Context* context);
+            virtual ~NewScriptController() { }
+
+            void takeControl(int ctrlid);
+            void setPlayer(PlayerInfo* player) { this->player_ = player; }
+           
+            virtual void tick(float dt) override;
+
+            // LUA interface
+            // tolua_begin 
+
+            void createAndAddTask(Task newTask);
+
+        private:
+            /* Information about the player that this ScriptController will
+             * control */
+            /* - Player pointer */
+            PlayerInfo* player_;
+
+            /* - Entity pointer, this is for convenience and will be the same as 
+             *   player_->getControllableEntity() 
+             */
+            ControllableEntity* entity_;
+
+            /* List of events to walk through */
+            std::queue<Task>* taskList_;
+
+
+            /*List of Tasks currently active */
+            std::vector<Task>* activeTasks_;
+
+            /* Time since the creation of this ScriptController object */
+            float scTime_;  
+
+
+    };// tolua_export
+} // tolua_export
+
+#endif /* _NewScriptController_H__ */
\ No newline at end of file

Added: code/branches/plehmannFS16/src/orxonox/controllers/Task.cc
===================================================================
--- code/branches/plehmannFS16/src/orxonox/controllers/Task.cc	                        (rev 0)
+++ code/branches/plehmannFS16/src/orxonox/controllers/Task.cc	2016-04-14 11:24:08 UTC (rev 11165)
@@ -0,0 +1,48 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Paul Lehmann
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#include "Task.h"
+
+#include "infos/PlayerInfo.h"
+#include "controllers/ArtificialController.h"
+#include "tools/interfaces/Tickable.h"
+
+namespace orxonox
+{
+   
+    RegisterClass(Task);
+
+    Task::Task() : isRunning_(false)
+    {
+        RegisterObject(Task);
+    }
+
+    
+
+}
\ No newline at end of file

Added: code/branches/plehmannFS16/src/orxonox/controllers/Task.h
===================================================================
--- code/branches/plehmannFS16/src/orxonox/controllers/Task.h	                        (rev 0)
+++ code/branches/plehmannFS16/src/orxonox/controllers/Task.h	2016-04-14 11:24:08 UTC (rev 11165)
@@ -0,0 +1,64 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Paul Lehmann
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Task_H__
+#define _Task_H__
+
+#include "infos/PlayerInfo.h"
+#include "controllers/ArtificialController.h"
+#include "tools/interfaces/Tickable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Task : public Tickable
+    {
+        public:
+            Task();
+            virtual ~Task();
+
+            virtual void tick(float dt) override;
+
+            void setIsRunning(bool shouldBeRunning)
+                {isRunning_ = shouldBeRunning;}
+
+            bool getIsRunning()
+                {return isRunning_;}
+
+            float getStartTime()
+                {return startTime_;}
+
+        private:
+
+        	bool isRunning_;
+
+        	float startTime_;
+
+    };
+}
+
+#endif /* _Task_H__ */




More information about the Orxonox-commit mailing list