public void UpdateSoundEmitter()
 {
     if (m_soundEmitter != null)
     {
         m_soundEmitter.Update();
     }
 }
Exemple #2
0
            public override void UpdateBeforeSimulation100()
            {
                base.UpdateBeforeSimulation100();
                if (m_particleVectorUp == Vector3.Zero)
                {
                    if (Entity.Physics.LinearVelocity != Vector3.Zero)
                    {
                        m_particleVectorUp = -Vector3.Normalize(Entity.Physics.LinearVelocity);
                    }
                    else
                    {
                        m_particleVectorUp = Vector3.Up;
                    }
                    m_particleVectorUp.CalculatePerpendicularVector(out m_particleVectorForward);
                }

                Vector3D pos    = Entity.PositionComp.GetPosition();
                var      planet = MyGamePruningStructure.GetClosestPlanet(pos);

                MeteorStatus orig = m_meteorStatus;

                if (planet != null && planet.HasAtmosphere && planet.GetAirDensity(pos) > 0.5f)
                {
                    m_meteorStatus = MeteorStatus.InAtmosphere;
                }
                else
                {
                    m_meteorStatus = MeteorStatus.InSpace;
                }

                if (orig != m_meteorStatus && m_dustEffect != null)
                {
                    m_dustEffect.Stop();
                    m_dustEffect = null;
                }

                if (m_dustEffect != null && !InParticleVisibleRange)
                {
                    m_dustEffect.Stop();
                    m_dustEffect = null;
                }

                if (m_dustEffect == null && InParticleVisibleRange)
                {
                    if (MyParticlesManager.TryCreateParticleEffect(m_particleEffectNames[(int)m_meteorStatus], out m_dustEffect))
                    {
                        UpdateParticlePosition();
                        m_dustEffect.UserScale = Entity.PositionComp.Scale.Value;
                    }
                }

                m_soundEmitter.Update();

                if (Sync.IsServer && MySandboxGame.TotalGamePlayTimeInMilliseconds - m_timeCreated > Math.Min(MAX_TRAJECTORY_LENGTH / SPEED, MAX_TRAJECTORY_LENGTH / Entity.Physics.LinearVelocity.Length()) * 1000)
                {
                    CloseMeteorInternal();
                }
            }
Exemple #3
0
 public override void UpdateBeforeSimulation100()
 {
     base.UpdateBeforeSimulation100();
     if (m_soundEmitter != null)
     {
         m_soundEmitter.Update();
         if (m_soundEmitter.IsPlaying && (DateTime.UtcNow - m_soundStart).TotalSeconds >= 15f)//stop falling sound if it playing too long
         {
             m_fallSoundShouldPlay.Value = false;
         }
     }
 }
 public EffectSoundEmitter(uint id, Vector3 position, MySoundPair sound)
 {
     ParticleSoundId = id;
     Updated = true;
     Emitter = new MyEntity3DSoundEmitter(null);
     Emitter.SetPosition(position);
     Emitter.PlaySound(sound);
     if (Emitter.Sound != null)
         OriginalVolume = Emitter.Sound.Volume;
     else
         OriginalVolume = 1f;
     Emitter.Update();
 }
Exemple #5
0
        public override void UpdateBeforeSimulation100()
        {
            base.UpdateBeforeSimulation100();
            if (m_soundEmitter != null)
            {
                m_soundEmitter.Update();
                if (m_soundEmitter.IsPlaying && (DateTime.UtcNow - m_soundStart).TotalSeconds >= 15f)//stop falling sound if it playing too long
                {
                    m_fallSoundShouldPlay.Value = false;
                }
            }

            var grav = MyGravityProviderSystem.CalculateTotalGravityInPoint(PositionComp.GetPosition());

            Physics.RigidBody.Gravity = grav;
        }
 public EffectSoundEmitter(uint id, Vector3 position, MySoundPair sound)
 {
     ParticleSoundId = id;
     Updated = true;
     MyEntity entity = null;
     if (MyFakes.ENABLE_NEW_SOUNDS && MySession.Static.Settings.RealisticSound)//snap emitter to closest block - used for realistic sounds
     {
         List<MyEntity> m_detectedObjects = new List<MyEntity>();
         BoundingSphereD effectSphere = new BoundingSphereD(MySession.Static.LocalCharacter != null ? MySession.Static.LocalCharacter.PositionComp.GetPosition() : MySector.MainCamera.Position, 2f);
         MyGamePruningStructure.GetAllEntitiesInSphere(ref effectSphere, m_detectedObjects);
         float distBest = float.MaxValue;
         float dist;
         for (int i = 0; i < m_detectedObjects.Count; i++)
         {
             MyCubeBlock block = m_detectedObjects[i] as MyCubeBlock;
             if (block != null)
             {
                 dist = Vector3.DistanceSquared(MySession.Static.LocalCharacter.PositionComp.GetPosition(), block.PositionComp.GetPosition());
                 if (dist < distBest)
                 {
                     dist = distBest;
                     entity = block;
                 }
             }
         }
         m_detectedObjects.Clear();
     }
     Emitter = new MyEntity3DSoundEmitter(entity);
     Emitter.SetPosition(position);
     if (sound == null)
         sound = MySoundPair.Empty;
     Emitter.PlaySound(sound);
     if (Emitter.Sound != null)
         OriginalVolume = Emitter.Sound.Volume;
     else
         OriginalVolume = 1f;
     Emitter.Update();
     SoundPair = sound;
 }
            public override void UpdateBeforeSimulation100()
            {
                base.UpdateBeforeSimulation100();
                if (m_particleVectorUp == Vector3.Zero)
                {
                    if (Entity.Physics.LinearVelocity != Vector3.Zero)
                    {
                        m_particleVectorUp = -Vector3.Normalize(Entity.Physics.LinearVelocity);
                    }
                    else
                    {
                        m_particleVectorUp = Vector3.Up;
                    }
                    m_particleVectorUp.CalculatePerpendicularVector(out m_particleVectorForward);
                }

                if (m_dustEffect != null && !InParticleVisibleRange)
                {
                    m_dustEffect.Stop();
                    m_dustEffect = null;
                }

                if (m_dustEffect == null && Entity.PositionComp.Scale > 1.5 && InParticleVisibleRange)
                {
                    if (MyParticlesManager.TryCreateParticleEffect(m_particleEffectId, out m_dustEffect))
                    {
                        UpdateParticlePosition();
                        m_dustEffect.UserScale = Entity.PositionComp.Scale.Value / 5;
                    }
                }

                m_soundEmitter.Update();

                if (Sync.IsServer && MySandboxGame.TotalGamePlayTimeInMilliseconds - m_timeCreated > Math.Min(MAX_TRAJECTORY_LENGTH / MIN_SPEED, MAX_TRAJECTORY_LENGTH / Entity.Physics.LinearVelocity.Length()) * 1000)
                {
                    CloseMeteorInternal();
                }
            }