16
16
// along with this program; if not, write to the Free Software
17
17
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
18
19
+ #include " audio/sfx_manager.hpp"
20
+ #include " audio/sfx_base.hpp"
19
21
#include " items/attachment.hpp"
20
22
#include " items/powerup.hpp"
21
23
#include " karts/ghost_kart.hpp"
26
28
#include " modes/linear_world.hpp"
27
29
#include " modes/world.hpp"
28
30
#include " replay/replay_recorder.hpp"
31
+ #include " tracks/terrain_info.hpp"
29
32
#include " tracks/track.hpp"
30
33
31
34
#include " LinearMath/btQuaternion.h"
@@ -99,6 +102,8 @@ void GhostKart::updateGraphics(float dt)
99
102
Moveable::updateGraphics (center_shift, btQuaternion (0 , 0 , 0 , 1 ));
100
103
// Also update attachment's graphics
101
104
m_attachment->updateGraphics (dt);
105
+
106
+ updateSound (dt);
102
107
} // updateGraphics
103
108
104
109
// ----------------------------------------------------------------------------
@@ -219,6 +224,8 @@ void GhostKart::update(int ticks)
219
224
m_all_replay_events[idx].m_red_skidding );
220
225
getKartGFX ()->update (dt);
221
226
227
+ m_speed = getSpeed ();
228
+
222
229
Vec3 front (0 , 0 , getKartLength ()*0 .5f );
223
230
m_xyz_front = getTrans ()(front);
224
231
@@ -233,12 +240,62 @@ void GhostKart::update(int ticks)
233
240
getKartModel ()->setAnimation (KartModel::AF_DEFAULT);
234
241
}
235
242
243
+ m_terrain_info->update (getTrans ().getBasis (),
244
+ getXYZ () + getTrans ().getBasis ().getColumn (1 ) * 0 .1f );
236
245
} // update
237
246
247
+ // ----------------------------------------------------------------------------
248
+ void GhostKart::updateSound (float dt)
249
+ {
250
+ if (!getController ()) return ;
251
+
252
+ GhostController* gc = dynamic_cast <GhostController*>(getController ());
253
+ if (gc == NULL ) return ;
254
+
255
+ const unsigned int idx = gc->getCurrentReplayIndex ();
256
+
257
+ updateEngineSFX (dt);
258
+
259
+ if (m_skid_sound)
260
+ {
261
+ if (m_all_replay_events[idx].m_skidding_effect )
262
+ {
263
+ if (m_skid_sound->getStatus ()!=SFXBase::SFX_PLAYING)
264
+ {
265
+ m_skid_sound->play (getSmoothedXYZ ());
266
+ }
267
+ }
268
+ else if (m_skid_sound->getStatus ()==SFXBase::SFX_PLAYING)
269
+ {
270
+ m_skid_sound->stop ();
271
+ }
272
+ }
273
+
274
+ if (m_nitro_sound)
275
+ {
276
+ if (m_all_replay_events[idx].m_nitro_usage )
277
+ {
278
+ if (m_nitro_sound->getStatus ()!=SFXBase::SFX_PLAYING)
279
+ {
280
+ m_nitro_sound->play (getSmoothedXYZ ());
281
+ }
282
+ }
283
+ else if (m_nitro_sound->getStatus ()==SFXBase::SFX_PLAYING)
284
+ {
285
+ m_nitro_sound->stop ();
286
+ }
287
+ }
288
+ }
289
+
238
290
// ----------------------------------------------------------------------------
239
291
/* * Returns the speed of the kart in meters/second. */
240
292
float GhostKart::getSpeed () const
241
293
{
294
+ if (!getController ())
295
+ {
296
+ return 0 .f ;
297
+ }
298
+
242
299
const GhostController* gc =
243
300
dynamic_cast <const GhostController*>(getController ());
244
301
0 commit comments