Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- Player
- Shop
- Sounds
- Specializations
- Triggers
- Utils
- Vehicles
- Weather
Engine v1.7.1.0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
Foundation Reference
SoundManager
DescriptionThis class handles all soundsParent
AbstractManagerFunctions
initDataStructures
DescriptionInitialize data structuresDefinition
initDataStructures()Code
29 | function SoundManager:initDataStructures() |
30 | self.samples = {} |
31 | self.orderedSamples = {} |
32 | self.activeSamples = {} |
33 | self.activeSamplesSet = {} |
34 | self.currentSampleIndex = 1 |
35 | self.oldRandomizationIndex = 1 |
36 | self.isIndoor = false |
37 | self.isInsideBuilding = false |
38 | |
39 | self.soundTemplates = {} |
40 | self.soundTemplateXMLFile = nil |
41 | self:loadSoundTemplates(SoundManager.DEFAULT_SOUND_TEMPLATES) |
42 | |
43 | self.modifierTypeNameToIndex = {} |
44 | self.modifierTypeIndexToDesc = {} |
45 | SoundModifierType = self.modifierTypeNameToIndex |
46 | |
47 | self.indoorStateChangedListeners = {} |
48 | end |
loadSoundTemplates
DescriptionLoads sound templates from xml fileDefinition
loadSoundTemplates()Return Values
boolean | true | if loading was successful else false |
74 | function SoundManager:loadSoundTemplates(xmlFilename) |
75 | local xmlFile = loadXMLFile("TempTemplates", xmlFilename) |
76 | if xmlFile ~= nil then |
77 | local i = 0 |
78 | while true do |
79 | local key = string.format("soundTemplates.template(%d)", i) |
80 | if not hasXMLProperty(xmlFile, key) then |
81 | break |
82 | end |
83 | |
84 | local name = getXMLString(xmlFile, key.."#name") |
85 | if name ~= nil then |
86 | if self.soundTemplates[name] == nil then |
87 | self.soundTemplates[name] = key |
88 | else |
89 | print(string.format("Warning: Sound template '%s' already exists!", name)) |
90 | end |
91 | end |
92 | |
93 | i = i + 1 |
94 | end |
95 | |
96 | self.soundTemplateXMLFile = xmlFile |
97 | return true |
98 | end |
99 | |
100 | return false |
101 | end |
new
DescriptionCreating managerDefinition
new()Return Values
table | instance | instance of object |
21 | function SoundManager:new(customMt) |
22 | local self = AbstractManager:new(customMt or SoundManager_mt) |
23 | |
24 | return self |
25 | end |
registerModifierType
DescriptionLoads sound templates from xml fileDefinition
registerModifierType()Return Values
boolean | true | if loading was successful else false |
53 | function SoundManager:registerModifierType(typeName, func, minFunc, maxFunc) |
54 | typeName = typeName:upper() |
55 | |
56 | if SoundModifierType[typeName] == nil then |
57 | local desc = {} |
58 | desc.name = typeName |
59 | desc.index = #self.modifierTypeIndexToDesc + 1 |
60 | desc.func = func |
61 | desc.minFunc = minFunc |
62 | desc.maxFunc = maxFunc |
63 | |
64 | SoundModifierType[typeName] = desc.index |
65 | table.insert(self.modifierTypeIndexToDesc, desc) |
66 | end |
67 | |
68 | return SoundModifierType[typeName] |
69 | end |