Exemple #1
0
        public override void UpdateBeforeSimulation()
        {
            //We dont want to update every frame because of this
            //Visible = IsDummyVisible();

            base.UpdateBeforeSimulation();

            if ((DummyFlags & MyDummyPointFlags.PARTICLE) != 0 &&
                ParticleEffect == null &&
                //MyGuiScreenGamePlay.Static.IsGameActive() &&
                (PersistentFlags & MyPersistentEntityFlags.Enabled) > 0)
            {
                StartEffect();
            }

            if (ParticleEffect != null &&
                //((MyGuiScreenGamePlay.Static.IsEditorActive() && !MyGuiScreenGamePlay.Static.IsIngameEditorActive()) ||
                (DummyFlags & MyDummyPointFlags.PARTICLE) == 0)
            {
                StopEffect();
            }

            if (m_cue != null && m_cue.Value.IsPlaying)
            {
                MyAudio.UpdateCuePosition(m_cue, WorldMatrix.Translation, WorldMatrix.Forward, WorldMatrix.Up, Vector3.Zero);
            }

            if (DoesParticleEffectNeedDetector())
            {
                RefreshParticleSound();

                if (m_smallShipDetector == null)
                {
                    RefreshParticleEffect();
                }

                foreach (var detectedEntityPair in m_smallShipDetector.GetDetectedEntities())
                {
                    var detectedSmallShip = (MySmallShip)detectedEntityPair.Key;

                    float distance          = Vector3.Distance(detectedSmallShip.GetPosition(), this.GetPosition());
                    float influenceStrength = MathHelper.Clamp((m_smallShipDetector.Radius - distance) / m_smallShipDetector.Radius, 0f, 1f);

                    if (m_effectHelper.DamageStrength.HasValue)
                    {
                        DamageShip(detectedSmallShip, influenceStrength);
                    }

                    if (m_effectHelper.DirectionalPushStrength.HasValue)
                    {
                        PushShip(detectedSmallShip, distance, influenceStrength);
                    }
                }
            }
        }