private void Deselect() { Vector2Int targetCoordinates = gridHighlight.coordinates; bool isReachable = false; if (requiresPath && !WorldEditor.WorldEditorManager.IsWorldEditorActive) { // Check if path between old and new position is possible GridPathfinder ptf = new GridPathfinder(Grid.grid); List <Vector2Int> path = ptf.GetPath(AttachedEntity.BookmarkedCoordinates, targetCoordinates); isReachable = path != null; } else { // Check if the new position is vacant isReachable = !Grid.grid.CheckCollisionFlags(targetCoordinates, AttachedEntity.GetCollisionFlags()); } if (isReachable) { // Can move to new position AttachedEntity.Move(targetCoordinates); } else { if (WorldEditor.WorldEditorManager.IsWorldEditorActive) { // Cannot move to selected position - abort placement return; } else { // Cannot move to new position - go back to old position AttachedEntity.LoadBookmark(); } } DestroyGridHighlight(); // Update collision data AttachedEntity.UpdateCollision(); HasSelection = false; isSelected = false; UpdateRenderers(); arrow.positionCount = 0; }
public List <HexCell> GetPath() { return(pathfinder.GetPath()); }