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 | |
---|
38 | namespace orxonox // tolua_export |
---|
39 | { // tolua_export |
---|
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 | /** Time span of the event */ |
---|
54 | float duration; |
---|
55 | |
---|
56 | /** Start point in time of the event */ |
---|
57 | float eventTime; |
---|
58 | }; |
---|
59 | |
---|
60 | class _OrxonoxExport ScriptController // tolua_export |
---|
61 | : public ArtificialController, public Tickable |
---|
62 | { // tolua_export |
---|
63 | public: |
---|
64 | ScriptController(Context* context); |
---|
65 | virtual ~ScriptController() { } |
---|
66 | |
---|
67 | void takeControl(int ctrlid); |
---|
68 | void setPlayer(PlayerInfo* player) { this->player_ = player; } |
---|
69 | |
---|
70 | virtual void tick(float dt); |
---|
71 | |
---|
72 | // LUA interface |
---|
73 | // tolua_begin |
---|
74 | void eventScheduler(std::string instruction, |
---|
75 | float x1, float y1, float z1, |
---|
76 | float x2, float y2, float z2, |
---|
77 | float duration, float executionTime); |
---|
78 | |
---|
79 | static ScriptController* getScriptController(); |
---|
80 | |
---|
81 | int getID() { return ctrlid_; } |
---|
82 | |
---|
83 | // tolua_end |
---|
84 | const Vector3& getPosition(); |
---|
85 | |
---|
86 | void execute(event ev); |
---|
87 | |
---|
88 | private: |
---|
89 | /* Information about the player that this ScriptController will |
---|
90 | * control */ |
---|
91 | /* - Player pointer */ |
---|
92 | PlayerInfo* player_; |
---|
93 | |
---|
94 | /* - Entity pointer, this is for convenience and will be the same as |
---|
95 | * player_->getControllableEntity() |
---|
96 | */ |
---|
97 | ControllableEntity* entity_; |
---|
98 | |
---|
99 | /* Controller ID, defaults to 0 and is set using takeControl() */ |
---|
100 | int ctrlid_; |
---|
101 | |
---|
102 | /* List of events to walk through */ |
---|
103 | std::vector<event> eventList; |
---|
104 | unsigned int eventno; |
---|
105 | |
---|
106 | /* Time since the creation of this ScriptController object */ |
---|
107 | float scTime; |
---|
108 | |
---|
109 | /* Boolean that specifies whether we're processing an event right |
---|
110 | * now */ |
---|
111 | bool processing; |
---|
112 | |
---|
113 | /* Data about the event currently being processed */ |
---|
114 | /* - The event itself */ |
---|
115 | event currentEvent; |
---|
116 | |
---|
117 | /* - Time this event has been going on for */ |
---|
118 | float eventTime; |
---|
119 | Vector3 startpos; |
---|
120 | |
---|
121 | /* - Position to look at during that transition */ |
---|
122 | //Vector3 lookAtPosition; |
---|
123 | |
---|
124 | };// tolua_export |
---|
125 | } // tolua_export |
---|
126 | |
---|
127 | #endif /* _ScriptController_H__ */ |
---|