[10014] | 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: |
---|
[10622] | 23 | * ... |
---|
[10014] | 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #ifndef _ScriptController_H__ |
---|
| 30 | #define _ScriptController_H__ |
---|
| 31 | |
---|
[10028] | 32 | #include "OrxonoxPrereqs.h" /* die ganzen tolua, kopiert aus Dock.h*/ |
---|
[10014] | 33 | #include "ArtificialController.h" |
---|
| 34 | #include "core/EventIncludes.h" |
---|
| 35 | |
---|
| 36 | |
---|
[10048] | 37 | |
---|
[10028] | 38 | namespace orxonox // tolua_export |
---|
| 39 | { // tolua_export |
---|
[10048] | 40 | |
---|
[10066] | 41 | /** Structure to describe a single event */ |
---|
[10048] | 42 | struct event |
---|
| 43 | { |
---|
[10066] | 44 | /** Instruction for this event */ |
---|
[10048] | 45 | std::string fctName; |
---|
| 46 | |
---|
[10622] | 47 | /** Final position we want to be at **/ |
---|
[10066] | 48 | Vector3 v1; |
---|
[10622] | 49 | |
---|
| 50 | /** Where we are looking **/ |
---|
[10066] | 51 | Vector3 v2; |
---|
[10065] | 52 | |
---|
[10622] | 53 | /** The parameters are additionally stored as a set of 6 numerical values **/ |
---|
| 54 | float a, b, c, d, e, f; |
---|
| 55 | |
---|
[10066] | 56 | /** Time span of the event */ |
---|
[10065] | 57 | float duration; |
---|
| 58 | |
---|
[10066] | 59 | /** Start point in time of the event */ |
---|
[10048] | 60 | float eventTime; |
---|
| 61 | }; |
---|
| 62 | |
---|
[10028] | 63 | class _OrxonoxExport ScriptController // tolua_export |
---|
[10047] | 64 | : public ArtificialController, public Tickable |
---|
[10028] | 65 | { // tolua_export |
---|
[10014] | 66 | public: |
---|
[10028] | 67 | ScriptController(Context* context); |
---|
[10014] | 68 | virtual ~ScriptController() { } |
---|
| 69 | |
---|
[10047] | 70 | void takeControl(int ctrlid); |
---|
| 71 | void setPlayer(PlayerInfo* player) { this->player_ = player; } |
---|
[10020] | 72 | |
---|
[10047] | 73 | virtual void tick(float dt); |
---|
[10028] | 74 | |
---|
| 75 | // LUA interface |
---|
| 76 | // tolua_begin |
---|
[10622] | 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); |
---|
[10048] | 81 | |
---|
[10045] | 82 | static ScriptController* getScriptController(); |
---|
[10047] | 83 | |
---|
| 84 | int getID() { return ctrlid_; } |
---|
[10020] | 85 | |
---|
[10028] | 86 | // tolua_end |
---|
[10045] | 87 | const Vector3& getPosition(); |
---|
[10020] | 88 | |
---|
[10048] | 89 | void execute(event ev); |
---|
| 90 | |
---|
[10014] | 91 | private: |
---|
[10065] | 92 | /* Information about the player that this ScriptController will |
---|
| 93 | * control */ |
---|
| 94 | /* - Player pointer */ |
---|
[10047] | 95 | PlayerInfo* player_; |
---|
[10065] | 96 | |
---|
| 97 | /* - Entity pointer, this is for convenience and will be the same as |
---|
| 98 | * player_->getControllableEntity() |
---|
| 99 | */ |
---|
[10047] | 100 | ControllableEntity* entity_; |
---|
[10065] | 101 | |
---|
| 102 | /* Controller ID, defaults to 0 and is set using takeControl() */ |
---|
[10047] | 103 | int ctrlid_; |
---|
[10014] | 104 | |
---|
[10065] | 105 | /* List of events to walk through */ |
---|
| 106 | std::vector<event> eventList; |
---|
| 107 | unsigned int eventno; |
---|
[10014] | 108 | |
---|
[10065] | 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 */ |
---|
| 114 | bool processing; |
---|
| 115 | |
---|
[10066] | 116 | /* Data about the event currently being processed */ |
---|
| 117 | /* - The event itself */ |
---|
| 118 | event currentEvent; |
---|
[10065] | 119 | |
---|
| 120 | /* - Time this event has been going on for */ |
---|
| 121 | float eventTime; |
---|
| 122 | Vector3 startpos; |
---|
| 123 | |
---|
[10622] | 124 | /* Time of the previously scheduled event */ |
---|
| 125 | float prevEventTime; |
---|
| 126 | |
---|
[10065] | 127 | /* - Position to look at during that transition */ |
---|
[10066] | 128 | //Vector3 lookAtPosition; |
---|
[10065] | 129 | |
---|
[10028] | 130 | };// tolua_export |
---|
| 131 | } // tolua_export |
---|
[10014] | 132 | |
---|
| 133 | #endif /* _ScriptController_H__ */ |
---|