/// <summary> /// Unregisters the specified <see cref="DynamicObstacle"/> from this grid. /// </summary> /// <param name="obstacle">The <see cref="DynamicObstacle"/> to unregister</param> public void unregisterObstacle(DynamicObstacle obstacle) { // Check all obstacles for (int i = 0; i < obstacles.Count; i++) { // Check for matching obstacle if (obstacles[i].obstacle == obstacle) { // Remove the obstacle obstacles.RemoveAt(i); return; } } }
/// <summary> /// Registers a <see cref="DynamicObstacle"/> with this grid. /// </summary> /// <param name="obstacle">The <see cref="DynamicObstacle"/> to register</param> public void registerObstacle(DynamicObstacle obstacle) { // Make sure it is not already registered foreach (DynamicObstacleData data in obstacles) { // We have foud the same obstacle already registered if (data.obstacle == obstacle) { return; } } // Add the obstacle obstacles.Add(new DynamicObstacleData { lastUpdate = 0, obstacle = obstacle, obstructedIndexes = new List <Index>(), }); }