private void CreateCenterSphere(MyEntity block)
        {
            if (block == null || m_centerSphere != null)
            {
                return;
            }

            MyEntitySubpart centerSphereSubpart;

            if (block.TryGetSubpart("sphere", out centerSphereSubpart))
            {
                m_centerSphere = centerSphereSubpart as MyEntity;
                if (m_centerSphere == null)
                {
                    return;
                }

                m_centerSphere.Render.EnableColorMaskHsv = true;
                m_centerSphere.Render.ColorMaskHsv       = block.Render.ColorMaskHsv;
                m_centerSphere.Render.PersistentFlags    = MyPersistentEntityFlags2.CastShadows;
                m_centerSphere.PositionComp.LocalMatrix  = Matrix.CreateFromTransformScale(Quaternion.Identity, new Vector3(0f, -1.0f, 0f), Vector3.One);
                m_centerSphere.Flags = EntityFlags.Visible | EntityFlags.NeedsDraw | EntityFlags.NeedsDrawFromParent | EntityFlags.InvalidateOnMove;
                m_centerSphere.OnAddedToScene(block);

                MyCubeBlockEmissive.SetEmissiveParts(m_centerSphere, 0.0f, Color.FromNonPremultiplied(new Vector4(0.35f, 0.05f, 0.35f, 0.75f)), Color.White);
            }
        }
 public override void ActiveUpdate()
 {
     m_centerSphere.PositionComp.LocalMatrix = Matrix.CreateFromTransformScale(Quaternion.Identity, new Vector3(0f, 1.5f, 0f), Vector3.One) * Matrix.CreateRotationY(MathHelper.ToRadians(m_activePosition));
     MyCubeBlockEmissive.SetEmissiveParts(m_centerSphere, 1f, Color.FromNonPremultiplied(new Vector4(0.05f, 0.05f, 0.35f, 0.75f)), Color.White);
     UpdateBolts(true);
     m_activePosition++;
 }
        private void UpdatePosition(int position, int maxPosition)
        {
            Vector3D sphereDiff = new Vector3D(0f, 1.5f, 0f) - new Vector3D(0f, -1f, 0f);

            m_centerSphere.PositionComp.LocalMatrix = Matrix.CreateFromTransformScale(Quaternion.Identity, new Vector3(0f, -1f, 0f) + sphereDiff * ((float)position / maxPosition), Vector3.One) * Matrix.CreateRotationY(MathHelper.ToRadians(position / 5f));
            MyCubeBlockEmissive.SetEmissiveParts(m_centerSphere, 1f * ((float)position / maxPosition), Color.FromNonPremultiplied(new Vector4(0.05f, 0.05f, 0.35f, 0.75f)), Color.White);
        }
Пример #4
0
        public override void ActiveUpdate()
        {
            float emissive = MathExtensions.TrianglePulse(m_updateCount, 1f, 150);

            //MyCubeBlockEmissive.SetEmissiveParts((MyEntity)m_owner, emissive, Color.FromNonPremultiplied(m_color) * 0f, Color.White);
            m_owner.SetEmissiveParts("Emissive-Beacon", Color.FromNonPremultiplied(m_color) * emissive, 1f);
            m_owner.SetEmissiveParts("Emissive0", Color.FromNonPremultiplied(m_color) * emissive, emissive);
            MyCubeBlockEmissive.SetEmissiveParts((MyEntity)m_owner, emissive, Color.FromNonPremultiplied(m_color) * emissive, Color.White);

            if (!m_owner.IsFunctional || !m_owner.Enabled)
            {
                if (m_soundEmitter != null)
                {
                    if (m_soundEmitter.IsPlaying)
                    {
                        m_soundEmitter.StopSound(true);
                    }
                }

                m_light.Intensity      = 0f;
                m_light.GlareIntensity = 0f;
                m_light.UpdateLight();

                return;
            }

            if (m_soundEmitter == null)
            {
                m_soundPair    = new MySoundPair("NaniteBeacon");
                m_soundEmitter = new MyEntity3DSoundEmitter((MyEntity)m_owner, true);
                m_soundEmitter.PlaySound(m_soundPair, true);
            }
            else if (!m_soundEmitter.IsPlaying)
            {
                m_soundEmitter.PlaySound(m_soundPair, true);
            }

            m_light.Intensity      = MathExtensions.TrianglePulse(m_updateCount, 0.8f, 150);
            m_light.GlareIntensity = MathExtensions.TrianglePulse(m_updateCount, 0.8f, 150);
            //m_light.GlareSize = 0.098f;

            Vector3D position = m_owner.GetPosition();

            if (m_owner.CubeGrid.GridSizeEnum == VRage.Game.MyCubeSize.Small)
            {
                Vector3D localPosition = new Vector3D(0f, 0.30f, 0f);
                position = Vector3D.Transform(localPosition + m_localOffset, m_owner.WorldMatrix);
            }
            else
            {
                Vector3D localPosition = new Vector3D(0f, -0.05f, 0f);
                position = Vector3D.Transform(localPosition + m_localOffset, m_owner.WorldMatrix);
            }

            m_light.Position = position;
            m_light.UpdateLight();

            m_updateCount++;
        }
Пример #5
0
 public override void InactiveUpdate()
 {
     m_owner.SetEmissiveParts("Emissive-Beacon", Color.Red, 1f);
     m_owner.SetEmissiveParts("Emissive0", Color.Red, 1f);
     MyCubeBlockEmissive.SetEmissiveParts((MyEntity)m_owner, 1f, Color.Red, Color.White);
     m_light.Intensity      = 0f;
     m_light.GlareIntensity = 0f;
     m_light.UpdateLight();
 }
Пример #6
0
        public override void InactiveUpdate()
        {
            MyCubeBlockEmissive.SetEmissiveParts(m_hammer, 1f, Color.Red, Color.White);

            if (m_dustParticles != null && DateTime.Now - m_smokeStarted > TimeSpan.FromSeconds(2))
            {
                StopParticles();
            }
        }
Пример #7
0
        public override void ActiveUpdate()
        {
            MyCubeBlockEmissive.SetEmissiveParts(m_hammer, 0.0f, Color.FromNonPremultiplied(new Vector4(0.3f, 0.15f, 0.0f, 1f)), Color.White);
            m_tick++;
            // Move upwards slowly, taking 5 seconds, waits for a second at top
            if (m_up)
            {
                if (m_tick <= 300)
                {
                    m_position = MathExtensions.TrianglePulse(m_tick, 2f, 300) - 1f;
                }

                if (m_tick % 360 == 0)
                {
                    m_up   = false;
                    m_tick = 15;
                }
            }
            else
            {
                // Slam down, takes less than half a second, but wait for a second before going up
                if (m_tick <= 30)
                {
                    m_position = MathExtensions.TrianglePulse(m_tick, 2f, 15) - 1f;
                }

                if (m_tick == 30)
                {
                    // Fire off some smoke particles
                    CreateMiningSmoke(m_block);

                    // Make a thump noise
                    m_soundEmitter.PlaySound(m_soundPair);
                }

                if (m_tick % 90 == 0)
                {
                    m_smokeStarted = DateTime.Now;
                    CreateParticles(Vector3D.Transform(new Vector3(0f, -3f, 0f), m_block.WorldMatrix), true, true, true);

                    m_up   = true;
                    m_tick = 0;
                }
            }

            if (m_dustParticles != null && DateTime.Now - m_smokeStarted > TimeSpan.FromSeconds(2))
            {
                StopParticles();
            }

            UpdatePosition();
        }
Пример #8
0
        /// <summary>
        /// Updates the working state of an entity with regards to it's lights, calling optional actions.
        /// </summary>
        /// <param name="block">The block to manipulate emissiveness on</param>
        /// <param name="light">The light to modify</param>
        /// <param name="lightOrigin">The origin of the light</param>
        /// <param name="lightColor">Color of the light</param>
        /// <param name="emissive">Emissiveness of the main model part</param>
        /// <param name="subpartEmissive">Emissiveness of the model's subparts</param>
        /// <param name="emV">Emissiveness colour components</param>
        /// <param name="updateLogic">Methods to call</param>
        public static void UpdateWorkingState(IMyCubeBlock block,
                                              MyLight light, Vector3D?lightOrigin, Color lightColor, float emissive,
                                              float subpartEmissive, Vector4 emV, Action updateLogic)
        {
            if (GameLogic.SkipProcessing())
            {
                return;
            }

            var entity   = block as MyEntity;
            var subparts = entity?.Subparts;

            if (block.IsWorking)
            {
                CreateOrUpdateLight(entity, light, lightColor, lightOrigin);
                MyCubeBlockEmissive.SetEmissiveParts(entity,
                                                     emissive,
                                                     Color.FromNonPremultiplied(emV),
                                                     Color.White);

                ToggleLight(light);

                if (subparts != null)
                {
                    foreach (var subPart in subparts)
                    {
                        MyCubeBlockEmissive.SetEmissiveParts(subPart.Value, subpartEmissive,
                                                             Color.FromNonPremultiplied(emV),
                                                             Color.White);
                    }
                }

                updateLogic?.Invoke();
            }
            else
            {
                ToggleLight(light);

                if (subparts == null)
                {
                    return;
                }

                foreach (var subPart in subparts)
                {
                    subPart.Value.SetEmissiveParts("Emissive", Color.Red, 1.0f);
                }
            }
        }
        public override void InactiveUpdate()
        {
            if (m_centerSphere == null)
            {
                if (m_block != null)
                {
                    CreateCenterSphere(m_block);
                }

                return;
            }

            m_centerSphere.PositionComp.LocalMatrix = Matrix.CreateFromTransformScale(Quaternion.Identity, new Vector3(0f, -1.0f, 0f), Vector3.One);
            MyCubeBlockEmissive.SetEmissiveParts(m_centerSphere, 0.0f, Color.Black, Color.White);
            m_activePosition = 0;
        }
Пример #10
0
 public override void UpdateBeforeSimulation10()
 {
     if (!m_initialized)
     {
         return;
     }
     try
     {
         if (m_entity != null)
         {
             var emissivity = MathHelper.Clamp(Heat / MaxHeat * 0.25f, 0.0f, 0.25f);
             MyCubeBlockEmissive.SetEmissiveParts((MyEntity)m_entity, emissivity, Color.Red, Color.White);
         }
     }
     catch (Exception e)
     { Debug.HandleException(e); }
 }
Пример #11
0
        public override void ActiveUpdate()
        {
            m_owner.SetEmissiveParts("Emissive-Beacon", Color.Lime, 1f);
            m_owner.SetEmissiveParts("Emissive0", Color.Lime, 1f);
            MyCubeBlockEmissive.SetEmissiveParts((MyEntity)m_owner, 1f, Color.Lime, Color.White);

            if (m_soundEmitter == null)
            {
                m_soundPair    = new MySoundPair("NaniteBeacon");
                m_soundEmitter = new MyEntity3DSoundEmitter((MyEntity)m_owner, true);
                m_soundEmitter.PlaySound(m_soundPair, true);
            }
            else if (!m_soundEmitter.IsPlaying)
            {
                m_soundEmitter.PlaySound(m_soundPair, true);
            }
        }
Пример #12
0
        private void CreateMiningHammer(MyEntity block)
        {
            if (block == null)
            {
                return;
            }

            m_hammer = new MyEntity();
            m_hammer.Init(null, m_modelsFolder + "NUHOL_Hammer.mwm", block, null, null);
            m_hammer.Render.EnableColorMaskHsv = true;
            m_hammer.Render.ColorMaskHsv       = block.Render.ColorMaskHsv;
            m_hammer.Render.PersistentFlags    = MyPersistentEntityFlags2.CastShadows;
            m_hammer.PositionComp.LocalMatrix  = Matrix.CreateFromTransformScale(Quaternion.Identity, new Vector3(0f, 1.5f, 0f), Vector3.One);
            m_hammer.Flags = EntityFlags.Visible | EntityFlags.NeedsDraw | EntityFlags.NeedsDrawFromParent | EntityFlags.InvalidateOnMove;
            m_hammer.OnAddedToScene(block);

            MyCubeBlockEmissive.SetEmissiveParts(m_hammer, 0.0f, Color.FromNonPremultiplied(new Vector4(0.3f, 0.15f, 0.0f, 1f)), Color.White);
        }
Пример #13
0
 public override void InactiveUpdate()
 {
     m_owner.SetEmissiveParts("Emissive-Beacon", Color.Red, 1f);
     m_owner.SetEmissiveParts("Emissive0", Color.Red, 1f);
     MyCubeBlockEmissive.SetEmissiveParts((MyEntity)m_owner, 1f, Color.Red, Color.White);
 }