root/src/BRAINSFramework/Feeler.cs

User picture

Author: conkerjo

Revision: 30 («Previous)


File Size: 1.63 KB

(July 01, 2009 23:02 UTC) Almost 3 years ago


  

 
Show/hide line numbers

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Brains.Framework.Utility;

namespace Brains.Framework
{
    /// <summary>
    /// Stores a direction and length of the feeler.
    /// </summary>
    public class Feeler
    {
        private Agent _owner;
        /// <summary>
        /// Gets the owning agent of the Feeler
        /// </summary>
        public Agent Owner { get { return _owner; } }
        
        /// <summary>
        /// Gets or Sets the direction of the Feeler in local space coordinates
        /// </summary>
        public Vector2 Vector { get; set; }

        /// <summary>
        /// Gets or sets the length of the Feeler
        /// </summary>
        public float Length { get; set; }
        
        public Vector2 TipWorldPosition
        {
            get
            {
                Vector2 dest = VectorUtil.VectorToWorldSpace(Vector, Owner.Orientation);
                Vector2 dd =Owner.Position + (dest * Length);
                return dd;
            }
        }
        
        /// <summary>
        /// Gets the direction of the Feeler in world coordinates
        /// </summary>
        public Vector2 WorldDirection
        {
            get
            {
                Vector2 dest = VectorUtil.VectorToWorldSpace(Vector, Owner.Orientation);
                return dest;
            }
        }

        internal Feeler(Vector2 feeler,float length,Agent owner)
        {
            Length = length;
            Vector = feeler;
            _owner = owner;
        }

    }


}