Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ScriptableController/src/orxonox/controllers/ScriptController.h @ 10065

Last change on this file since 10065 was 10065, checked in by smerkli, 10 years ago

Improved controller, "move and look" is now scriptable.

File size: 3.8 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#ifndef _ScriptController_H__
30#define _ScriptController_H__
31
32#include "OrxonoxPrereqs.h"                 /* die ganzen tolua, kopiert aus Dock.h*/
33#include "ArtificialController.h"
34#include "core/EventIncludes.h"
35
36
37
38namespace orxonox  // tolua_export
39{  // tolua_export
40
41    struct event
42    {   
43        std::string fctName;
44        float x1;
45        float y1;
46        float z1;
47
48        float x2;
49        float y2;
50        float z2;
51
52        float duration;
53
54        float eventTime;
55
56    }; 
57
58    class _OrxonoxExport ScriptController // tolua_export
59       : public ArtificialController, public Tickable
60    {  // tolua_export
61        public:
62            ScriptController(Context* context);
63
64            virtual ~ScriptController() { }
65
66            //virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
67           
68            void takeControl(int ctrlid);
69            void setPlayer(PlayerInfo* player) { this->player_ = player; }
70           
71            virtual void tick(float dt);
72
73            // LUA interface
74            // tolua_begin
75            void moveAndLook(float xm, float ym, float zm,
76              float xl, float yl, float zl, float t);
77
78            void eventScheduler(std::string instruction, 
79              float x1, float y1, float z1, 
80              float x2, float y2, float z2, 
81              float duration, float executionTime);
82
83            static ScriptController* getScriptController();
84
85            int getID() { return ctrlid_; }
86
87            // tolua_end
88            const Vector3& getPosition();
89
90            void execute(event ev);
91
92        private:
93            /* Information about the player that this ScriptController will
94             * control */
95            /* - Player pointer */
96            PlayerInfo* player_;
97
98            /* - Entity pointer, this is for convenience and will be the same as
99             *   player_->getControllableEntity()
100             */
101            ControllableEntity* entity_;
102
103            /* Controller ID, defaults to 0 and is set using takeControl() */
104            int ctrlid_;
105
106            /* List of events to walk through */
107            std::vector<event> eventList;
108            unsigned int eventno;
109
110            /* Time since the creation of this ScriptController object */
111            float scTime; 
112
113            /* Boolean that specifies whether we're processing an event right
114             * now */
115            bool processing;
116
117            /* Data about the point to go to and what to look at */
118            /* - Target position */
119            Vector3 target;
120
121            /* - Time it should take to get there */
122            float timeToTarget;
123
124            /* - Time this event has been going on for */
125            float eventTime;
126            Vector3 startpos;
127
128            /* - Position to look at during that transition */
129            Vector3 lookAtPosition;
130
131    };// tolua_export
132} // tolua_export
133
134#endif /* _ScriptController_H__ */
Note: See TracBrowser for help on using the repository browser.