Exemplo n.º 1
0
        public override void UpdateBeforeSimulation()
        {
            base.UpdateBeforeSimulation();

            if (m_elapsedMiliseconds > TimeToActivate && !m_smokeFired)
            {
                StartSmokeEffect();
                Physics.LinearVelocity = Vector3.Zero;
                Explode();

                m_smokeCue = MyAudio.AddCue2dOr3d(this, MySoundCuesEnum.WepBombSmartSmoke,
                                                  GetPosition(), WorldMatrix.Forward, WorldMatrix.Up, Physics.LinearVelocity);
            }

            if (m_isExploded)
            {
                var effect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_SmallGunShot);
                effect.WorldMatrix = this.WorldMatrix;
                effect.UserScale   = 2f;
                MarkForClose();
            }

            if (m_smokeEnded)
            {
                MarkForClose();
            }
            else if (m_smokeFired)
            {
                // Aggro near bots
                MyDangerZones.Instance.NotifyArea(GetPosition(), 300, OwnerEntity);
            }
        }
Exemplo n.º 2
0
 void PlayVoxelCutCue()
 {
     if (m_voxelCutCue == null || !m_voxelCutCue.Value.IsPlaying || MySession.Is25DSector)
     {
         m_voxelCutCue = MyAudio.AddCue2dOr3d(Parent, MySoundCuesEnum.SfxVoxelCrack, Parent.GetPosition(), Parent.WorldMatrix.Forward, Parent.WorldMatrix.Up, Parent.Physics.LinearVelocity);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Updates resource.
        /// </summary>
        public override void UpdateBeforeSimulation()
        {
            base.UpdateBeforeSimulation();

            bool decoyLiving = true;

            if (m_elapsedMiliseconds > TimeToActivate)
            {
                decoyLiving = UpdateParticles();
                this.Physics.LinearVelocity = Vector3.Zero;

                if (this.Visible)
                {
                    this.Visible = false;
                    m_flareLoop  = MyAudio.AddCue2dOr3d(this, MySoundCuesEnum.SfxFlareLoop01,
                                                        GetPosition(), WorldMatrix.Forward, WorldMatrix.Up, Physics.LinearVelocity);
                }
            }

            if (!decoyLiving)
            {
                MarkForClose();
            }
            else
            {
                // Aggro near bots
                MyDangerZones.Instance.NotifyArea(GetPosition(), 300, OwnerEntity);

                if (m_flareLoop != null && m_flareLoop.Value.IsPlaying)
                {
                    MyAudio.UpdateCuePosition(m_flareLoop, WorldMatrix.Translation, WorldMatrix.Forward, WorldMatrix.Up, Physics.LinearVelocity);
                }
            }
        }
Exemplo n.º 4
0
        protected void StopDrillingCue()
        {
            if (m_drillCue != null && m_drillCue.Value.IsPlaying)
            {
                m_drillCue.Value.Stop(SharpDX.XACT3.StopFlags.Release);
                if (m_drillCueReleaseEnum != null)
                {
                    MySoundCuesEnum releaseCue;
                    if ((m_drillCue.Value.CueEnum == m_drillOtherCueEnum ||
                         m_drillCue.Value.CueEnum == MyAudio.GetVersion2D(m_drillOtherCueEnum.Value)) &&
                        m_drillOtherCueReleaseEnum.HasValue)
                    {
                        releaseCue = m_drillOtherCueReleaseEnum.Value;
                    }
                    else
                    {
                        releaseCue = m_drillCueReleaseEnum.Value;
                    }

                    if (m_drillCueRelease == null || !m_drillCueRelease.Value.IsPlaying)
                    {
                        m_drillCueRelease = MyAudio.AddCue2dOr3d(Parent, releaseCue, WorldMatrix.Translation, WorldMatrix.Forward,
                                                                 WorldMatrix.Up, this.Parent.Physics.LinearVelocity);
                    }
                }
            }
        }
Exemplo n.º 5
0
 void StartDrillBlastOtherCue()
 {
     if ((m_drillBlastCue == null) || (m_drillBlastCue.Value.IsPlaying == false))
     {
         m_drillBlastCue = MyAudio.AddCue2dOr3d(Parent, MySoundCuesEnum.VehToolPressureDrillBlastOther3d, WorldMatrix.Translation,
                                                WorldMatrix.Forward, WorldMatrix.Up, this.Parent.Physics.LinearVelocity);
     }
 }
Exemplo n.º 6
0
 private void StartPressureIdleCue()
 {
     if (m_pressureIdleCue == null || m_pressureIdleCue.Value.IsPlaying == false)
     {
         m_pressureIdleCue = MyAudio.AddCue2dOr3d(Parent, MySoundCuesEnum.VehToolPressureDrillIdle3d, WorldMatrix.Translation,
                                                  WorldMatrix.Forward, WorldMatrix.Up, this.Parent.Physics.LinearVelocity);
     }
 }
Exemplo n.º 7
0
 void StartImplodeCue()
 {
     if ((m_implodeCue == null) || (m_implodeCue.Value.IsPlaying == false))
     {
         m_implodeCue = MyAudio.AddCue2dOr3d(this, MySoundCuesEnum.VehHarvesterTubeImplode2d, m_headPositionTransformed,
                                             WorldMatrix.Forward, WorldMatrix.Up, Parent.Physics.LinearVelocity);
     }
 }
Exemplo n.º 8
0
 void StopGrindingCue()
 {
     if ((m_grindingCue != null) && (m_grindingCue.Value.IsPlaying == true))
     {
         m_grindingCue.Value.Stop(SharpDX.XACT3.StopFlags.Immediate);
         m_grindingReleaseCue = MyAudio.AddCue2dOr3d(this, MySoundCuesEnum.VehHarvesterTubeRelease2d, m_headPositionTransformed, WorldMatrix.Forward,
                                                     WorldMatrix.Up, Parent.Physics.LinearVelocity);
     }
 }
Exemplo n.º 9
0
 //  When tube collided with something so we must pull it back quickly, so player won't notice intersection
 void StartFastReturningBack()
 {
     CurrentState = MyHarvestingDeviceEnum.FastReturningBack;
     m_parentMinerShip.Physics.Immovable = false;
     MyAudio.AddCue2dOr3d(Parent, MySoundCuesEnum.VehHarvesterTubeCollision2d,
                          Parent.GetPosition(), Parent.WorldMatrix.Forward, Parent.WorldMatrix.Up, Parent.Physics.LinearVelocity);
     StopGrindingCue();
     StopTubeMovingCue();
     CloseEffect();
 }
Exemplo n.º 10
0
 protected void StopMovingCue()
 {
     if ((m_movingCue != null) /* && m_movingCue.Value.IsPlaying*/)
     {
         m_movingCue.Value.Stop(SharpDX.XACT3.StopFlags.Immediate);
         if (m_movingCueReleaseEnum != null)
         {
             m_movingCueRelease = MyAudio.AddCue2dOr3d(Parent, m_movingCueReleaseEnum.Value,
                                                       Parent.GetPosition(), Parent.WorldMatrix.Forward, Parent.WorldMatrix.Up, Parent.Physics.LinearVelocity);
         }
     }
 }
Exemplo n.º 11
0
 protected void StartMovingCue()
 {
     if (m_movingCueEnum != null && (m_movingCue == null) || !m_movingCue.Value.IsPlaying)
     {
         m_movingCue = MyAudio.AddCue2dOr3d(Parent, m_movingCueEnum.Value,
                                            Parent.GetPosition(), Parent.WorldMatrix.Forward, Parent.WorldMatrix.Up, Parent.Physics.LinearVelocity);
     }
     if ((m_movingCueRelease != null) && m_movingCueRelease.Value.IsPlaying)
     {
         m_movingCueRelease.Value.Stop(SharpDX.XACT3.StopFlags.Immediate);
     }
     StopIdleCue();
 }
Exemplo n.º 12
0
        protected void StartIdleCue()
        {
            if (m_idleCueEnum != null && (m_idleCue == null || m_idleCue.Value.IsPlaying == false))
            {
                m_idleCue = MyAudio.AddCue2dOr3d(Parent, m_idleCueEnum.Value, WorldMatrix.Translation,
                                                 WorldMatrix.Forward, WorldMatrix.Up, this.Parent.Physics.LinearVelocity);
            }

            /*if ((m_drillCueRelease != null) && m_drillCueRelease.Value.IsPlaying)
             * {
             *  m_drillCueRelease.Value.Stop(SharpDX.XACT3.StopFlags.Release);
             * }*/
            StopDrillingCue();
        }
Exemplo n.º 13
0
 protected void StartDrillingCue(bool mining)
 {
     if (!mining && (m_drillOtherCueEnum.HasValue && (m_drillCue == null || !m_drillCue.Value.IsPlaying)))
     {
         m_drillCue = MyAudio.AddCue2dOr3d(Parent, m_drillOtherCueEnum.Value, WorldMatrix.Translation,
                                           WorldMatrix.Forward, WorldMatrix.Up, this.Parent.Physics.LinearVelocity);
     }
     else if (m_drillCueEnum.HasValue && (m_drillCue == null || !m_drillCue.Value.IsPlaying) || MySession.Is25DSector)
     {
         if (!MySession.Is25DSector)
         {
             m_drillCue = MyAudio.AddCue2dOr3d(Parent, m_drillCueEnum.Value, WorldMatrix.Translation,
                                               WorldMatrix.Forward, WorldMatrix.Up, this.Parent.Physics.LinearVelocity);
         }
     }
     StopIdleCue();
 }
Exemplo n.º 14
0
        //  This method realy initiates/starts the missile
        //  IMPORTANT: Direction vector must be normalized!
        public void Start(Vector3 position, Vector3 initialVelocity, Vector3 direction, float impulseMultiplier, MyEntity owner)
        {
            m_elapsedMiliseconds = 0;
            if (!TimeToActivate.HasValue)
            {
                //TimeToActivate = MyTimeBombConstants.TIMEOUT_ARRAY[m_ammoTimeoutIndex] * 1000;

                var ownerShip = owner as MySmallShip;
                Debug.Assert(ownerShip != null);
                if (ownerShip != null)
                {
                    TimeToActivate = ownerShip.Config.TimeBombTimer.CurrentValue * 1000;
                }
            }

            m_timingCue = MyAudio.AddCue2dOr3d(this, MySoundCuesEnum.WepBombSmartTimer,
                                               GetPosition(), WorldMatrix.Forward, WorldMatrix.Up, Physics.LinearVelocity);


            FormatName();

            base.Start(position, initialVelocity, direction, impulseMultiplier, owner, m_timeBombHUDBuilder);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Initialize flares to fire
        /// </summary>
        private void FireFlares()
        {
            m_flareDeploy = MyAudio.AddCue2dOr3d(this, MySoundCuesEnum.SfxFlareDeploy,
                                                 GetPosition(), WorldMatrix.Forward, WorldMatrix.Up, Physics.LinearVelocity);

            MyAudio.UpdateCuePosition(m_flareDeploy, GetPosition(), GetForward(), GetUp(), Physics.LinearVelocity);

            foreach (FlareParticle particle in m_particles)
            {
                particle.Position = WorldMatrix.Translation;
                Matrix rot = Matrix.CreateFromAxisAngle(WorldMatrix.Forward, MyMwcUtils.GetRandomFloat(0.0f, MathHelper.TwoPi));
                particle.Dir     = Vector3.TransformNormal(MyUtilRandomVector3ByDeviatingVector.GetRandom(WorldMatrix.Up, 0.2f), rot);
                particle.FlyTime = MyMwcUtils.GetRandomFloat(500, 8000);
                particle.Life    = MyMwcUtils.GetRandomFloat(8000, MyDecoyFlareConstants.MAX_LIVING_TIME);

                var effect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.UniversalLauncher_DecoyFlare);
                effect.UserBirthMultiplier = 0.3f;
                particle.ParticleEffect    = effect;
            }

            m_startParticleTime = MyMinerGame.TotalGamePlayTimeInMilliseconds;
            m_flaresFired       = true;
        }
Exemplo n.º 16
0
        public override bool StartShooting()
        {
            if (!base.StartShooting())
            {
                return(false);
            }

            if ((MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < MyAutocanonConstants.SHOT_INTERVAL_IN_MILISECONDS)
            {
                return(false);
            }

            // Set muzzle flashes:
            m_muzzleFlashLength = MyMwcUtils.GetRandomFloat(4, 6);
            m_muzzleFlashRadius = MyMwcUtils.GetRandomFloat(1.2f, 2.0f);

            // Increse smoke to generate
            IncreaseSmoke();

            // Make random trajectories for the bullet:
            Matrix worldMatrix = WorldMatrix;
            // get muzzle flashes:
            List <MyModelDummy> muzzles = GetMuzzleFlashMatrix();

            muzzleFlashPosition1 = MyUtils.GetTransform(muzzles[0].Matrix.Translation, ref worldMatrix);
            muzzleFlashPosition2 = MyUtils.GetTransform(muzzles[1].Matrix.Translation, ref worldMatrix);

            // if (!IsControlledByPlayer())
            {
                if (m_shotSmoke == null)
                {
                    m_shotSmoke            = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_LargeGunShot);
                    m_shotSmoke.AutoDelete = false;
                }
                m_shotSmoke.UserEmitterScale = m_smokeToGenerate;
                m_shotSmoke.WorldMatrix      = Matrix.CreateTranslation(muzzleFlashPosition1);

                if (m_shotSmoke2 == null)
                {
                    m_shotSmoke2            = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_LargeGunShot);
                    m_shotSmoke2.AutoDelete = false;
                }
                m_shotSmoke2.UserEmitterScale = m_smokeToGenerate;
                m_shotSmoke2.WorldMatrix      = Matrix.CreateTranslation(muzzleFlashPosition2);
            }

            int randSoundSource = MyMwcUtils.GetRandomInt(2);

            MySoundCue?shootingSound = GetWeaponBase().UnifiedWeaponCueGet(MySoundCuesEnum.WepMachineGunNormFire3d);

            if (shootingSound == null || !shootingSound.Value.IsPlaying)
            {
                GetWeaponBase().UnifiedWeaponCueSet(Audio.MySoundCuesEnum.WepMachineGunNormFire3d,
                                                    MyAudio.AddCue2dOr3d(this.GetWeaponBase().PrefabParent, Audio.MySoundCuesEnum.WepMachineGunNormFire3d, randSoundSource == 1 ? muzzleFlashPosition1 : muzzleFlashPosition2, WorldMatrix.Forward, WorldMatrix.Up, Vector3.Zero));
                //MyAudio.AddCue3D(Audio.MySoundCuesEnum.WepAutocanonFire3d, randSoundSource == 1 ? muzzleFlashPosition1 : muzzleFlashPosition2, WorldMatrix.Forward, WorldMatrix.Up, Vector3.Zero));
            }

            AddProjectile(MyAmmoConstants.GetAmmoProperties(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic), muzzleFlashPosition1);
            AddProjectile(MyAmmoConstants.GetAmmoProperties(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic), muzzleFlashPosition2);

            m_lastTimeShoot = MyMinerGame.TotalGamePlayTimeInMilliseconds;

            return(true);
        }
Exemplo n.º 17
0
        public override bool StartShooting()
        {
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyLargeShipMissileLauncherBarrel::StartShooting");

            LastShotId = null;

            int missileShotInterval = 0;

            MyLargeShipGunBase.GetMissileAmmoParams(GetAmmoType(), ref missileShotInterval);
            if ((MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < missileShotInterval)
            {
                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                return(false);
            }

            m_burstFinish = false;
            while (!m_burstFinish)
            {
                if (!base.StartShooting())
                {
                    MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                    return(false);
                }

                if (m_groupMask == null)
                {
                    MyPhysics.physicsSystem.GetRigidBodyModule().GetGroupMaskManager().GetGroupMask(ref m_groupMask);
                }

                MyEntity target = ((MyLargeShipGunBase)Parent).GetTarget();

                List <MyModelDummy> muzzles = GetMuzzleFlashMatrix();
                m_activeMuzzle = --m_burstToFire;

                Matrix  worldMatrix         = WorldMatrix;
                Vector3 muzzleFlashPosition = MyUtils.GetTransform(muzzles[m_activeMuzzle].Matrix.Translation, ref worldMatrix);


                if (IsControlledByPlayer())
                {
                    //target = MySession.PlayerShip.TargetEntity as MySmallShip;
                    target = MyEnemyTargeting.SwitchNextTarget(true);
                }

                if (target != null || IsControlledByPlayer())
                {
                    MySoundCue?shootingSound = GetWeaponBase().UnifiedWeaponCueGet(MySoundCuesEnum.WepMissileLaunch3d);
                    if (shootingSound == null || !shootingSound.Value.IsPlaying)
                    {
                        GetWeaponBase().UnifiedWeaponCueSet(Audio.MySoundCuesEnum.WepMissileLaunch3d,
                                                            MyAudio.AddCue2dOr3d(this.GetWeaponBase().PrefabParent, Audio.MySoundCuesEnum.WepMissileLaunch3d, muzzleFlashPosition, WorldMatrix.Forward, WorldMatrix.Up, Vector3.Zero));
                        //MyAudio.AddCue2dOr3d(this.GetWeaponBase().PrefabParent, Audio.MySoundCuesEnum.WepMissileLaunch3d, muzzleFlashPosition, WorldMatrix.Forward, WorldMatrix.Up, Vector3.Zero);
                    }

                    Vector3 deviateVector = GetDeviatedVector(MyAmmoConstants.GetAmmoProperties(GetAmmoType()));

                    var missile = MyMissiles.Add(GetAmmoType(), muzzleFlashPosition + 2 * WorldMatrix.Forward, WorldMatrix.Forward * 2.0f, deviateVector, Vector3.Zero, this, target, SearchingDistance, isLightWeight: true);
                    if (missile.GuidedInMultiplayer)
                    {
                        missile.EntityId = MyEntityIdentifier.AllocateId();
                        MyEntityIdentifier.AddEntityWithId(missile);
                        LastShotId = missile.EntityId;
                    }
                }


                if (m_burstToFire <= 0)
                {
                    m_burstFireTime_ms = MyMinerGame.TotalGamePlayTimeInMilliseconds;
                    m_burstToFire      = m_burstFireCount;
                    m_burstFinish      = true;
                }
                if ((MyMinerGame.TotalGamePlayTimeInMilliseconds - m_burstFireTime_ms) > m_burstFireTimeLoadingIntervalConst_ms)
                {
                    m_burstFinish = false;
                }

                if (!IsControlledByPlayer())
                {
                    m_burstFinish = true;
                }
            }

            m_lastTimeShoot = MyMinerGame.TotalGamePlayTimeInMilliseconds;

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

            return(true);
        }
Exemplo n.º 18
0
 protected void AddWeaponCue(MySoundCuesEnum cueEnum)
 {
     GetParentMinerShip().UnifiedWeaponCueSet(cueEnum, MyAudio.AddCue2dOr3d(GetParentMinerShip(), cueEnum,
                                                                            m_positionMuzzleInWorldSpace, Parent.WorldMatrix.Forward, Parent.WorldMatrix.Up, Parent.Physics.LinearVelocity));
 }
Exemplo n.º 19
0
        //  Every child of this base class must implement Shot() method, which shots projectile or missile.
        //  Method returns true if something was shot. False if not (because interval between two shots didn't pass)
        public override bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo)
        {
            if (GetParentMinerShip() == null)
            {
                return(false);
            }

            //  Allow shoting only at intervals
            if ((MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < MyAutocanonConstants.SHOT_INTERVAL_IN_MILISECONDS && !IsDummy)
            {
                return(false);
            }
            //  Stop 'release cue' if playing
            MySoundCue?autocanonReleaseCue = GetParentMinerShip().UnifiedWeaponCueGet(AUTOCANON_RELEASE);

            if ((autocanonReleaseCue != null) && (autocanonReleaseCue.Value.IsPlaying == true))
            {
                autocanonReleaseCue.Value.Stop(SharpDX.XACT3.StopFlags.Immediate);
            }

            //  Angle of muzzle flash particle
            m_muzzleFlashLength = MyMwcUtils.GetRandomFloat(3, 4) * m_barrel.GetMuzzleSize();
            m_muzzleFlashRadius = MyMwcUtils.GetRandomFloat(1.8f, 2.2f) * m_barrel.GetMuzzleSize();

            //  Increase count of smokes to draw
            SmokesToGenerateIncrease();

            //Use looping cue only in playership
            MySoundCuesEnum attackCue = GetParentMinerShip() == MySession.PlayerShip ? AUTOCANON_ATTACK_LOOP : AUTOCANON_ATTACK;

            //  Start 'attack and loop' cue (shooting)
            MySoundCue?autocanonAttackLoopCue = GetParentMinerShip().UnifiedWeaponCueGet(attackCue);

            if ((autocanonAttackLoopCue == null) || (autocanonAttackLoopCue.Value.IsPlaying == false))
            {
                //MyMwcLog.WriteLine("Adding new AUTOCANNON attack loop");
                GetParentMinerShip().UnifiedWeaponCueSet(
                    attackCue,
                    MyAudio.AddCue2dOr3d(GetParentMinerShip(), attackCue,
                                         m_positionMuzzleInWorldSpace, WorldMatrix.Forward, WorldMatrix.Up, Parent.Physics.LinearVelocity));
            }

            MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammoType = MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic;

            if (usedAmmo != null) //TODO: bot fires without ammo
            {
                ammoType = usedAmmo.AmmoType;
            }

            MyAmmoProperties ammoProperties = MyAmmoConstants.GetAmmoProperties(ammoType);

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyAutocannonGun.Shot add projectile");

            if (MyMwcFinalBuildConstants.ENABLE_TRAILER_SAVE)
            {
                MinerWars.AppCode.Game.Trailer.MyTrailerSave.UpdateGunShot(this.Parent, Trailer.MyTrailerGunsShotTypeEnum.PROJECTILE);
            }

            AddProjectile(ammoProperties, this);
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

            m_cannonMotorEndPlayed = false;
            m_lastTimeShoot        = MyMinerGame.TotalGamePlayTimeInMilliseconds;

            //  We shot one projectile
            return(true);
        }
Exemplo n.º 20
0
        public override void UpdateAfterSimulation()
        {
            base.UpdateAfterSimulation();

            //  Cannon is rotating while shoting. After that, it will slow-down.
            float normalizedRotationSpeed = 1.0f - MathHelper.Clamp((float)(MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) / m_rotationTimeout, 0, 1);

            normalizedRotationSpeed = MathHelper.SmoothStep(0, 1, normalizedRotationSpeed);
            m_rotationAngle        -= normalizedRotationSpeed * MyAutocanonConstants.ROTATION_SPEED_PER_SECOND * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS;

            Matrix worldMatrix = this.WorldMatrix;

            m_positionMuzzleInWorldSpace = GetMuzzlePosition(m_barrel.GetMuzzlePosition());
            m_barrel.SetData(ref m_worldMatrixForRenderingFromCockpitView, m_rotationAngle);

            //  Handle 'motor loop and motor end' cues
            if ((m_cannonMotorEndPlayed == false) && ((MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) > MyAutocanonConstants.SHOT_INTERVAL_IN_MILISECONDS))
            {
                //  Stop 'shooting loop' cue
                if (MyMinerGame.TotalGamePlayTimeInMilliseconds > m_lastTimeShoot + MyAutocanonConstants.MIN_TIME_RELEASE_INTERVAL_IN_MILISECONDS)
                {
                    MySoundCue?autocanonAttackLoopCue = GetParentMinerShip().UnifiedWeaponCueGet(AUTOCANON_ATTACK_LOOP);
                    if ((autocanonAttackLoopCue != null) && (autocanonAttackLoopCue.Value.IsPlaying == true))
                    {
                        autocanonAttackLoopCue.Value.Stop(SharpDX.XACT3.StopFlags.Immediate);
                    }
                    autocanonAttackLoopCue = GetParentMinerShip().UnifiedWeaponCueGet(AUTOCANON_ATTACK);
                    if ((autocanonAttackLoopCue != null) && (autocanonAttackLoopCue.Value.IsPlaying == true))
                    {
                        autocanonAttackLoopCue.Value.Stop(SharpDX.XACT3.StopFlags.Immediate);
                    }

                    //  Start 'release' cue
                    MySoundCue?autocanonReleaseCue = GetParentMinerShip().UnifiedWeaponCueGet(AUTOCANON_RELEASE);
                    if ((autocanonReleaseCue == null) || (autocanonReleaseCue.Value.IsPlaying == false))
                    {
                        GetParentMinerShip().UnifiedWeaponCueSet(
                            AUTOCANON_RELEASE,
                            MyAudio.AddCue2dOr3d(GetParentMinerShip(), AUTOCANON_RELEASE,
                                                 Parent.GetPosition(), Parent.WorldMatrix.Forward, Parent.WorldMatrix.Up,
                                                 Parent.Physics.LinearVelocity));
                    }

                    m_cannonMotorEndPlayed = true;
                }
            }

            //  Update sound position
            MySoundCue?updateAutocanonAttackLoopCue = GetParentMinerShip().UnifiedWeaponCueGet(AUTOCANON_ATTACK_LOOP);

            if ((updateAutocanonAttackLoopCue != null) && (updateAutocanonAttackLoopCue.Value.IsPlaying == true))
            {
                MyAudio.UpdateCuePosition(updateAutocanonAttackLoopCue, m_positionMuzzleInWorldSpace, WorldMatrix.Forward,
                                          WorldMatrix.Up, Parent.Physics.LinearVelocity);
            }
            updateAutocanonAttackLoopCue = GetParentMinerShip().UnifiedWeaponCueGet(AUTOCANON_ATTACK);
            if ((updateAutocanonAttackLoopCue != null) && (updateAutocanonAttackLoopCue.Value.IsPlaying == true))
            {
                MyAudio.UpdateCuePosition(updateAutocanonAttackLoopCue, m_positionMuzzleInWorldSpace, WorldMatrix.Forward,
                                          WorldMatrix.Up, Parent.Physics.LinearVelocity);
            }

            //  Update sound position
            MySoundCue?updateAutocanonReleaseCue = GetParentMinerShip().UnifiedWeaponCueGet(AUTOCANON_RELEASE);

            if ((updateAutocanonReleaseCue != null) && (updateAutocanonReleaseCue.Value.IsPlaying == true))
            {
                MyAudio.UpdateCuePosition(updateAutocanonReleaseCue, m_positionMuzzleInWorldSpace, WorldMatrix.Forward,
                                          WorldMatrix.Up, Parent.Physics.LinearVelocity);
            }

            //  If gun fires too much, we start generating smokes at the muzzle
            if ((MyMinerGame.TotalGamePlayTimeInMilliseconds - m_smokeLastTime) >= (MyAutocanonConstants.SMOKES_INTERVAL_IN_MILISECONDS))
            {
                m_smokeLastTime = MyMinerGame.TotalGamePlayTimeInMilliseconds;

                SmokesToGenerateDecrease();

                if (m_smokesToGenerate > 0 && m_smokeEffect == null)
                {
                    if (MyCamera.GetDistanceWithFOV(GetPosition()) < 150)
                    {
                        m_smokeEffect             = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_Autocannon);
                        m_smokeEffect.WorldMatrix = WorldMatrix;
                        m_smokeEffect.OnDelete   += new EventHandler(m_smokeEffect_OnDelete);
                    }
                }
            }

            if (m_smokeEffect != null)
            {
                float smokeOffset = 0.2f;
                if ((MinerWars.AppCode.Game.GUI.MyGuiScreenGamePlay.Static.CameraAttachedTo == MinerWars.AppCode.Game.GUI.MyCameraAttachedToEnum.PlayerMinerShip) &&
                    (Parent == MySession.PlayerShip))
                {
                    smokeOffset = 0.0f;
                }

                m_smokeEffect.WorldMatrix         = Matrix.CreateTranslation(m_positionMuzzleInWorldSpace + worldMatrix.Forward * smokeOffset);
                m_smokeEffect.UserBirthMultiplier = m_smokesToGenerate;
            }
        }