Beispiel #1
0
        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();
        }
Beispiel #2
0
 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");
 }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
        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;
            }
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
 private void DuplicateUtilityItem(WorkingMemoryUtilityItem _utilityItem)
 {
     AddNewUtilityItem(new UtilityDescription(_utilityItem.GetUtilityDescription()));
 }