root/src/BRAINSFramework/Feeler.cs

113
1
//****************************************************************//
1

2
//********************copyright Rik Dodsworth 2009****************//
3
//****************************************************************//
4
//***************************free to use**************************//
5
//****************************************************************//
6
//*******************please just leave this header****************//
7
//*************************for recognition************************//
8
//****************************************************************//
9
//****************************************************************//
10
11
using System;
2
using System;
12
using System.Collections.Generic;
3
using System.Collections.Generic;
13
using System.Linq;
4
using System.Linq;
14
using System.Text;
5
using System.Text;
15
using Microsoft.Xna.Framework;
6
using Microsoft.Xna.Framework;
7
using Brains.Framework.Utility;
16
8
17
namespace Brains.Framework
9
namespace Brains.Framework
18
{
10
{
11
    /// <summary>
12
    /// Stores a direction and length of the feeler.
13
    /// </summary>
19
    public class Feeler
14
    public class Feeler
20
    {
15
    {
21
        public Agent Owner;
16
        private Agent _owner;
17
        /// <summary>
18
        /// Gets the owning agent of the Feeler
19
        /// </summary>
20
        public Agent Owner { get { return _owner; } }
21
        
22
        /// <summary>
23
        /// Gets or Sets the direction of the Feeler in local space coordinates
24
        /// </summary>
22
        public Vector2 Vector { get; set; }
25
        public Vector2 Vector { get; set; }
26
27
        /// <summary>
28
        /// Gets or sets the length of the Feeler
29
        /// </summary>
23
        public float Length { get; set; }
30
        public float Length { get; set; }
31
        
24
        public Vector2 TipWorldPosition
32
        public Vector2 TipWorldPosition
25
        {
33
        {
26
            get
34
            get
27
            {
35
            {
28
                Vector2 dest = Util.VectorToWorldSpace(Vector, Owner.Orientation);
36
                Vector2 dest = VectorUtil.VectorToWorldSpace(Vector, Owner.Orientation);
29
                Vector2 dd =Owner.Position + (dest * Length);
37
                Vector2 dd =Owner.Position + (dest * Length);
30
                return dd;
38
                return dd;
31
            }
39
            }
32
        }
40
        }
41
        
42
        /// <summary>
43
        /// Gets the direction of the Feeler in world coordinates
44
        /// </summary>
33
        public Vector2 WorldDirection
45
        public Vector2 WorldDirection
34
        {
46
        {
35
            get
47
            get
36
            {
48
            {
37
                Vector2 dest = Util.VectorToWorldSpace(Vector, Owner.Orientation);
49
                Vector2 dest = VectorUtil.VectorToWorldSpace(Vector, Owner.Orientation);
38
                return dest;
50
                return dest;
39
            }
51
            }
40
        }
52
        }
41
        public Feeler(Vector2 feeler,float length,Agent owner)
53
54
        internal Feeler(Vector2 feeler,float length,Agent owner)
42
        {
55
        {
43
            Length = length;
56
            Length = length;
44
            Vector = feeler;
57
            Vector = feeler;
45
            Owner = owner;
58
            _owner = owner;
46
        }
59
        }
60
47
    }
61
    }
62
63
48
}
64
}