Orxonox  0.0.5 Codename: Arcturus
ScriptController.h
Go to the documentation of this file.
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 
38 namespace orxonox // tolua_export
39 { // tolua_export
40 
42  struct event
43  {
46 
48  Vector3 v1;
49 
51  Vector3 v2;
52 
54  float a, b, c, d, e, f;
55 
57  float duration;
58 
60  float eventTime;
61  };
62 
63  class _OrxonoxExport ScriptController // tolua_export
64  : public ArtificialController, public Tickable
65  { // tolua_export
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  // LUA interface
76  // tolua_begin
77  void eventScheduler(std::string instruction = "",
78  float x1 = 0, float y1 = 0, float z1 = 0,
79  float x2 = 0, float y2 = 0, float z2 = 0,
80  float duration = 0, float executionTime = 0);
81 
82  static ScriptController* getScriptController();
83 
84  int getID() { return ctrlid_; }
85 
86  // tolua_end
87  const Vector3& getPosition();
88 
89  void execute(event ev);
90 
91  private:
92  /* Information about the player that this ScriptController will
93  * control */
94  /* - Player pointer */
96 
97  /* - Entity pointer, this is for convenience and will be the same as
98  * player_->getControllableEntity()
99  */
101 
102  /* Controller ID, defaults to 0 and is set using takeControl() */
103  int ctrlid_;
104 
105  /* List of events to walk through */
106  std::vector<event> eventList;
107  unsigned int eventno;
108 
109  /* Time since the creation of this ScriptController object */
110  float scTime;
111 
112  /* Boolean that specifies whether we're processing an event right
113  * now */
115 
116  /* Data about the event currently being processed */
117  /* - The event itself */
119 
120  /* - Time this event has been going on for */
121  float eventTime;
122  Vector3 startpos;
123 
124  /* Time of the previously scheduled event */
126 
127  /* - Position to look at during that transition */
128  //Vector3 lookAtPosition;
129 
130  };// tolua_export
131 } // tolua_export
132 
133 #endif /* _ScriptController_H__ */
PlayerInfo * player_
Definition: ScriptController.h:95
float f
Definition: ScriptController.h:54
Vector3 startpos
Definition: ScriptController.h:122
ControllableEntity * entity_
Definition: ScriptController.h:100
virtual ~ScriptController()
Definition: ScriptController.h:68
float c
Definition: ScriptController.h:54
float scTime
Definition: ScriptController.h:110
::std::string string
Definition: gtest-port.h:756
Structure to describe a single event.
Definition: ScriptController.h:42
float b
Definition: ScriptController.h:54
float duration
Time span of the event.
Definition: ScriptController.h:57
std::string fctName
Instruction for this event.
Definition: ScriptController.h:45
unsigned int eventno
Definition: ScriptController.h:107
float d
Definition: ScriptController.h:54
Vector3 v2
Where we are looking.
Definition: ScriptController.h:51
Vector3 v1
Final position we want to be at.
Definition: ScriptController.h:48
std::vector< event > eventList
Definition: ScriptController.h:106
float a
The parameters are additionally stored as a set of 6 numerical values.
Definition: ScriptController.h:54
void setPlayer(PlayerInfo *player)
Definition: ScriptController.h:71
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
int ctrlid_
Definition: ScriptController.h:103
int getID()
Definition: ScriptController.h:84
Shared library macros, enums, constants and forward declarations for the orxonox library ...
Definition: Context.h:45
float eventTime
Definition: ScriptController.h:121
#define _OrxonoxExport
Definition: OrxonoxPrereqs.h:60
Definition: ScriptController.h:63
float prevEventTime
Definition: ScriptController.h:125
Definition: PlayerInfo.h:39
The Tickable interface provides a tick(dt) function, that gets called every frame.
Definition: Tickable.h:52
bool processing
Definition: ScriptController.h:114
The ControllableEntity is derived from the orxonox::MobileEntity.
Definition: ControllableEntity.h:48
Definition of the XMLPortEventState() macro, as well as some more useful macros.
event currentEvent
Definition: ScriptController.h:118
Definition: ArtificialController.h:38
float e
Definition: ScriptController.h:54
float eventTime
Start point in time of the event.
Definition: ScriptController.h:60