/// <summary> /// Удаляет просканированную область /// </summary> /// <param name="leftBottomPoint">Левая нижняя точка выбранной местности</param> /// <param name="rightTopPoint">Правая верхняя точка выбранной иестности</param> /// <param name="callback">Уведомление о завершении операции</param> public void RemoveArea(Vector2 leftBottomPoint, Vector2 rightTopPoint, OnOperationComplete callback = null) { TaskFactory.Add(() => { var removedArea = new AABB(leftBottomPoint, rightTopPoint); var removedCells = CellTree.RemoveAll(removedArea); foreach (var removedCell in removedCells) { foreach (var item in removedCell.Neighbours) { item.Key.Neighbours.Remove(removedCell); } List <Cell> gosCellsList = GetCells(removedCell.GameObject); if (gosCellsList != null) { gosCellsList.Remove(removedCell); } } if (callback != null) { callback(); } }); }
private void OnExecutionComplete(Result <T> result) { if (result.Data == null) { result.SetFailure($"{_operation.Method.Name} is expecting to send {typeof(T).Name} but it is null!"); } OnOperationComplete.Invoke(this, result); }
protected override void ExecuteOperation() { Result <T> result = PreviousResult as Result <T>; if (result.Data != null) { _operation.Invoke(result.Data, OnExecutionComplete); } else { result.SetFailure($"{_operation.Method.Name} is expecting to receive {typeof(T).Name} but it is null!"); OnOperationComplete.Invoke(this, result); } }
/// <summary> /// Выполняет сканирование и обработку местности /// </summary> /// <param name="leftBottomPoint">Левая нижняя точка выбранной местности</param> /// <param name="rightTopPoint">Правая верхняя точка выбранной иестности</param> /// <param name="scanAccuracy"></param> /// <param name="callback">Уведомление о завершении операции</param> /// <param name="addToExistingMap">Добавить в уже существующую карту</param> public void ScanArea(Vector2 leftBottomPoint, Vector2 rightTopPoint, float scanAccuracy = MinScanAccuracy * 50f, OnOperationComplete callback = null, bool addToExistingMap = true) { if (!addToExistingMap) { //CellTree.Clear(); CellTree = new AABBTree <Cell>(new InsertStrategyArea <Cell>()); CellsFromGameobject.Clear(); } var scanAreaBounds = new AABB(leftBottomPoint, rightTopPoint); //for debug //scanAreaBounds = new AABB(leftBottomPoint/10f, rightTopPoint/10f); if (scanAccuracy > scanAreaBounds.width) { scanAccuracy = scanAreaBounds.width - MinScanAccuracy; } if (scanAccuracy > scanAreaBounds.height) { scanAccuracy = scanAreaBounds.height - MinScanAccuracy; } ScanArea(scanAreaBounds /*, hitsTree*/, scanAccuracy); //todo: scan in thread TaskFactory.Add( () => { //CellTree.Build(); //CellTree.Balance(); //foreach (var node in CellTree) //{ // //TaskFactory.Add(() => // //{ // addNeighbours(node); // //}); //} if (callback != null) { callback(); } }); Debug.Log(CellTree.Count); //Debug.Log(CellTree.Height); }
private void OnExecutionComplete(Result result) { OnOperationComplete.Invoke(this, result); }
/// <summary> /// Выполняет сканирование и обработку местности /// </summary> /// <param name="leftBottomPoint">Левая нижняя точка выбранной местности</param> /// <param name="rightTopPoint">Правая верхняя точка выбранной иестности</param> /// <param name="scanAccuracy"></param> /// <param name="callback">Уведомление о завершении операции</param> /// <param name="addToExistingMap">Добавить в уже существующую карту</param> public void ScanArea(Vector2 leftBottomPoint, Vector2 rightTopPoint, float scanAccuracy = MinScanAccuracy * 50f, OnOperationComplete callback = null, bool addToExistingMap = true) { if (!addToExistingMap) { //CellTree.Clear(); CellTree = new List <Cell>(); } var scanAreaBounds = new[] { new FloatWithSizeMath.FloatWithSize(leftBottomPoint.x, rightTopPoint.x), new FloatWithSizeMath.FloatWithSize(leftBottomPoint.y, rightTopPoint.y) }; if (scanAccuracy > scanAreaBounds[0].Size) { scanAccuracy = scanAreaBounds[0].Size - MinScanAccuracy; } if (scanAccuracy > scanAreaBounds[1].Size) { scanAccuracy = scanAreaBounds[1].Size - MinScanAccuracy; } ScanArea(scanAreaBounds[0], scanAreaBounds[1] /*, hitsTree*/, scanAccuracy); //todo: scan in thread Console.WriteLine("Cells count: " + CellTree.Count); if (callback != null) { callback(); } }
/// <summary> /// Удаляет просканированную область /// </summary> /// <param name="leftBottomPoint">Левая нижняя точка выбранной местности</param> /// <param name="rightTopPoint">Правая верхняя точка выбранной иестности</param> /// <param name="callback">Уведомление о завершении операции</param> public void RemoveArea(Vector2 leftBottomPoint, Vector2 rightTopPoint, OnOperationComplete callback = null) { throw new NotImplementedException(); }