00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __SOUNDSOURCECOMPONENT_H__
00017 #define __SOUNDSOURCECOMPONENT_H__
00018
00019
00020 #include "../../dependencies.h"
00021 #ifdef __COMPILE_WITH_SFML_AUDIO__
00022 #include "../../core/EntityComponent.h"
00023
00024
00025
00034 class SoundSourceComponent : public EntityComponent
00035 {
00036 public:
00037
00038
00041 SoundSourceComponent(Entity *parent);
00043 ~SoundSourceComponent();
00044
00045
00048 sf::Sound* getSound();
00051 sf::Music* getMusic();
00052
00061 bool loadMusic(const std::string &fileName);
00065 bool loadMusicFromMemory(c8 *buffer, long length);
00075 bool loadSoundBuffer(const std::string &bufferName);
00076
00078 void unloadData();
00079
00081 void play();
00083 void pause();
00085 void stop();
00086
00088 f32 getAttenuation() const;
00090 bool getIsPaused() const;
00092 bool getIsPlaying() const;
00094 bool getIsStopped() const;
00096 bool getLoop() const;
00098 f32 getMinDistance() const;
00101 f32 getOffset() const;
00103 f32 getPitch() const;
00105 f32 getVolume() const;
00106
00117 void setAttenuation(f32 attenuation);
00126 void setLoop(bool value);
00134 void setMinDistance(f32 minDistance);
00137 void setOffset(f32 offset);
00145 void setPitch(f32 pitch);
00153 void setVolume(f32 volume);
00154
00155
00158 void onPositionChange(void *p);
00161 void onPause(void *p);
00164 void onUnPause(void *p);
00167 void onSound(void *p);
00168
00169
00172 static bool parseXML(IXMLReader *file, Entity *entity);
00173
00174 private:
00175
00176
00177 sf::Sound *mSound;
00178 sf::Music *mMusic;
00179
00180 c8 *mBuffer;
00181 long mBufferSize;
00182 std::string mSoundFileName;
00183
00184 f32 mAttenuation;
00185 bool mLoop;
00186 f32 mMinDistance;
00187 f32 mPitch;
00188 vector3df mPosition;
00189 f32 mVolume;
00190
00191 bool mWasPaused;
00192
00193 };
00194
00195 #endif // __COMPILE_WITH_SFML_AUDIO__
00196
00197 #endif