Esempio n. 1
0
        //  Kills this missile. Must be called at her end (after explosion or timeout)
        //  This method must be called when this object dies or is removed
        //  E.g. it removes lights, sounds, etc
        protected override void Closing()
        {
            base.Closing();

            if (this.Physics != null)
            {
                MyMissiles.Remove(this);
            }

            if (m_collidedEntity != null)
            {
                m_collidedEntity.OnClose -= m_collidedEntity_OnClose;
                m_collidedEntity          = null;
            }

            if (m_smokeEffect != null)
            {
                m_smokeEffect.Stop();
                m_smokeEffect = null;
            }

            //  Free the light
            if (m_light != null)
            {
                MyLights.RemoveLight(m_light);
                m_light = null;
            }

            //  Stop cue (needed because sound is looping)
            m_soundEmitter.StopSound(true);
        }
 private void UpdateParticleEffect()
 {
     if (_effectCachedModel != _reactor.Model)
     {
         _effectCachedModel = _reactor.Model;
         var tmp = new Dictionary <string, IMyModelDummy>();
         _effectCachedModel?.GetDummies(tmp);
         _effectMatrix = tmp.GetValueOrDefault("subpart_PlasmaParticle")?.Matrix; // empty for particle
     }
     if (_reactor.IsWorking && _effectMatrix.HasValue)
     {
         var fractionalOutput = _reactor.CurrentOutput / _reactor.MaxOutput;
         var dTheta           = MAX_RATE * fractionalOutput * MyEngineConstants.PHYSICS_STEP_SIZE_IN_SECONDS;
         _effectMatrix = _effectMatrix.Value * MatrixD.CreateRotationY(dTheta);
         if (_effect == null)
         {
             MyParticlesManager.TryCreateParticleEffect("PlasmaSparks", out _effect); // particle subtype
         }
         _effect.WorldMatrix = _effectMatrix.Value * _reactor.WorldMatrix;
         _effect.Velocity    = _reactor.CubeGrid.Physics?.GetVelocityAtPoint(_effect.WorldMatrix.Translation) ?? Vector3.Right; // rotation
     }
     else
     {
         _effect?.Stop();
         if (_effect != null)
         {
             MyParticlesManager.RemoveParticleEffect(_effect);
         }
         _effect = null;
     }
 }
Esempio n. 3
0
        public override void UpdateAfterSimulation()
        {
            base.UpdateAfterSimulation();

            if (CurrentState == MyDrillStateEnum.Drilling)
            {
                if (m_trailEffect == null)
                {
                    m_trailEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Drill_Thermal);

                    //Must be done with handler because we need to set world matrix until effect totally dies
                    m_trailEffect.OnDelete += OnTrailEffectDeleted;
                }
            }
            else
            {
                if (m_trailEffect != null)
                {
                    m_trailEffect.Stop();
                    m_trailEffect = null;
                }
            }

            if (m_trailEffect != null)
            {
                Matrix effectMatrix = Matrix.CreateWorld(m_positionMuzzleInWorldSpace + MySmallShipConstants.ALL_SMALL_SHIP_MODEL_SCALE * 2 * WorldMatrix.Forward, WorldMatrix.Forward, WorldMatrix.Up);
                m_trailEffect.WorldMatrix = effectMatrix;
            }

            if (m_drillHead != null)
            {
                m_drillHead.SetWorldMatrixForCockpit(ref m_worldMatrixForRenderingFromCockpitView);
                m_drillHead.RotationSpeed = -m_rotatingSpeed;
            }
        }
Esempio n. 4
0
            private void DestroyMeteor()
            {
                MyParticleEffect impactParticle;

                if (InParticleVisibleRange && MyParticlesManager.TryCreateParticleEffect("Meteorit_Smoke1AfterHit", out impactParticle))
                {
                    impactParticle.WorldMatrix = Entity.WorldMatrix;
                    impactParticle.UserScale   = 5 * MyUtils.GetRandomFloat(0.8f, 1.2f);
                }
                if (m_dustEffect != null)
                {
                    m_dustEffect.Stop();
                    if (MySession.Static.EnvironmentHostility != MyEnvironmentHostilityEnum.CATACLYSM_UNREAL)
                    {
                        m_dustEffect.Close(false);
                        if (InParticleVisibleRange && m_particleVectorUp != Vector3.Zero && MyParticlesManager.TryCreateParticleEffect("Meteorit_Smoke1AfterHit", out m_dustEffect))
                        {
                            MatrixD m = MatrixD.CreateWorld(Entity.WorldMatrix.Translation, m_particleVectorForward, m_particleVectorUp);
                            m_dustEffect.WorldMatrix = m;
                        }
                    }
                    m_dustEffect = null;
                }
                if (m_dustEffect != null)
                {
                    m_dustEffect.Stop();
                    m_dustEffect = null;
                }
                PlayExplosionSound();
            }
        static void CreateAutocannonHitMaterialParticles(ref Vector3 hitPoint, ref Vector3 normal, ref Vector3 direction, MyEntity physObject, MySurfaceImpactEnum surfaceImpact, MyEntity weapon)
        {
            Vector3 reflectedDirection = Vector3.Reflect(direction, normal);

            MyParticleEffect effect = null;

            switch (surfaceImpact)
            {
            case MySurfaceImpactEnum.METAL:
                effect = GetEffectForWeapon(weapon, (int)MyParticleEffectsIDEnum.MaterialHit_Autocannon_Metal);
                break;

            case MySurfaceImpactEnum.DESTRUCTIBLE:
                effect = GetEffectForWeapon(weapon, (int)MyParticleEffectsIDEnum.MaterialHit_Autocannon_Destructible);
                break;

            case MySurfaceImpactEnum.INDESTRUCTIBLE:
                effect = GetEffectForWeapon(weapon, (int)MyParticleEffectsIDEnum.MaterialHit_Autocannon_Indestructible);
                break;

            default:
                System.Diagnostics.Debug.Assert(false);
                break;
            }
            Matrix dirMatrix = MyMath.MatrixFromDir(reflectedDirection);

            effect.WorldMatrix = Matrix.CreateWorld(hitPoint, dirMatrix.Forward, dirMatrix.Up);
        }
Esempio n. 6
0
        public override bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo)
        {
            if (usedAmmo == null || (MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < MyMachineGunConstants.SHOT_INTERVAL_IN_MILISECONDS && !IsDummy)
            {
                return(false);
            }

            if (m_smokeEffect == null)
            {
                if (MyCamera.GetDistanceWithFOV(GetPosition()) < 150)
                {
                    m_smokeEffect             = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_Autocannon);
                    m_smokeEffect.WorldMatrix = WorldMatrix;
                    m_smokeEffect.OnDelete   += OnSmokeEffectDelete;
                }
            }

            MyAmmoProperties ammoProperties = MyAmmoConstants.GetAmmoProperties(usedAmmo.AmmoType);

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

            AddProjectile(ammoProperties, this);

            m_lastTimeShoot = MyMinerGame.TotalGamePlayTimeInMilliseconds;
            StartLoopSound(ammoProperties.ShotSound);

            return(true);
        }
Esempio n. 7
0
        public override void UpdateAfterSimulation100()
        {
            base.UpdateAfterSimulation100();

            if (m_producedSinceLastUpdate)
            {
                if (m_effect == null)
                {
                    CreateEffect();
                }
            }
            else
            {
                if (m_effect != null)
                {
                    m_effect.Stop();
                    m_effect = null;
                }
            }

            if (MyFakes.ENABLE_OXYGEN_SOUNDS)
            {
                UpdateSound();
            }

            m_isProducing             = m_producedSinceLastUpdate;
            m_producedSinceLastUpdate = false;

            UdpateTexts();
        }
Esempio n. 8
0
        public void Start(Vector3 direction, int?trailEffectId)
        {
            this.Physics.LinearVelocity  = direction;
            this.Physics.AngularVelocity = new Vector3(MyMwcUtils.GetRandomFloat(0.2f, 1.5f), MyMwcUtils.GetRandomFloat(0.2f, 1.5f), 0);

            if (m_size == 0)
            {
                m_size = this.WorldVolume.Radius;
            }

            if (trailEffectId != null)
            {
                m_trailEffect                      = MyParticlesManager.CreateParticleEffect(trailEffectId.Value);
                m_trailEffect.AutoDelete           = true;
                m_trailEffect.UserScale            = this.WorldVolume.Radius / 10;
                m_trailEffect.UserBirthMultiplier /= 2;
                m_trailEffect.WorldMatrix          = this.WorldMatrix;// worldMatrix;
            }

            m_burningCue = MyAudio.AddCue3D(MySoundCuesEnum.SfxMeteorFly, this.GetPosition(), this.GetForward(), Vector3.Up, direction);
            m_startTime  = MyMinerGame.TotalGamePlayTimeInMilliseconds;

            if (MyMultiplayerGameplay.IsHosting)
            {
                MyMultiplayerGameplay.Static.NewEntity(GetObjectBuilder(true), WorldMatrix);
            }
        }
Esempio n. 9
0
            private void DestroyMeteor()
            {
                MyParticleEffect impactParticle;

                if (InParticleVisibleRange && MyParticlesManager.TryCreateParticleEffect((int)MyParticleEffectsIDEnum.MeteorAsteroidCollision, out impactParticle))
                {
                    impactParticle.WorldMatrix = Entity.WorldMatrix;
                    impactParticle.UserScale   = MyUtils.GetRandomFloat(1.5f, 2);
                }
                if (m_dustEffect != null)
                {
                    m_dustEffect.Stop();
                    if (m_particleEffectId == (int)MyParticleEffectsIDEnum.MeteorParticle)
                    {
                        m_dustEffect.Close(false);
                        if (InParticleVisibleRange && m_particleVectorUp != Vector3.Zero && MyParticlesManager.TryCreateParticleEffect((int)MyParticleEffectsIDEnum.MeteorParticleAfterHit, out m_dustEffect))
                        {
                            MatrixD m = MatrixD.CreateWorld(Entity.WorldMatrix.Translation, m_particleVectorForward, m_particleVectorUp);
                            m_dustEffect.WorldMatrix = m;
                        }
                    }
                    m_dustEffect = null;
                }
                PlayExplosionSound();
            }
Esempio n. 10
0
        public override void UpdateAfterSimulation()
        {
            base.UpdateAfterSimulation();

            if (CurrentState == MyDrillStateEnum.Drilling)
            {
                if (m_trailEffect == null)
                {
                    m_trailEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Drill_Thermal);

                    //Must be done with handler because we need to set world matrix until effect totally dies
                    m_trailEffect.OnDelete += OnTrailEffectDeleted;
                }
            }
            else
            {
                if (m_trailEffect != null)
                {
                    m_trailEffect.Stop();
                    m_trailEffect = null;
                }
            }

            if (m_trailEffect != null)
            {
                Matrix effectMatrix = Matrix.CreateWorld(m_positionMuzzleInWorldSpace + MySmallShipConstants.ALL_SMALL_SHIP_MODEL_SCALE * 2 * WorldMatrix.Forward, WorldMatrix.Forward, WorldMatrix.Up);
                m_trailEffect.WorldMatrix = effectMatrix;
            }

            if (m_drillHead != null)
            {
                m_drillHead.SetWorldMatrixForCockpit(ref m_worldMatrixForRenderingFromCockpitView);
                m_drillHead.RotationSpeed = -m_rotatingSpeed;
            }
        }
Esempio n. 11
0
        ////

        public MyParticleEffect CreateParticle(int id)
        {
            //MyParticleEffect effect = Static.GraphicsManager.ParticlesManager.CreateParticleEffect(id);
            MyParticleEffect effect = MyParticlesLibrary.CreateParticleEffect(id);

            return(effect);
        }
Esempio n. 12
0
        //  Kills this missile. Must be called at her end (after explosion or timeout)
        public override void Close()
        {
            base.Close();

            if (m_collidedEntity != null)
            {
                m_collidedEntity.OnClose -= m_collidedEntityClosedHandler;
                m_collidedEntity          = null;
            }

            //  Free the light
            if (m_light != null)
            {
                MyLights.RemoveLight(m_light);
                m_light = null;
            }

            //  Stop thruster cue
            if ((m_thrusterCue != null) && (m_thrusterCue.Value.IsPlaying == true))
            {
                m_thrusterCue.Value.Stop(SharpDX.XACT3.StopFlags.Immediate);
            }

            if (m_smokeEffect != null)
            {
                m_smokeEffect.Stop();
                m_smokeEffect = null;
            }

            MyCannonShots.Remove(this);
        }
Esempio n. 13
0
 public WeaponEffect(MyModelDummy dummy, int effectId, MyWeaponDefinition.WeaponEffectAction action, MyParticleEffect effect)
 {
     this.Dummy    = dummy;
     this.EffectId = effectId;
     this.Effect   = effect;
     this.Action   = action;
 }
Esempio n. 14
0
        private void CreateEffect()
        {
            if (m_effect != null)
            {
                m_effect.Stop();
                m_effect = null;
            }

            if (MyParticlesManager.TryCreateParticleEffect(48, out m_effect))
            {
                Matrix mat;
                Orientation.GetMatrix(out mat);

                var orientation = mat;

                if (IsDepressurizing)
                {
                    orientation.Left    = mat.Right;
                    orientation.Up      = mat.Down;
                    orientation.Forward = mat.Backward;
                }

                orientation             = Matrix.Multiply(orientation, CubeGrid.PositionComp.WorldMatrix.GetOrientation());
                orientation.Translation = CubeGrid.GridIntegerToWorld(Position + mat.Forward / 4f);

                m_effect.WorldMatrix = orientation;

                m_effect.UserScale = 3f;
            }
        }
Esempio n. 15
0
 internal void SetDamageEffect(bool show)
 {
     if (MyFakes.SHOW_DAMAGE_EFFECTS && BlockDefinition.DamageEffectID != null && MySandboxGame.Static.EnableDamageEffects)
     {
         if (!show && m_damageEffect != null)
         {//stop
             m_damageEffect.Stop();
             m_damageEffect = null;
             if (!m_wasUpdatedEachFrame)
             {
                 NeedsUpdate &= ~MyEntityUpdateEnum.EACH_FRAME;
             }
         }
         if (show && m_damageEffect == null)
         {//start
             if (MyParticlesManager.TryCreateParticleEffect((int)BlockDefinition.DamageEffectID, out m_damageEffect))
             {
                 m_damageEffect.UserScale = Model.BoundingBox.Perimeter * .01f;//scale to size of item
                 setDamageWorldMatrix();
                 m_damageEffect.OnDelete  += damageEffect_OnDelete;
                 m_damageEffect.AutoDelete = false;
             }
             m_wasUpdatedEachFrame = (NeedsUpdate & MyEntityUpdateEnum.EACH_FRAME) != 0;
             //Debug.Assert(!m_wasUpdatedEachFrame, "may not t NeedUpdate correctly!");
             NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME;
         }
     }
 }
Esempio n. 16
0
        protected void CreateParticles(Vector3D position, bool createDust, bool createSparks, bool createStones)
        {
            if (m_dustParticles != null && m_dustParticles.IsStopped)
            {
                m_dustParticles = null;
            }

            if (createDust)
            {
                if (m_dustParticles == null)
                {
                    //MyParticleEffectsIDEnum.Smoke_Construction
                    MyParticlesManager.TryCreateParticleEffect(createStones ? (int)m_dustEffectStonesId : (int)m_dustEffectId, out m_dustParticles);
                }

                if (m_dustParticles != null)
                {
                    //m_dustParticles.AutoDelete = false;
                    //m_dustParticles.Near = m_drillEntity.Render.NearFlag;
                    m_dustParticles.WorldMatrix = MatrixD.CreateTranslation(position);
                }
            }

            if (createSparks)
            {
                MyParticleEffect sparks;
                if (MyParticlesManager.TryCreateParticleEffect((int)m_sparksEffectId, out sparks))
                {
                    sparks.WorldMatrix = Matrix.CreateTranslation(position);
                    //sparks.Near = m_drillEntity.Render.NearFlag;
                }
            }
        }
Esempio n. 17
0
        public void LoadParticlesLibrary(string file)
        {
            if (file.Contains(".mwl"))
            {
                MyParticlesLibrary.Deserialize(file);
            }
            else
            {
                ProfilerShort.Begin("Verify Integrity");
                MyDataIntegrityChecker.HashInFile(file);
                MyObjectBuilder_Definitions builder = null;

                ProfilerShort.BeginNextBlock("Parse");
                MyObjectBuilderSerializer.DeserializeXML <MyObjectBuilder_Definitions>(file, out builder);

                if (builder == null || builder.ParticleEffects == null)
                {
                    return;
                }
                else
                {
                    MyParticlesLibrary.Close();
                    foreach (var classDef in builder.ParticleEffects)
                    {
                        MyParticleEffect effect = MyParticlesManager.EffectsPool.Allocate();
                        effect.DeserializeFromObjectBuilder(classDef);
                        MyParticlesLibrary.AddParticleEffect(effect);
                    }
                }

                //definitionBuilders.Add(new Tuple<MyObjectBuilder_Definitions, string>(builder, file));
                ProfilerShort.End();
            }
        }
Esempio n. 18
0
        public override bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo)
        {
            if (usedAmmo == null || (MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < MySniperConstants.SHOT_INTERVAL_IN_MILISECONDS && !IsDummy)
            {
                return(false);
            }

            MyAmmoProperties ammoProperties = MyAmmoConstants.GetAmmoProperties(usedAmmo.AmmoType);

            AddProjectile(ammoProperties, this);

            m_lastTimeShoot = MyMinerGame.TotalGamePlayTimeInMilliseconds;
            AddWeaponCue(ammoProperties.ShotSound);

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

            MyParticleEffect startEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_SmallGunShot);

            startEffect.WorldMatrix = Matrix.CreateWorld(GetMuzzlePosition(), GetForward(), GetUp());

            return(true);
        }
Esempio n. 19
0
 public WeaponEffect(string name, Matrix localMatrix, int effectId, MyWeaponDefinition.WeaponEffectAction action, MyParticleEffect effect)
 {
     this.Name        = name;
     this.EffectId    = effectId;
     this.Effect      = effect;
     this.Action      = action;
     this.LocalMatrix = localMatrix;
 }
 void StopSecondaryEffect()
 {
     if (m_toolSecondaryEffect != null)
     {
         m_toolSecondaryEffect.Stop();
         m_toolSecondaryEffect = null;
     }
 }
Esempio n. 21
0
 public void Stop()
 {
     if (m_effect != null)
     {
         m_effect.Stop();
         m_effect = null;
     }
 }
Esempio n. 22
0
 void Stop()
 {
     if (effect != null)
     {
         effect.Stop();
         effect = null;
     }
 }
Esempio n. 23
0
 private void StopEffect(bool instant = true)
 {
     if (effect != null)
     {
         effect.Stop(instant);
         effect = null;
     }
 }
Esempio n. 24
0
 void m_entity_OnClose(MyEntity obj)
 {
     if (m_shotSmoke != null)
     {
         MyParticlesManager.RemoveParticleEffect(m_shotSmoke);
         m_shotSmoke = null;
     }
 }
Esempio n. 25
0
 protected void StopDustEffect()
 {
     if (m_dustEffect != null)
     {
         m_dustEffect.Stop();
         m_dustEffect = null;
     }
 }
Esempio n. 26
0
 private void StopDustParticles()
 {
     if (DustParticles != null)
     {
         DustParticles.Stop();
         DustParticles = null;
     }
 }
Esempio n. 27
0
 public void StopSparkParticles()
 {
     if (SparkEffect != null)
     {
         SparkEffect.Stop();
         SparkEffect = null;
     }
 }
Esempio n. 28
0
 private void CloseEffect()
 {
     if (m_harvestingParticleEffect != null)
     {
         m_harvestingParticleEffect.Stop();
         m_harvestingParticleEffect = null;
     }
 }
Esempio n. 29
0
 private void StopParticles()
 {
     if (m_dustParticles != null)
     {
         m_dustParticles.Stop();
         m_dustParticles = null;
     }
 }
Esempio n. 30
0
 private void DestroyFxObjects()
 {
     if (_fxImpactParticles != null)
     {
         MyParticlesManager.RemoveParticleEffect(_fxImpactParticles);
         _fxImpactParticles = null;
     }
 }
Esempio n. 31
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();
                }
            }
Esempio n. 32
0
 public override void Close()
 {
     if (m_trailEffect != null)
     {
         m_trailEffect.Stop();
         m_trailEffect = null;
     }
     base.Close();
 }
Esempio n. 33
0
        public override void UpdateAfterSimulation()
        {
            base.UpdateAfterSimulation();

            var muzzlePosition = m_positionMuzzleInWorldSpace;
            muzzlePosition += NearFlag
                                     ? MySmallShipConstants.ALL_SMALL_SHIP_MODEL_SCALE * WorldMatrix.Forward
                                     : .5f * WorldMatrix.Forward;
            if (m_state == PressureState.Pushed && CurrentState == MyDrillStateEnum.Activated)
            {
                StartPressureIdleCue();
            }
            else
            {
                StopPressureIdleCue();
            }

            if ((MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeStarted) >= MyPressureDrillDeviceConstants.SHOT_INTERVAL_IN_MILISECONDS)
            {
                StopDrillingCue();
                StopMovingCue();
                m_state = PressureState.Pushed;

                return;
            }

            if (m_pressureFireEffect != null && !m_pressureFireEffect.IsStopped)
            {
                m_pressureFireEffect.WorldMatrix = Matrix.CreateWorld(
                    muzzlePosition + 1.5f * WorldMatrix.Forward,
                    WorldMatrix.Forward,
                    WorldMatrix.Up);
            }

            switch (m_state)
            {
                case PressureState.Init:
                    StartDrillChargingCue();
                    m_state = PressureState.Charging;

                    m_chargingPressureEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Drill_Pressure_Charge);
                    m_chargingPressureEffect.WorldMatrix = Matrix.CreateWorld(muzzlePosition, WorldMatrix.Forward, WorldMatrix.Up);
                    break;

                case PressureState.Charging:
                    {
                        ((MySmallShip)Parent).IncreaseHeadShake(MyDrillDeviceConstants.SHAKE_DURING_ROTATION);

                        if (m_chargingPressureEffect != null)
                        {
                            m_chargingPressureEffect.WorldMatrix = Matrix.CreateWorld(muzzlePosition, WorldMatrix.Forward, WorldMatrix.Up);
                        }

                        if (m_drillChargingCue == null || !m_drillChargingCue.Value.IsPlaying)
                            m_state = PressureState.Ready;
                    }
                    break;

                case PressureState.Ready:
                    {
                        
                        m_chargingPressureEffect.Stop();
                        m_chargingPressureEffect = null;

                        m_pressureFireEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Drill_Pressure_Fire);
                        m_pressureFireEffect.OnDelete += OnPressureFireEffectDelete;
                        m_pressureFireEffect.WorldMatrix = Matrix.CreateWorld(muzzlePosition, WorldMatrix.Forward, WorldMatrix.Up);

                        //  Check for collision with drill and world
                        MyLine line = new MyLine(GetPosition(), GetPosition() + 2 * m_radius * WorldMatrix.Forward, true);

                        MyIntersectionResultLineTriangleEx? intersection = MyEntities.GetIntersectionWithLine(ref line, Parent, null);

                        if (intersection != null && intersection.Value.Entity.Physics != null)
                        {
                            var voxelMap = intersection.Value.Entity as MyVoxelMap;

                            StartDrillingCue(voxelMap != null);

                            if (voxelMap != null)
                            {

                                ((MySmallShip)Parent).IncreaseHeadShake(MyDrillDeviceConstants.SHAKE_DURING_IN_VOXELS);

                                //  We found voxel so lets make tunel into it
                                BoundingSphere bigSphereForTunnel = new BoundingSphere(GetPosition() + 20 * WorldMatrix.Forward, m_radius);

                                for (int i = 1; i < (int)m_radius; i++)
                                {
                                    bigSphereForTunnel.Center = GetPosition() + (20 + i) * WorldMatrix.Forward;
                                    bigSphereForTunnel.Radius = i * 2;

                                    CutOutFromVoxel(voxelMap, ref bigSphereForTunnel);
                                }

                                CreateImpactEffect(intersection.Value.IntersectionPointInWorldSpace, intersection.Value.NormalInWorldSpace, MyParticleEffectsIDEnum.Drill_Pressure_Impact);
                                StartDrillBlastRockCue();
                            }
                            //  Display particles when we are in contact with voxel
                            else
                            {
                                ((MySmallShip)Parent).IncreaseHeadShake(MyDrillDeviceConstants.SHAKE_DURING_ROTATION);

                                CreateImpactEffect(intersection.Value.IntersectionPointInWorldSpace, intersection.Value.NormalInWorldSpace, MyParticleEffectsIDEnum.Drill_Pressure_Impact_Metal);

                                intersection.Value.Entity.DoDamage(0, m_damage, 0, MyDamageType.Drill, MyAmmoType.Explosive, Parent);

                                StartDrillBlastOtherCue();
                            }

                        }
                        else
                        {
                            StartDrillBlastCue();
                        }
                        m_state = PressureState.Pushed;
                    }
                    break;

                case PressureState.Pushed:
                    {
                        StopDrillingBlastCue();
                        StopMovingCue();
                    }
                    break;
            }
        }
Esempio n. 34
0
 private void OnPressureFireEffectDelete(object sender, EventArgs e)
 {
     m_pressureFireEffect = null;
 }
Esempio n. 35
0
        public override void Close()
        {
            base.Close();

            if (m_chargingPressureEffect != null)
            {
                m_chargingPressureEffect.Stop();
                m_chargingPressureEffect = null;
            }
            if (m_pressureFireEffect != null)
            {
                m_pressureFireEffect.Stop();
                m_pressureFireEffect = null;
            }
            if (m_drillChargingCue != null)
            {
                m_drillChargingCue.Value.Stop(SharpDX.XACT3.StopFlags.Release);
                m_drillChargingCue = null;
            }
        }
Esempio n. 36
0
        public override void Close()
        {
            base.Close();

            if (m_nuclearEffect != null)
            {
                m_nuclearEffect.Stop();
                m_nuclearEffect = null;
            }
        }
Esempio n. 37
0
 private void OnTrailEffectDeleted(object sender, EventArgs e)
 {
     m_trailEffect = null;
 }
Esempio n. 38
0
 protected void StopDustEffect()
 {
     if (m_dustEffect != null)
     {
         m_dustEffect.Stop();
         m_dustEffect = null;
     }
 }
Esempio n. 39
0
 private void OnNuclearEffectDeleted(object sender, EventArgs e)
 {
     m_nuclearEffect = null;
 }