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 | * Cyrill Burgener |
---|
24 | * Co-authors: |
---|
25 | * ... |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | /** |
---|
30 | @file HoverShip.cc |
---|
31 | @brief Implementation of the HoverShip class. |
---|
32 | */ |
---|
33 | |
---|
34 | #include "HoverShip.h" |
---|
35 | #include "core/CoreIncludes.h" |
---|
36 | |
---|
37 | namespace orxonox |
---|
38 | { |
---|
39 | RegisterClass(HoverShip); |
---|
40 | |
---|
41 | HoverShip::HoverShip(Context* context) : SpaceShip(context) |
---|
42 | { |
---|
43 | RegisterObject(HoverShip); |
---|
44 | enableCollisionCallback(); |
---|
45 | isFloor_ = false; |
---|
46 | } |
---|
47 | |
---|
48 | void HoverShip::tick(float dt) |
---|
49 | { |
---|
50 | SUPER(HoverShip, tick, dt); |
---|
51 | } |
---|
52 | |
---|
53 | void HoverShip::moveFrontBack(const Vector2& value) |
---|
54 | { this->steering_.z -= value.x; } |
---|
55 | |
---|
56 | void HoverShip::moveRightLeft(const Vector2& value) |
---|
57 | { this->steering_.x += value.x; } |
---|
58 | |
---|
59 | void HoverShip::moveUpDown(const Vector2& value) |
---|
60 | { this->steering_.y += value.x; } |
---|
61 | |
---|
62 | void HoverShip::rotateYaw(const Vector2& value) |
---|
63 | { |
---|
64 | this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x); |
---|
65 | |
---|
66 | Pawn::rotateYaw(value); |
---|
67 | } |
---|
68 | |
---|
69 | void HoverShip::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
70 | { |
---|
71 | SUPER(HoverShip, XMLPort, xmlelement, mode); |
---|
72 | |
---|
73 | XMLPortParam(HoverShip, "jumpBoost", setJumpBoost, getJumpBoost, xmlelement, mode); |
---|
74 | } |
---|
75 | |
---|
76 | |
---|
77 | void HoverShip::setJumpBoost(float jumpBoost) |
---|
78 | { |
---|
79 | this->jumpBoost_ = jumpBoost; |
---|
80 | } |
---|
81 | |
---|
82 | |
---|
83 | float HoverShip::getJumpBoost() |
---|
84 | { |
---|
85 | return jumpBoost_; |
---|
86 | } |
---|
87 | |
---|
88 | /** |
---|
89 | @brief |
---|
90 | Rotate in pitch direction. |
---|
91 | Due to added left, can also lead to an additional up-down motion. |
---|
92 | @param value |
---|
93 | A vector whose first component specifies the magnitude of the rotation. Positive means pitch up, negative means pitch down. |
---|
94 | */ |
---|
95 | void HoverShip::rotatePitch(const Vector2& value) { } |
---|
96 | |
---|
97 | /** |
---|
98 | @brief |
---|
99 | Rotate in roll direction. |
---|
100 | @param value |
---|
101 | A vector whose first component specifies the magnitude of the rotation. Positive means roll left, negative means roll right. |
---|
102 | */ |
---|
103 | void HoverShip::rotateRoll(const Vector2& value) { } |
---|
104 | |
---|
105 | bool HoverShip::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) |
---|
106 | { |
---|
107 | SpaceShip::collidesAgainst(otherObject, cs, contactPoint); |
---|
108 | //SUPER(HoverShip, collidesAgainst, otherObject, cs, contactPoint); |
---|
109 | |
---|
110 | if (contactPoint.m_normalWorldOnB.y() > 0.6 |
---|
111 | && this->getVelocity().y < 1) { |
---|
112 | this->isFloor_ = true; |
---|
113 | } else { |
---|
114 | this->isFloor_ = false; |
---|
115 | } |
---|
116 | |
---|
117 | return false; |
---|
118 | } |
---|
119 | |
---|
120 | void HoverShip::boost(bool bBoost) { |
---|
121 | if (bBoost && this->isFloor_) |
---|
122 | { |
---|
123 | this->setVelocity( |
---|
124 | this->getVelocity().x, |
---|
125 | jumpBoost_, |
---|
126 | this->getVelocity().z |
---|
127 | ); |
---|
128 | this->isFloor_ = false; |
---|
129 | } |
---|
130 | } |
---|
131 | |
---|
132 | /*Hover* HoverShip::getGame() |
---|
133 | { |
---|
134 | if (game == NULL) |
---|
135 | { |
---|
136 | for (ObjectList<Hover>::iterator it = ObjectList<Hover>::begin(); it != ObjectList<Hover>::end(); ++it) |
---|
137 | { |
---|
138 | game = *it; |
---|
139 | } |
---|
140 | } |
---|
141 | return game; |
---|
142 | }*/ |
---|
143 | } |
---|