コード例 #1
0
        public override void UpdateAfterSimulation()
        {
            if (!MySandboxGame.IsGameReady)
            {
                return;
            }
            if (Game.IsDedicated)
            {
                return;
            }

            if (_currentDisplayTime <= 0 && MessageQueue.Count > 0)
            {
                _currentDisplayTime = 200;
                _currentMessage     = MessageQueue.Dequeue();
                MyAudio.Static.PlaySound(MySoundPair.GetCueId(_currentMessage.Value.Sound));
            }
            else if (_currentDisplayTime > 0)
            {
                _currentDisplayTime--;
                if (_currentDisplayTime <= 0)
                {
                    _currentMessage = null;
                }
            }
        }
コード例 #2
0
        private void InitCue(string cueName)
        {
            if (string.IsNullOrEmpty(cueName))
            {
                CueId = MyStringId.NullOrEmpty;
            }
            else
            {
                MyStringId stringId = MyStringId.GetOrCompute(cueName);
                MySoundCategoryDefinition.SoundDescription soundDesc = null;
                var soundCategories = MyDefinitionManager.Static.GetSoundCategoryDefinitions();

                // check whether saved cue is in some category
                foreach (var category in soundCategories)
                {
                    foreach (var soundDescTmp in category.Sounds)
                    {
                        if (MySoundPair.GetCueId(soundDescTmp.SoundId) == stringId)
                        {
                            soundDesc = soundDescTmp;
                        }
                    }
                }

                if (soundDesc != null)
                {
                    SelectSound(stringId, false);
                }
                else
                {
                    CueId = MyStringId.NullOrEmpty;
                }
            }
        }
コード例 #3
0
 private void UpdateProductionSound()
 {
     if (this.m_soundEmitter == null)
     {
         this.m_soundEmitter = new MyEntity3DSoundEmitter(base.Entity as MyEntity, false, 1f);
     }
     if (base.m_currentItemStatus >= 1f)
     {
         this.m_soundEmitter.StopSound(true, true);
     }
     else
     {
         bool?nullable;
         MyCraftingComponentBase.MyBlueprintToProduce currentItemInProduction = base.GetCurrentItemInProduction();
         if ((currentItemInProduction == null) || (currentItemInProduction.Blueprint.ProgressBarSoundCue == null))
         {
             nullable = null;
             this.m_soundEmitter.PlaySingleSound(this.ActionSound, false, false, false, nullable);
         }
         else
         {
             nullable = null;
             this.m_soundEmitter.PlaySingleSound(MySoundPair.GetCueId(currentItemInProduction.Blueprint.ProgressBarSoundCue), false, false, nullable);
         }
     }
 }
コード例 #4
0
ファイル: MySoundBlock.cs プロジェクト: caomw/SpaceEngineers
        private void InitCue(int cueId)
        {
            if (cueId == 0)
            {
                CueId = cueId;
            }
            else
            {
                MyStringId stringId = MyStringId.TryGet(cueId);
                MySoundCategoryDefinition.SoundDescription soundDesc = null;
                var soundCategories = MyDefinitionManager.Static.GetSoundCategoryDefinitions();

                // check whether saved cue is in some category
                foreach (var category in soundCategories)
                {
                    foreach (var soundDescTmp in category.Sounds)
                    {
                        if (MySoundPair.GetCueId(soundDescTmp.SoundId) == stringId)
                        {
                            soundDesc = soundDescTmp;
                        }
                    }
                }

                if (soundDesc != null)
                {
                    SelectSound(stringId, false);
                }
                else
                {
                    CueId = 0;
                }
            }
        }
コード例 #5
0
        private static void PlaySound(Vector3D position, string cueName)
        {
            var emitter = MyAudioComponent.TryGetSoundEmitter();

            if (emitter == null)
            {
                return;
            }

            emitter.SetPosition(position);
            emitter.PlaySound(MySoundPair.GetCueId(cueName));
        }
コード例 #6
0
        private void FillListContent(ICollection <MyGuiControlListbox.Item> listBoxContent, ICollection <MyGuiControlListbox.Item> listBoxSelectedItems)
        {
            foreach (var soundCategory in MyDefinitionManager.Static.GetSoundCategoryDefinitions())
            {
                foreach (var sound in soundCategory.Sounds)
                {
                    m_helperSB.Clear().Append(sound.SoundText);
                    var stringId = MySoundPair.GetCueId(sound.SoundId);

                    var item = new MyGuiControlListbox.Item(text: m_helperSB, userData: stringId);

                    listBoxContent.Add(item);
                    if (stringId == CueId)
                    {
                        listBoxSelectedItems.Add(item);
                    }
                }
            }
        }
コード例 #7
0
        private void UpdateProductionSound()
        {
            if (m_soundEmitter == null)
            {
                m_soundEmitter = new MyEntity3DSoundEmitter(Entity as MyEntity);
            }

            if (this.m_currentItemStatus < 1f)
            {
                var blueprint = this.GetCurrentItemInProduction();
                if (blueprint != null && blueprint.Blueprint.ProgressBarSoundCue != null)
                {
                    m_soundEmitter.PlaySingleSound(MySoundPair.GetCueId(blueprint.Blueprint.ProgressBarSoundCue));
                }
                else
                {
                    m_soundEmitter.PlaySingleSound(ActionSound);
                }
            }
            else
            {
                m_soundEmitter.StopSound(true);
            }
        }
コード例 #8
0
 public void StartSecondarySound(string cueName, bool sync = false)
 {
     StartSecondarySound(MySoundPair.GetCueId(cueName), sync);
 }