public void Copy(SurfaceDataObject _object)
        {
            if (_object == null)
            {
                return;
            }

            base.Copy(_object);

            Name = _object.Name;
            UseBehaviourModeKey = _object.UseBehaviourModeKey;
            BehaviourModeKey    = _object.BehaviourModeKey;

            Audio.Copy(_object.Audio);
            Effect.Copy(_object.Effect);
            Influences.Copy(_object.Influences);

            Textures = _object.Textures;
        }
        public void HandleEnvironment(Vector3 _velocity)
        {
            if (_velocity.z == 0)
            {
                return;
            }

            if (m_IntervalTimer > 0)
            {
                m_IntervalTimer -= Time.deltaTime;
            }


            if (m_IntervalTimer <= 0)
            {
                m_IntervalTimer = Interval / _velocity.z;

                SurfaceDataObject _new_surface = null;

                foreach (SurfaceDataObject _surface in Surfaces)
                {
                    foreach (Texture _texture in _surface.Textures)
                    {
                        if (_texture != null && _texture.name == m_TextureName)
                        {
                            _new_surface = _surface;
                            break;
                        }
                    }
                }

                if (_new_surface != null)
                {
                    m_IntervalTimer = _new_surface.Interval / _velocity.z;

                    if (m_ActiveSurface != null && m_ActiveSurface != _new_surface)
                    {
                        m_ActiveSurface.Effect.StopEffect();
                    }

                    if (m_ActiveSurface != _new_surface)
                    {
                        m_ActiveSurface = _new_surface;
                        m_ActiveSurface.Effect.StartEffect(m_Owner);
                    }

                    Audio.Play(m_ActiveSurface.Audio);
                }
                else
                {
                    if (m_ActiveSurface != null)
                    {
                        m_ActiveSurface.Effect.StopEffect();
                    }

                    m_ActiveSurface = null;

                    Audio.Stop();
                }
            }
        }
 public SurfaceDataObject(SurfaceDataObject _object) : base(_object)
 {
     Copy(_object);
 }
        /// <summary>
        /// Update surface handling.
        /// </summary>
        public void Update(CreatureObject _creature)
        {
            if (Enabled == false || _creature == null || _creature.Move.IsGrounded == false)
            {
                return;
            }

            Vector3 _velocity = _creature.Move.DesiredVelocity;

            if (_creature.Behaviour.ActiveBehaviourMode != null && _creature.Behaviour.ActiveBehaviourMode.Rule != null)
            {
                _velocity = _creature.Behaviour.ActiveBehaviourMode.Rule.Move.Motion.Velocity;
            }


            // Update Ground Texture Name - only required while creature is moving or texture name is empty
            if (_velocity.z > 0 || m_ActiveTextureName == "")
            {
                string _detected_texture_name = m_ActiveTextureName;

                m_GroundScanIntervalTimer += Time.deltaTime;
                if (m_GroundScanIntervalTimer >= GroundScanInterval)
                {
                    m_GroundScanIntervalTimer = 0;
                    _detected_texture_name    = _creature.Move.UpdateGroundTextureName();
                }

                if (_detected_texture_name != m_ActiveTextureName)
                {
                    m_ActiveTextureName = _detected_texture_name;

                    SurfaceDataObject _best_surface = null;
                    foreach (SurfaceDataObject _surface in Surfaces)
                    {
                        foreach (TextureDataObject _texture in _surface.Textures)
                        {
                            if (_texture != null && _texture.Image != null && _texture.Image.name == m_ActiveTextureName)
                            {
                                _best_surface = _surface;
                                break;
                            }
                        }
                    }

                    if (_best_surface != null)
                    {
                        if (m_ActiveSurface != _best_surface)
                        {
                            if (m_ActiveSurface != null)
                            {
                                m_ActiveSurface.Effect.Stop();
                            }

                            m_ActiveSurface = _best_surface;
                            m_ActiveSurface.Effect.Start(OwnerComponent);

                            AudioPlayer.Play(m_ActiveSurface.Audio);
                            FootstepPlayer.SetData(m_ActiveSurface.Footsteps);
                        }
                    }
                    else
                    {
                        if (m_ActiveSurface != null)
                        {
                            m_ActiveSurface.Effect.Stop();
                        }

                        m_ActiveSurface = null;

                        FootstepPlayer.SetData(null);
                        AudioPlayer.Stop();
                    }
                }
            }

            if (_velocity.z == 0)
            {
                AudioPlayer.Stop();
            }
            else
            {
                AudioPlayer.Update();
                FootstepPlayer.Update(_velocity.z);
            }
        }