1 //-----------------------------------------------------------------------------
2 // Copyright (c) 2012 GarageGames, LLC
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to
6 // deal in the Software without restriction, including without limitation the
7 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 // sell copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 //-----------------------------------------------------------------------------
23 #ifndef _SFXFMODEVENT_H_
24 #define _SFXFMODEVENT_H_
27 #include "sfx/sfxTrack.h"
29 #ifndef _CONSOLETYPES_H_
30 #include "console/consoleTypes.h"
33 #include "math/mPoint2.h"
36 #include "fmod_event.h"
40 class SFXFMODEventGroup
;
43 /// An event in an FMOD Designer project.
45 /// This class must not be manually instanced by the user. Instead, SFXFMODEvents
46 /// are automatically created when an SFXFMODProject is loaded.
48 /// Be aware that as all the playback happens internally within FMOD's event system,
49 /// this bypasses the SFX layer and will thus not work with features that rely the
50 /// structures there. Namely, sound occlusion (except for FMOD's own occlusion) will
51 /// not work with FMOD events.
53 /// The parameters of an FMOD event are automatically created and designed using the
54 /// information in the project.
56 class SFXFMODEvent
: public SFXTrack
60 typedef SFXTrack Parent
;
61 friend class SFXFMODEventGroup
;
62 friend class SFXFMODEventSource
;
66 /// Name of the event in the Designer project.
69 /// Event group that this event belongs to.
70 SFXFMODEventGroup
* mGroup
;
72 /// Next event in the group's event chain.
73 SFXFMODEvent
* mSibling
;
75 /// FMOD event handle when event is open. Client-side only.
79 Point2F mParameterRanges
[ MaxNumParameters
];
82 F32 mParameterValues
[ MaxNumParameters
];
84 /// Group ID for client net sync.
88 void _createParameters();
96 SFXFMODEvent( SFXFMODEventGroup
* group
, const String
& name
);
99 SFXFMODEvent( SFXFMODEventGroup
* group
, FMOD_EVENT
* handle
);
103 /// Create the event object on the FMOD device.
106 /// Release the event object on the FMOD device.
110 const String
& getEventName() const { return mName
; }
113 SFXFMODEventGroup
* getEventGroup() const { return mGroup
; }
116 String
getQualifiedName() const;
119 bool isDataLoaded() const;
122 virtual bool onAdd();
123 virtual void onRemove();
124 virtual bool preload( bool server
, String
& errorStr
);
125 virtual void packData( BitStream
* stream
);
126 virtual void unpackData( BitStream
* stream
);
128 static void initPersistFields();
130 DECLARE_CONOBJECT( SFXFMODEvent
);
131 DECLARE_CATEGORY( "SFX FMOD" );
132 DECLARE_DESCRIPTION( "An FMOD Designer event." );
135 #endif // !_SFXFMODEVENT_H_