public override void OnStart(StartState state)
        {
            if (state == StartState.Editor || state == StartState.None)
            {
                return;
            }

            var configNode = AudioUtility.GetConfigNode(part.partInfo.name, this.moduleName);

            foreach (var groupNode in configNode.GetNodes())
            {
                var           soundLayerNodes = groupNode.GetNodes("SOUNDLAYER");
                CollisionType collisionType;

                if (Enum.TryParse(groupNode.name, out collisionType))
                {
                    var soundLayers = AudioUtility.CreateSoundLayerGroup(soundLayerNodes);
                    if (SoundLayerGroups.ContainsKey(collisionType))
                    {
                        SoundLayerGroups[collisionType].AddRange(soundLayers);
                    }
                    else
                    {
                        SoundLayerGroups.Add(collisionType, soundLayers);
                    }
                }
            }

            GameEvents.onGamePause.Add(onGamePause);
            GameEvents.onGameUnpause.Add(onGameUnpause);
        }
        public override void OnStart(StartState state)
        {
            if (state == StartState.Editor || state == StartState.None)
            {
                return;
            }

            string partParentName = part.name + "_" + this.moduleName;

            audioParent = part.gameObject.GetChild(partParentName);
            if (audioParent == null)
            {
                audioParent = new GameObject(partParentName);
                audioParent.transform.rotation = part.transform.rotation;
                audioParent.transform.position = part.transform.position;
                audioParent.transform.parent   = part.transform;
            }

            var configNode = AudioUtility.GetConfigNode(part.partInfo.name, this.moduleName);

            engineModules = part.Modules.GetModules <ModuleEngines>();

            foreach (var node in configNode.GetNodes())
            {
                string _engineState = node.name;

                var soundLayers = AudioUtility.CreateSoundLayerGroup(node.GetNodes("SOUNDLAYER"));
                if (soundLayers.Count > 0)
                {
                    if (SoundLayerGroups.ContainsKey(_engineState))
                    {
                        SoundLayerGroups[_engineState].AddRange(soundLayers);
                    }
                    else
                    {
                        SoundLayerGroups.Add(_engineState, soundLayers);
                    }
                }
            }

            foreach (var engineModule in engineModules)
            {
                ignites.Add(engineModule.engineID, engineModule.EngineIgnited);
                flameouts.Add(engineModule.engineID, engineModule.flameout);
            }

            initialized = true;

            GameEvents.onGamePause.Add(onGamePause);
            GameEvents.onGameUnpause.Add(onGameUnpause);
        }
        public override void OnStart(StartState state)
        {
            if (state == StartState.Editor || state == StartState.None)
            {
                return;
            }

            string partParentName = part.name + "_" + this.moduleName;

            audioParent = part.gameObject.GetChild(partParentName);
            if (audioParent == null)
            {
                audioParent = new GameObject(partParentName);
                audioParent.transform.rotation = part.transform.rotation;
                audioParent.transform.position = part.transform.position;
                audioParent.transform.parent   = part.transform;
            }

            moduleWheel  = part.GetComponent <ModuleWheelBase>();
            moduleMotor  = part.GetComponent <ModuleWheelMotor>();
            moduleDeploy = part.GetComponent <ModuleWheelDeployment>();

            var configNode = AudioUtility.GetConfigNode(part.partInfo.name, this.moduleName);

            SoundLayerGroups.Clear();
            spools.Clear();
            foreach (var node in configNode.GetNodes())
            {
                string _wheelState = node.name;

                var soundLayers = AudioUtility.CreateSoundLayerGroup(node.GetNodes("SOUNDLAYER"));
                if (soundLayers.Count > 0)
                {
                    if (SoundLayerGroups.ContainsKey(_wheelState))
                    {
                        SoundLayerGroups[_wheelState].AddRange(soundLayers);
                    }
                    else
                    {
                        SoundLayerGroups.Add(_wheelState, soundLayers);
                    }
                }
            }

            GameEvents.onGamePause.Add(onGamePause);
            GameEvents.onGameUnpause.Add(onGameUnpause);

            initialized = true;
        }
        public override void OnStart(StartState state)
        {
            if (state == StartState.Editor || state == StartState.None)
            {
                return;
            }

            string partParentName = part.name + "_" + this.moduleName;

            audioParent = part.gameObject.GetChild(partParentName);
            if (audioParent == null)
            {
                audioParent = new GameObject(partParentName);
                audioParent.transform.rotation = part.transform.rotation;
                audioParent.transform.position = part.transform.position;
                audioParent.transform.parent   = part.transform;
            }

            var configNode = AudioUtility.GetConfigNode(part.partInfo.name, this.moduleName);

            SoundLayers = AudioUtility.CreateSoundLayerGroup(configNode.GetNodes("SOUNDLAYER"));

            if (part.isLaunchClamp())
            {
                fxGroup     = part.findFxGroup("activate");
                isDecoupler = true;
            }

            if (part.GetComponent <ModuleDecouplerBase>())
            {
                fxGroup     = part.findFxGroup("decouple");
                isDecoupler = true;
            }

            if (fxGroup != null)
            {
                if (SoundLayers.Where(x => x.name == fxGroup.name).Count() > 0)
                {
                    var soundLayer = SoundLayers.Find(x => x.name == fxGroup.name);
                    if (soundLayer.audioClips != null)
                    {
                        var clip = GameDatabase.Instance.GetAudioClip(soundLayer.audioClips[0]);
                        if (clip != null)
                        {
                            fxGroup.sfx   = clip;
                            fxGroup.audio = AudioUtility.CreateOneShotSource(
                                audioParent,
                                soundLayer.volume * HighLogic.CurrentGame.Parameters.CustomParams <Settings>().ShipVolume,
                                soundLayer.pitch,
                                soundLayer.maxDistance,
                                soundLayer.spread);

                            Sources.Add(soundLayer.name, fxGroup.audio);
                        }
                    }
                }
            }

            GameEvents.onGameUnpause.Add(onGameUnpause);
            GameEvents.onDockingComplete.Add(onDock);
            GameEvents.onPartUndockComplete.Add(onUnDock);
        }