protected void OnEnable()
		{
			this.tracker.AddOnNewDetectedDelegate(this.OnNewDetected);
						
			if (this._ignoreList.Count == 0)
				return;
			
			// Unless this is a AreaTargetTracker. Stop here.
			if (this.tracker.area == null)
				return;
						
			// Sync the ignore list with the TargetTracker by removing any ignore targetables.				
			var areaListCopy = new TargetList(this.tracker.area);
			for (int i = 0; i < areaListCopy.Count; i++)
			{
				this.currentTargetable = areaListCopy[i].targetable;
				if (this.currentTargetable == null)
					continue;
				
				if (this._ignoreList.Contains(this.currentTargetable))
				{
					this.tracker.area.Remove(this.currentTargetable);
				}
			}
		}
    protected void Awake()
    {
        this.startingColor = this.GetComponent<Renderer>().material.color;
			
        this.targetable = this.GetComponent<Targetable>();
        this.targetable.AddOnDetectedDelegate(this.OnDetected);
        this.targetable.AddOnNotDetectedDelegate(this.OnNotDetected);

        this.targetable.AddOnHitDelegate(this.OnHit);
    }
		/// <summary>
		/// Use like List<Targetable>.Remove to remove the passed targetable from the ignore 
		/// list and add it to the TargetTracker
		/// </summary>
		/// <param name='targetable'>
		/// Targetable.
		/// </param>
		public void Remove(Targetable targetable) 
		{
			if (targetable == null)
				return;

			// Does nothing if there is nothing to remove.
			this._ignoreList.Remove(targetable);			
			
			// Don't affect the TargetTracker if this is disabled. If disabled, all 
			//	 are added back to the Area anyway and OnEnable only Remove is done.
			if (this.enabled && this.tracker.area != null)
				// The TargetTracker will handle preventing multiples from being added
				this.tracker.area.Add(targetable);
		}
Beispiel #4
0
 public void AddOnNotDetectedDelegate(Targetable.OnNotDetectedDelegate del)
 {
     this.onNotDetectedDelegates = (Targetable.OnNotDetectedDelegate)Delegate.Combine(this.onNotDetectedDelegates, del);
 }
		/// <summary>
		/// Use like List<Targetable>.Add() to add the passed targetable to the ignore 
		///  list and remove it from the TargetTracker
		/// </summary>
		/// <param name='targetable'>
		/// Targetable.
		/// </param>
		public void Add(Targetable targetable) 
		{
			if (targetable == null)
				return;
			
			// Only add this once.
			if (!this._ignoreList.Contains(targetable))
				this._ignoreList.Add(targetable);

			// Don't affect the TargetTracker if this is disabled. It will sync OnEnable
			if (this.enabled && 
			    this.tracker != null && 
			    this.tracker.area != null && 
			    targetable.trackers.Contains(this.tracker))
			{
				// Removing multiple times doesn't hurt and lets the inspector use this.
				this.tracker.area.Remove(targetable);
			}
		}
Beispiel #6
0
 public void AddOnHitColliderDelegate(Targetable.OnHitColliderDelegate del)
 {
     this.onHitColliderDelegates = (Targetable.OnHitColliderDelegate)Delegate.Combine(this.onHitColliderDelegates, del);
 }
Beispiel #7
0
 public void SetOnNotDetectedDelegate(Targetable.OnNotDetectedDelegate del)
 {
     this.onNotDetectedDelegates = del;
 }
Beispiel #8
0
 public void SetOnHitDelegate(Targetable.OnHitDelegate del)
 {
     this.onHitDelegates = del;
 }
Beispiel #9
0
 public void RemoveOnNotDetectedDelegate(Targetable.OnNotDetectedDelegate del)
 {
     this.onNotDetectedDelegates = (Targetable.OnNotDetectedDelegate)Delegate.Remove(this.onNotDetectedDelegates, del);
 }
Beispiel #10
0
 public void RemoveOnHitDelegate(Targetable.OnHitDelegate del)
 {
     this.onHitDelegates = (Targetable.OnHitDelegate)Delegate.Remove(this.onHitDelegates, del);
 }