Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions 2D/Behaviors/SteerForNeighborGroup2D.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Profiling;
using UnitySteer.Attributes;

namespace UnitySteer2D.Behaviors
Expand Down Expand Up @@ -116,6 +118,12 @@ public List<Vehicle2D> Neighbors
get { return _neighbors; }
}

/// <summary>
/// Delegate which is called when the detected neighbors list is changed
/// </summary>
public Action<SteerForNeighborGroup2D> OnNeighborsChanged = delegate { };


#endregion

#region Methods
Expand Down Expand Up @@ -162,6 +170,14 @@ private void HandleDetection(Radar2D radar)
_neighbors.Add(other);
}
}

if (OnNeighborsChanged != null)
{
Profiler.BeginSample("Neighbor event handler");
OnNeighborsChanged(this);
Profiler.EndSample();
}

}

protected override Vector2 CalculateForce()
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# UnitySteer changelog

## WIP

* Added OnNeighborsChanged event to SteerForNeighbourGroup2D

## v3.1

* 2D support thanks to @GandaG and @pjohalloran.
Expand Down