Example #1
0
 /// <summary>
 /// Constructor that immediately sets the closest item (and distance)
 /// </summary>
 /// <param name="item">track item to store as closest item</param>
 public CloseToMouseItem(DrawableTrackItem item)
 {
     ClosestDistanceSquared = 0;
     DrawableTrackItem = item;
     Description = DrawableTrackItem.Description;
     worldLocation = DrawableTrackItem.WorldLocation;
 }
Example #2
0
        /// <summary>
        /// Check wether this track Item is closest to the mouse location
        /// </summary>
        /// <param name="location">Location to check</param>
        /// <param name="mouseLocation">Current mouse location</param>
        /// <param name="trItem">The track Item that will be stored when it is indeed the closest</param>
        public void CheckMouseDistance(WorldLocation location, WorldLocation mouseLocation, DrawableTrackItem trItem)
        {
            float distanceSquared = CloseToMouse.GetGroundDistanceSquared(location, mouseLocation);

            if (distanceSquared < ClosestDistanceSquared)
            {
                ClosestDistanceSquared = distanceSquared;
                this.DrawableTrackItem = trItem;
                this.worldLocation = location;
                this.Description = trItem.Description;
            }
        }