Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/Presentation_FS16/src/orxonox/controllers/ScriptController.h @ 12373

Last change on this file since 12373 was 11207, checked in by fvultier, 9 years ago

merged scriptable controller

  • Property svn:eol-style set to native
File size: 4.2 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 *      ...
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 
39{ 
40
41    /** Structure to describe a single event */
42    struct event
43    {   
44        /** Instruction for this event */
45        std::string fctName;
46
47        /** Final position we want to be at **/
48        Vector3 v1;
49
50        /** Where we are looking **/
51        Vector3 v2;
52
53        /** The parameters are additionally stored as a set of 6 numerical values **/
54        float a, b, c, d, e, f;
55
56        /** Time span of the event */
57        float duration;
58
59        /** Start point in time of the event */
60        float eventTime;
61    }; 
62
63    class _OrxonoxExport ScriptController 
64       : public ArtificialController, public Tickable
65    { 
66        public:
67            ScriptController(Context* context);
68            virtual ~ScriptController() { }
69
70            void takeControl(int ctrlid);
71            void setPlayer(PlayerInfo* player) { this->player_ = player; }
72           
73            virtual void tick(float dt) override;
74
75           
76            void eventScheduler(std::string instruction = "", 
77              float x1 = 0, float y1 = 0, float z1 = 0, 
78              float x2 = 0, float y2 = 0, float z2 = 0, 
79              float duration = 0, float executionTime = 0);
80
81            static ScriptController* getScriptController();
82
83            int getID() { return ctrlid_; }
84
85           
86            const Vector3& getPosition();
87
88            void execute(event ev);
89
90        private:
91            /* Information about the player that this ScriptController will
92             * control */
93            /* - Player pointer */
94            PlayerInfo* player_;
95
96            /* - Entity pointer, this is for convenience and will be the same as
97             *   player_->getControllableEntity()
98             */
99            ControllableEntity* entity_;
100
101            /* Controller ID, defaults to 0 and is set using takeControl() */
102            int ctrlid_;
103
104            /* List of events to walk through */
105            std::vector<event> eventList;
106            unsigned int eventno;
107
108            /* Time since the creation of this ScriptController object */
109            float scTime; 
110
111            /* Boolean that specifies whether we're processing an event right
112             * now */
113            bool processing;
114
115            /* Data about the event currently being processed */
116            /* - The event itself */
117            event currentEvent;
118
119            /* - Time this event has been going on for */
120            float eventTime;
121            Vector3 startpos;
122
123            /* Time of the previously scheduled event */
124            float prevEventTime;
125
126            /* - Position to look at during that transition */
127            //Vector3 lookAtPosition;
128
129
130            /* private member functions */
131
132            /*spiral event*/
133            void spi(float dl);
134
135            /* rotate and look event */
136            void ral(float dl);
137
138            /* move and look event */
139            void mal(float dl);
140
141            /* transition look event */
142            void chl(float dl);
143
144            /* rotate around x-coordinate event */
145            void rotX(float dl);
146
147    };
148} 
149
150#endif /* _ScriptController_H__ */
Note: See TracBrowser for help on using the repository browser.