Exemple #1
0
        // Your block update (each frame after simulation ... if works ...)
        public void BlockUpdate()
        {
            if (m_anima == null)
            {
                return;
            }
            // Enable Anima based of player distance and if object is functional
            // It will only enable if it's under 500m AND block is functional
            m_anima.Enable = m_anima.TestPlayerDistance(500.0) && block.IsFunctional;

            // Only update if is enabled!
            if (m_anima.Enable)
            {
                m_anima.Update(m_anima.GetElapsed());

                // This is only for animating the "Emissive" material!
                float corePower = 0.0f;
                switch (blockMode)
                {
                case BlockMode.POWER_ON:
                    corePower = m_part_3.CursorNormal;
                    break;

                case BlockMode.POWER_OFF:
                    corePower = 1.0f - m_part_3.CursorNormal;
                    break;

                case BlockMode.ACTIVE:
                    corePower = 1.0f;
                    break;
                }
                m_part_3.SetEmissive(corePower, Color.Lerp(Color.DarkRed, Color.Green, corePower));
            }
        }