private void DeleteUtilityItem(WorkingMemoryUtilityItem _utilityItem) { SelectNeighbourUtilityItemIfNeeded(_utilityItem); _utilityItem.RemoveFromHierarchy(); PuppeteerEditorHelper.Remove(ref (m_SelectedListItem as GoalListItem).GetDescription().UtilityParts, _utilityItem.GetUtilityDescription()); m_SelectedListItem.MarkUnsavedChanges(true); AddUnsavedMarker(); }
private void UpdateSelectedUtilityItem(WorkingMemoryUtilityItem _utilityItem) { if (m_SelectedWorkingMemoryUtilityItem != null) { m_SelectedWorkingMemoryUtilityItem.RemoveFromClassList("selectedWorldStateItem"); if (_utilityItem == m_SelectedWorkingMemoryUtilityItem) { m_SelectedWorkingMemoryUtilityItem = null; return; } } m_SelectedWorkingMemoryUtilityItem = _utilityItem; _utilityItem?.AddToClassList("selectedWorldStateItem"); }
private void AddNewUtilityItem(UtilityDescription _utilityDescription) { if (m_SelectedListItem is GoalListItem selectedGoalListItem) { GoalDescription selectedDescription = selectedGoalListItem.GetDescription(); int newIndex = PuppeteerEditorHelper.Append(ref selectedDescription.UtilityParts, _utilityDescription); WorkingMemoryUtilityItem utilityItem = CreateUtilityItem(selectedDescription.UtilityParts[newIndex]); m_SelectedListItem.MarkUnsavedChanges(true); AddUnsavedMarker(); UpdateSelectedUtilityItem(utilityItem); } }
private void SelectNeighbourUtilityItemIfNeeded(WorkingMemoryUtilityItem _utilityItem) { if (_utilityItem != m_SelectedWorkingMemoryUtilityItem) { return; } bool neighbourSelected = SelectNeighbourUtilityItem(MoveDirection.Up); if (!neighbourSelected) { neighbourSelected |= SelectNeighbourUtilityItem(MoveDirection.Down); } if (!neighbourSelected) { m_SelectedWorkingMemoryUtilityItem = null; } }
private WorkingMemoryUtilityItem CreateUtilityItem(UtilityDescription _utilityDescription) { WorkingMemoryUtilityItem utilityItem = new WorkingMemoryUtilityItem( _utilityDescription, AnyUtilityItemValueChanged, _item => { if (m_SelectedGoalPartItem != null) { PuppeteerEditorHelper.UpdateSelectedWorldStateItem(ref m_SelectedGoalPartItem, null); } UpdateSelectedUtilityItem(_item); }, DeleteUtilityItem, DuplicateUtilityItem ); m_GoalConfigurator.UtilityContainer.Add(utilityItem); return(utilityItem); }
private void DuplicateUtilityItem(WorkingMemoryUtilityItem _utilityItem) { AddNewUtilityItem(new UtilityDescription(_utilityItem.GetUtilityDescription())); }