public override void Update(GameTime gameTime)
        {
            // Check if we reached way point.
            Vector2 vertex = _path[_currentVertexIdx];

            if ((GameObject.Position - vertex).Length() <= _threshold && IsMoving)
            {
                if (IsPatroling)
                {   // If patroling the next waypoint after the last is the first waypoint
                    _currentVertexIdx = (_currentVertexIdx + 1) % _path.Length;
                }
                else
                {
                    // Stop at last way point.
                    if (_currentVertexIdx == _path.Length - 1)
                    {
                        if (OnFinishedPath != null)
                        {
                            OnFinishedPath();
                        }
                        IsMoving = false;
                    }
                    else
                    {
                        _currentVertexIdx = _currentVertexIdx + 1;
                    }
                }

                // Calculate direction
                if (_path[_currentVertexIdx] != vertex)
                {
                    _currentVelocity = ConvertUnits.ToSimUnits(Vector2.Normalize(_path[_currentVertexIdx] - vertex) * Speed);
                }
                else
                {
                    _currentVelocity = Vector2.Zero;
                }
            }

            // Move towards current vertex.
            if (IsMoving)
            {
                // setPosition(GameObject.Position + _currentMovementDirection * (float)gameTime.ElapsedGameTime.TotalSeconds);
                _physics.SetVelocity(_currentVelocity);
            }
            else
            {
                _physics.SetVelocity(Vector2.Zero);
            }
        }
        public override void Start()
        {
            if (Sprite != null)
            {
                var texture = AddComponent <TextureComponent>();
                texture.Texture = Sprite;
                texture.Start();
            }

            _physics = AddComponent <PhysicsComponent>();

            var vertices = new List <Vector2>(4);

            vertices.Add(GameObject.Position + new Vector2(-10, -10));
            vertices.Add(GameObject.Position + new Vector2(10, -10));
            vertices.Add(GameObject.Position + new Vector2(10, 10));
            vertices.Add(GameObject.Position + new Vector2(-10, 10));

            _physics.Polygon       = vertices;
            _physics.Friction      = 0.0f;
            _physics.Restitution   = 0.6f;
            _physics.Mass          = 1f;
            _physics.IsStatic      = false;
            _physics.IsProjectile  = true;
            _physics.IgnoreGravity = true;
            _physics.Start();

            var velocity = new Vector2(Velocity * (float)Math.Cos(Angle), Velocity * (float)Math.Sin(Angle));

            _physics.SetVelocity(velocity);

            // Hook up events.
            _physics.OnCollision += onCollision;
        }