Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
SoundSceneObjClass.h
1/* Renegade Scripts.dll
2 Copyright 2013 Tiberian Technologies
3
4 This file is part of the Renegade scripts.dll
5 The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 2, or (at your option) any later
8 version. See the file COPYING for more details.
9 In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
10 Only the source code to the module(s) containing the licenced code has to be released.
11*/
12#ifndef __SOUNDSCENEOBJCLASS_H__
13#define __SOUNDSCENEOBJCLASS_H__
14
15#include "engine_threading.h"
16#include "engine_string.h"
17#include "engine_vector.h"
18#include "audiocallback.h"
19#include "Persist.h"
20#include "Matrix3D.h"
21#if !defined(W3DVIEWER) && !defined(TTLE_EXPORTS)
22#include "HashTemplateClass.h"
23#endif
24class SoundSceneClass;
25class SoundCullObjClass;
26class Sound3DClass;
27class SoundPseudo3DClass;
28class FilteredSoundClass;
29class Listener3DClass;
30class AudibleSoundClass;
31class RenderObjClass;
32const uint32 SOUND_OBJ_DEFAULT_ID = 0;
33const uint32 SOUND_OBJ_START_ID = 1000000000;
34
35class SoundSceneObjClass : public MultiListObjectClass, public PersistClass, public RefCountClass
36{
37public:
38 friend class SoundSceneClass;
39 friend class WWAudioClass;
40 friend class HandleMgrClass;
41 SoundSceneObjClass (void);
42 SoundSceneObjClass (const SoundSceneObjClass &src);
43 virtual ~SoundSceneObjClass (void);
44 const SoundSceneObjClass &operator= (const SoundSceneObjClass &src);
45 virtual Sound3DClass * As_Sound3DClass (void) { return NULL; }
46 virtual SoundPseudo3DClass * As_SoundPseudo3DClass (void) { return NULL; }
47 virtual FilteredSoundClass * As_FilteredSoundClass (void) { return NULL; }
48 virtual Listener3DClass * As_Listener3DClass (void) { return NULL; }
49 virtual AudibleSoundClass * As_AudibleSoundClass(void) { return NULL; }
50 virtual uint32 Get_ID (void) const { return m_ID; }
51 virtual void Set_ID (uint32 id);
52 virtual bool On_Frame_Update (unsigned int milliseconds = 0);
53 virtual void On_Event (AudioCallbackClass::EVENTS event, uint32 param1 = 0, uint32 param2 = 0);
54 virtual void Register_Callback (AudioCallbackClass::EVENTS events, AudioCallbackClass *callback);
55 virtual void Remove_Callback (void);
56 virtual void Set_Position (const Vector3 &position) = 0;
57 virtual Vector3 Get_Position (void) const = 0;
58 virtual void Set_Listener_Transform (const Matrix3D &tm) {};
59 virtual void Set_Transform (const Matrix3D &transform) = 0;
60 virtual Matrix3D Get_Transform (void) const = 0;
61 virtual void Cull_Sound (bool culled = true) = 0;
62 virtual bool Is_Sound_Culled (void) const = 0;
63 virtual void Set_User_Data (RefCountClass *user_obj = NULL, uint32 user = 0) { REF_PTR_SET (m_UserObj, user_obj); m_UserData = user; }
64 virtual uint32 Get_User_Data (void) const { return m_UserData; }
65 virtual RefCountClass *Peek_User_Obj (void) const { return m_UserObj; }
66 virtual void Attach_To_Object (RenderObjClass *render_obj, int bone_index = -1);
67 virtual void Attach_To_Object (RenderObjClass *render_obj, const char *bone_name);
68 virtual RenderObjClass *Peek_Parent_Object (void) { return m_AttachedObject; }
69 virtual int Get_Parent_Bone (void) { return m_AttachedBone; }
70 virtual void Apply_Auto_Position (void);
71 virtual void Add_To_Scene (bool start_playing = true) = 0;
72 virtual void Remove_From_Scene (void) = 0;
73 virtual bool Is_In_Scene (void) const { return m_Scene != NULL; }
74 virtual void Set_DropOff_Radius (float radius = 1) = 0;
75 virtual float Get_DropOff_Radius (void) const = 0;
76 bool Save (ChunkSaveClass &csave);
77 bool Load (ChunkLoadClass &cload);
78protected:
79 virtual SoundCullObjClass * Peek_Cullable_Wrapper (void) const { return m_PhysWrapper; }
80 virtual void Set_Cullable_Wrapper (SoundCullObjClass *obj) { m_PhysWrapper = obj; }
81 static void Register_Sound_Object (SoundSceneObjClass *sound_obj);
82 static void Unregister_Sound_Object (SoundSceneObjClass *sound_obj);
83 static bool Find_Sound_Object (uint32 id_to_find, int *index);
84
85 SoundSceneClass * m_Scene; // 0018 0030
86 SoundCullObjClass * m_PhysWrapper; // 001C 0034
87 AudioCallbackClass * m_pCallback; // 0020 0038
88 AudioCallbackClass::EVENTS m_RegisteredEvents; // 0024 003C
89 uint32 m_ID; // 0028 0040
90 RenderObjClass * m_AttachedObject; // 002C 0044
91 int m_AttachedBone; // 0030 0048
92 uint32 m_UserData; // 0034 004C
93 RefCountClass * m_UserObj; // 0038 0050
94
95 static uint32 m_NextAvailableID;
96 static DynamicVectorClass<SoundSceneObjClass *> m_GlobalSoundList;
97 static CriticalSectionClass m_IDListMutex;
98
99 // Added by TT
100#if !defined(W3DVIEWER) && !defined(TTLE_EXPORTS)
101public:
102 static void Associate_Server_ID(SoundSceneObjClass* sound_obj, uint32 server_id);
103
104protected:
105 static HashTemplateClass<uint32, SoundSceneObjClass*> m_ServerGlobalSoundList;
106 static HashTemplateClass<uint32, uint32> m_ReversedServerGlobalSoundList;
107 static CriticalSectionClass m_ServerIDListMutex;
108
109 static bool Find_Server_Sound_Object(uint32 server_id_to_find, SoundSceneObjClass*& sound_obj);
110#endif
111}; // 003C 0054
112
113#endif