/// <summary> /// Selects an entity. /// </summary> /// <param name="entity">The entity to select.</param> private void Set([NotNull] Entity entity) { var entityId = Editor.Controller.GetAbsoluteId(entity); if (!SelectableIds.Contains(entityId) || SelectedIds.Count == 1 && SelectedIds.Contains(entityId)) { return; } IsControllingMouse = true; Editor.Dispatcher.InvokeAsync(() => { var viewModel = (EntityHierarchyElementViewModel)Editor.FindPartViewModel(entityId); Editor.ClearSelection(); if (viewModel is not null) { Editor.SelectedContent.Add(viewModel); } Editor.Controller.InvokeAsync(() => IsControllingMouse = false); }); }
/// <inheritdoc/> void IEditorGameSelectionViewModelService.RemoveSelectable(AbsoluteId id) { Editor.Controller.EnsureAssetAccess(); Editor.Controller.InvokeAsync(() => SelectableIds.Remove(id)); // Remove from game selection, in case it was selected var element = (EntityHierarchyElementViewModel)Editor.FindPartViewModel(id); if (element == null) { return; } // Retrieve old selection to pass it to the event var oldSelectionIds = GetSelectedRootIds(); RemoveFromSelection(element); RaiseSelectionUpdated(oldSelectionIds); }
/// <inheritdoc/> void IEditorGameSelectionViewModelService.AddSelectable(AbsoluteId id) { Editor.Controller.EnsureAssetAccess(); Editor.Controller.InvokeAsync(() => SelectableIds.Add(id)); // Add to game selection, in case it is already selected var element = (EntityHierarchyElementViewModel)Editor.FindPartViewModel(id); if (element == null) { return; } if (Editor.SelectedContent.Contains(element)) { // Retrieve old selection to pass it to the event var oldSelectionIds = GetSelectedRootIds(); AddToSelection(element); RaiseSelectionUpdated(oldSelectionIds); } }