Example #1
0
        private void RegisterConfiguratorCallbacks()
        {
            m_GoalConfigurator.DisplayName.RegisterCallback <FocusOutEvent>(_eventTarget =>
            {
                if (PuppeteerEditorHelper.UpdateDescriptionIfNecessary((_eventTarget.target as TextField), ref (m_SelectedListItem as GoalListItem).GetDescription().DisplayName))
                {
                    m_SelectedListItem.ChangeText((_eventTarget.target as TextField).value);
                    m_SelectedListItem.MarkUnsavedChanges(true);
                    AddUnsavedMarker();
                }
            });

            m_GoalConfigurator.BaseUtility.RegisterCallback <FocusOutEvent>(_eventTarget =>
            {
                if (m_SelectedListItem is GoalListItem selectedGoalListItem)
                {
                    float currentUtility = selectedGoalListItem.GetDescription().BaseUtility;
                    float newUtility     = (_eventTarget.target as FloatField).value;

                    if (currentUtility != newUtility)
                    {
                        selectedGoalListItem.GetDescription().BaseUtility = newUtility;
                        selectedGoalListItem.MarkUnsavedChanges(true);
                        AddUnsavedMarker();
                    }
                }
            });
        }
Example #2
0
        private bool SelectNeighbourGoalPartItem(MoveDirection _direction)
        {
            if (_direction != MoveDirection.Up && _direction != MoveDirection.Down)
            {
                return(false);
            }

            if (m_SelectedListItem is GoalListItem selectedGoalListItem)
            {
                GoalDescription description = selectedGoalListItem.GetDescription();
                int             index       = m_GoalConfigurator.GoalPartsContainer.IndexOf(m_SelectedGoalPartItem);
                if (index > 0 && _direction == MoveDirection.Up)
                {
                    PuppeteerEditorHelper.UpdateSelectedWorldStateItem(ref m_SelectedGoalPartItem, m_GoalConfigurator.GoalPartsContainer[--index] as WorldStateItem);
                    return(true);
                }
                else if (_direction == MoveDirection.Down)
                {
                    if (index < description.GoalParts.Length - 1)
                    {
                        PuppeteerEditorHelper.UpdateSelectedWorldStateItem(ref m_SelectedGoalPartItem, m_GoalConfigurator.GoalPartsContainer[++index] as WorldStateItem);
                    }
                    else
                    {
                        if (m_GoalConfigurator.UtilityContainer.childCount > 0)
                        {
                            PuppeteerEditorHelper.UpdateSelectedWorldStateItem(ref m_SelectedGoalPartItem, null);
                            UpdateSelectedUtilityItem(m_GoalConfigurator.UtilityContainer[0] as WorkingMemoryUtilityItem);
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }
Example #3
0
        public override void EnterSelection()
        {
            if (m_SelectedWorldStateItem != null)
            {
                PuppeteerEditorHelper.UpdateSelectedWorldStateItem(ref m_SelectedWorldStateItem, null);
                return;
            }

            if (m_SelectedListItem == null || m_ActionConfigurator == null)
            {
                return;
            }

            if (m_ActionConfigurator.PreconditionsContainer.childCount > 0)
            {
                PuppeteerEditorHelper.UpdateSelectedWorldStateItem(ref m_SelectedWorldStateItem, m_ActionConfigurator.PreconditionsContainer[0] as WorldStateItem);
                return;
            }

            if (m_ActionConfigurator.EffectsContainer.childCount > 0)
            {
                PuppeteerEditorHelper.UpdateSelectedWorldStateItem(ref m_SelectedWorldStateItem, m_ActionConfigurator.EffectsContainer[0] as WorldStateItem);
                return;
            }
        }
        private void OnEnable()
        {
            titleContent = new GUIContent("Puppeteer PlanVisualiser", PuppeteerEditorResourceLoader.VisualiserIcon16.texture);

            EditorApplication.playModeStateChanged += EditorPlayModeStateChanged;
            Selection.selectionChanged             += OnSelectionChange;

            VisualTreeAsset visualTree = Resources.Load <VisualTreeAsset>("LayoutPuppeteerVisualiserWindow");

            visualTree.CloneTree(rootVisualElement);

            TextElement versionText = rootVisualElement.Q <TextElement>(name: "version");

            versionText.text = PuppeteerEditorHelper.GetVersion();

            StyleSheet styleSheet = Resources.Load <StyleSheet>("StylePuppeteerVisualiserWindow");

            rootVisualElement.styleSheets.Add(styleSheet);

            StyleSheet themeSheet = Resources.Load <StyleSheet>(EditorGUIUtility.isProSkin ? "StyleDarkTheme" : "StyleLightTheme");

            rootVisualElement.styleSheets.Add(themeSheet);

            var textLogo = rootVisualElement.Q <Image>(className: "textLogo");

            textLogo.image = PuppeteerEditorResourceLoader.TextLogo32.texture;

            m_Visualiser.OnVisualiserContentChanged += Repaint;

            if (m_Agent == null)
            {
                OnSelectionChange();
            }
        }
Example #5
0
        private WorldStateItem CreateGoalPartItem(WorldStateDescription _goalpart)
        {
            WorldStateItem goalPartItem = new WorldStateItem(_goalpart);

            goalPartItem.OnMouseDown += _item =>
            {
                if (m_SelectedWorkingMemoryUtilityItem != null)
                {
                    UpdateSelectedUtilityItem(null);
                }

                PuppeteerEditorHelper.UpdateSelectedWorldStateItem(ref m_SelectedGoalPartItem, _item);
            };
            goalPartItem.OnDelete += _item =>
            {
                PuppeteerEditorHelper.DeleteWorldStateItem(this, m_SelectedListItem as GoalListItem,
                                                           ref (m_SelectedListItem as GoalListItem).GetDescription().GoalParts, _item, SelectNeighbourGoalPartItemIfNeeded);
            };

            goalPartItem.OnDuplicate    += _item => AddNewGoalPartItem(new WorldStateDescription(_item.GetWorldStateDescription()));
            goalPartItem.OnValueChanged += _item =>
            {
                m_SelectedListItem.MarkUnsavedChanges(true);
                AddUnsavedMarker();
            };

            m_GoalConfigurator.GoalPartsContainer.Add(goalPartItem);

            return(goalPartItem);
        }
        public ExecutableSensorField(string _label = null) : base(label: _label, PuppeteerEditorHelper.GetSensorTypes(), 0)
        {
            // Unity won't let us access the choices member variable in BasePopupField so we unfortunately have to get it again.
            m_ContentTypes = PuppeteerEditorHelper.GetSensorTypes();

            AddToClassList(ussClassName);
            labelElement.AddToClassList(labelUssClassName);
        }
        public ArchetypeSelectorField(string _label = null) : base(_label, PuppeteerEditorHelper.GetArchetypeSelectorGUIDs(), 0, GetArchetypeName, GetArchetypeName)
        {
            // Unity won't allow access to the choices member variable in BasePopupField so we unfortunately have to get it again.
            m_ArchetypeGuids = new List <Guid>(PuppeteerEditorHelper.GetArchetypeSelectorGUIDs());

            AddToClassList(ussClassName);
            labelElement.AddToClassList(labelUssClassName);
        }
Example #8
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();
        }
Example #9
0
 public override void ClearSelection()
 {
     if (m_SelectedWorldStateItem != null)
     {
         PuppeteerEditorHelper.UpdateSelectedWorldStateItem(ref m_SelectedWorldStateItem, null);
     }
     else
     {
         base.ClearSelection();
     }
 }
Example #10
0
        public override void SaveSelectedChange()
        {
            bool shouldSaveToFile = PuppeteerEditorHelper.AddOrUpdateInList <GoalListItem, GoalDescription>(m_SerialisedGoals, m_SelectedListItem);

            bool successful = !shouldSaveToFile || PuppeteerManager.Instance.SaveGoals();

            if (successful)
            {
                m_SelectedListItem.MarkUnsavedChanges(false);
                TryClearUnsavedMarker();
            }
        }
        public void OnEnable()
        {
            titleContent = new GUIContent("Puppeteer Configurator", PuppeteerEditorResourceLoader.ConfiguratorIcon16.texture);

            VisualTreeAsset visualTree = Resources.Load <VisualTreeAsset>("LayoutPuppeteerConfiguratorWindow");

            visualTree.CloneTree(rootVisualElement);

            VisualTreeAsset leftPanelTree = Resources.Load <VisualTreeAsset>("LayoutLeftPanel");
            VisualElement   leftPanel     = rootVisualElement.Q <VisualElement>(className: "leftPanel");

            leftPanel.styleSheets.Add(Resources.Load <StyleSheet>("StyleLeftPanel"));
            leftPanelTree.CloneTree(leftPanel);

            VisualTreeAsset rightPanelTree = Resources.Load <VisualTreeAsset>("LayoutRightPanel");
            VisualElement   rightPanel     = rootVisualElement.Q <VisualElement>(className: "rightPanel");

            rightPanel.styleSheets.Add(Resources.Load <StyleSheet>("StyleRightPanel"));
            rightPanelTree.CloneTree(rightPanel);

            m_TabView = rootVisualElement.Q <TabView>(className: "puppeteerTabView");

            var textLogo = rootVisualElement.Q <Image>(className: "textLogo");

            textLogo.image = PuppeteerEditorResourceLoader.TextLogo32.texture;

            m_TabView.SetConfiguratorWindow(this);

            m_TabView.AddTab(new GoalView(rootVisualElement, leftPanel, rightPanel, _updated => m_ConfiguratorStates.LastOpenedGoal           = _updated));
            m_TabView.AddTab(new ActionView(rootVisualElement, leftPanel, rightPanel, _updated => m_ConfiguratorStates.LastOpenedAction       = _updated));
            m_TabView.AddTab(new SensorView(rootVisualElement, leftPanel, rightPanel, _updated => m_ConfiguratorStates.LastOpenedSensor       = _updated));
            m_TabView.AddTab(new ArchetypeView(rootVisualElement, leftPanel, rightPanel, _updated => m_ConfiguratorStates.LastOpenedArchetype = _updated));
            m_TabView.AddTab(new AgentView(rootVisualElement, leftPanel, rightPanel, _updated => m_ConfiguratorStates.LastOpenedAgentObjectID = _updated));

            m_TabView.OnTabListItemSelected = _updated => m_ConfiguratorStates.TabTypeName = _updated;
            m_TabView.Enable();

            RestoreLastOpened();
            AddShortcuts();
            RegisterCallbacks();

            TextElement versionText = rootVisualElement.Q <TextElement>(name: "version");

            versionText.text = PuppeteerEditorHelper.GetVersion();

            StyleSheet styleSheet = Resources.Load <StyleSheet>("StylePuppeteerConfiguratorWindow");

            rootVisualElement.styleSheets.Add(styleSheet);

            StyleSheet themeSheet = Resources.Load <StyleSheet>(EditorGUIUtility.isProSkin ? "StyleDarkTheme" : "StyleLightTheme");

            rootVisualElement.styleSheets.Add(themeSheet);
        }
Example #12
0
        private WorldStateItem CreateWorldStateItem(WorldStateDescription _worldStateDescription)
        {
            WorldStateItem worldStateItem = new WorldStateItem(_worldStateDescription);

            worldStateItem.OnMouseDown    += _item => PuppeteerEditorHelper.UpdateSelectedWorldStateItem(ref m_SelectedWorldStateItem, _item);
            worldStateItem.OnDuplicate    += _item => AddNewWorldStateItem(_item.parent, new WorldStateDescription(_item.GetWorldStateDescription()));
            worldStateItem.OnValueChanged += _item =>
            {
                m_SelectedListItem.MarkUnsavedChanges(true);
                AddUnsavedMarker();
            };

            return(worldStateItem);
        }
Example #13
0
 public override void ClearSelection()
 {
     if (m_SelectedGoalPartItem != null)
     {
         PuppeteerEditorHelper.UpdateSelectedWorldStateItem(ref m_SelectedGoalPartItem, null);
     }
     else if (m_SelectedWorkingMemoryUtilityItem != null)
     {
         UpdateSelectedUtilityItem(null);
     }
     else
     {
         base.ClearSelection();
     }
 }
Example #14
0
        public override void DrawInspector(PuppeteerPlanVisualiser _visualiser)
        {
            PuppeteerEditorGUIHelper.DrawGraphInspectorHeader(PuppeteerEditorResourceLoader.GoalIcon32.texture, "Goal", GetContentTypeName());

            EditorGUILayout.Space();
            PuppeteerEditorGUIHelper.DrawDivider();
            EditorGUILayout.Space();

            _visualiser.ShowGoalUtilityFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(_visualiser.ShowGoalUtilityFoldout, "Utility");
            if (_visualiser.ShowGoalUtilityFoldout)
            {
                ++EditorGUI.indentLevel;
                PuppeteerEditorGUIHelper.DrawHorizontal("Base Utility", m_GoalDescription.BaseUtility.ToString());

                ++EditorGUI.indentLevel;
                foreach (var utilityPart in m_GoalDescription.UtilityParts)
                {
                    EditorGUILayout.LabelField(string.Format("{0} {1} * {2}", PuppeteerEditorHelper.UtilityOperatorToString(utilityPart.UtilityOperator),
                                                             utilityPart.WorldStateName.ToString(), utilityPart.CurveMultiplier));
                }
                --EditorGUI.indentLevel;

                --EditorGUI.indentLevel;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();

            _visualiser.ShowGoalPartsFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(_visualiser.ShowGoalPartsFoldout, "Goal Parts");
            if (_visualiser.ShowGoalPartsFoldout)
            {
                ++EditorGUI.indentLevel;
                foreach (var goalPart in m_GoalDescription.GoalParts)
                {
                    PuppeteerEditorGUIHelper.DrawHorizontal(goalPart.Key, goalPart.Value.ToString());
                }
                --EditorGUI.indentLevel;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();

            EditorGUILayout.Space();
            PuppeteerEditorGUIHelper.DrawDivider();
            EditorGUILayout.Space();

            if (GUILayout.Button("Open Configuration"))
            {
                var window = PuppeteerConfiguratorWindow.CreateWindow();
                window.OpenEntryInTabOfType <GoalView>(m_GoalDescription.GUID);
            }
        }
Example #15
0
 public override void DeleteSelection()
 {
     if (m_SelectedGoalPartItem != null)
     {
         PuppeteerEditorHelper.DeleteWorldStateItem(this, m_SelectedListItem as GoalListItem,
                                                    ref (m_SelectedListItem as GoalListItem).GetDescription().GoalParts, m_SelectedGoalPartItem, SelectNeighbourGoalPartItemIfNeeded);
     }
     else if (m_SelectedWorkingMemoryUtilityItem != null)
     {
         DeleteUtilityItem(m_SelectedWorkingMemoryUtilityItem);
     }
     else
     {
         base.DeleteSelection();
     }
 }
Example #16
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);
            }
        }
Example #17
0
        private void AddNewGoalPartItem(WorldStateDescription _goalPart)
        {
            if (m_SelectedListItem is GoalListItem selectedGoalListItem)
            {
                GoalDescription selectedDescription = selectedGoalListItem.GetDescription();

                int newIndex = PuppeteerEditorHelper.Append(ref selectedDescription.GoalParts, _goalPart);

                WorldStateItem goalPartItem = CreateGoalPartItem(selectedDescription.GoalParts[newIndex]);

                m_SelectedListItem.MarkUnsavedChanges(true);
                AddUnsavedMarker();

                PuppeteerEditorHelper.UpdateSelectedWorldStateItem(ref m_SelectedGoalPartItem, goalPartItem);
            }
        }
Example #18
0
        protected override void UpdateConfigurator()
        {
            if (m_SelectedListItem is ActionListItem selectedActionListItem)
            {
                EnableRightPanelContent();
                LazyInitConfigurator();

                ActionDescription selectedDescription = selectedActionListItem.GetDescription();

                m_ActionConfigurator.DisplayName.value = selectedDescription.DisplayName;
                m_ActionConfigurator.GUIDLabel.text    = selectedDescription.GUID.ToString();
                m_ActionConfigurator.BaseUtility.value = selectedDescription.BaseUtility;

                if (selectedDescription.ExecutableActionType != null)
                {
                    m_ActionConfigurator.ActionField.SetValueWithoutNotify(selectedDescription.ExecutableActionType);
                }

                m_ActionConfigurator.PreconditionsContainer.Clear();
                for (int i = 0; i < selectedDescription.Preconditions.Length; ++i)
                {
                    WorldStateItem worldStateItem = CreateWorldStateItem(selectedDescription.Preconditions[i]);
                    worldStateItem.OnDelete += _item =>
                    {
                        PuppeteerEditorHelper.DeleteWorldStateItem(this, m_SelectedListItem as ActionListItem,
                                                                   ref (m_SelectedListItem as ActionListItem).GetDescription().Preconditions, _item, null);
                    };

                    m_ActionConfigurator.PreconditionsContainer.Add(worldStateItem);
                }

                m_ActionConfigurator.EffectsContainer.Clear();
                for (int i = 0; i < selectedDescription.Effects.Length; ++i)
                {
                    WorldStateItem worldStateItem = CreateWorldStateItem(selectedDescription.Effects[i]);
                    worldStateItem.OnDelete += _item =>
                    {
                        PuppeteerEditorHelper.DeleteWorldStateItem(this, m_SelectedListItem as ActionListItem,
                                                                   ref (m_SelectedListItem as ActionListItem).GetDescription().Effects, _item, null);
                    };

                    m_ActionConfigurator.EffectsContainer.Add(worldStateItem);
                }
            }
        }
Example #19
0
 public override void EnterSelection()
 {
     if (m_SelectedGoalPartItem != null)
     {
         PuppeteerEditorHelper.UpdateSelectedWorldStateItem(ref m_SelectedGoalPartItem, null);
     }
     else if (m_SelectedWorkingMemoryUtilityItem != null)
     {
         UpdateSelectedUtilityItem(m_SelectedWorkingMemoryUtilityItem);
     }
     else if (m_SelectedListItem != null)
     {
         if (m_GoalConfigurator != null && m_GoalConfigurator.GoalPartsContainer.childCount > 0)
         {
             PuppeteerEditorHelper.UpdateSelectedWorldStateItem(ref m_SelectedGoalPartItem, m_GoalConfigurator.GoalPartsContainer[0] as WorldStateItem);
         }
     }
 }
            public override void Init(VisualElement _ve, IUxmlAttributes _bag, CreationContext _cc)
            {
                base.Init(_ve, _bag, _cc);

                UtilityOperatorSelectorField utilityOperatorSelectorField = (UtilityOperatorSelectorField)_ve;

                string valueFromBag = m_Value.GetValueFromBag(_bag, _cc);

                KeyValuePair <UtilityOperators, string> validPair = PuppeteerEditorHelper.GetUtilityOperatorStringPairs().FirstOrDefault(_entry =>
                {
                    return(_entry.Value == valueFromBag);
                });

                if (validPair.Value != string.Empty)
                {
                    utilityOperatorSelectorField.SetValueWithoutNotify(validPair.Key);
                }
            }
Example #21
0
        public override void SaveAllChanges()
        {
            bool shouldSaveToFile = PuppeteerEditorHelper.RemoveDeletedItems <GoalListItem, GoalDescription>(m_SerialisedGoals, m_ListItems) > 0;

            for (int i = 0; i < m_ListItems.Count; ++i)
            {
                shouldSaveToFile |= PuppeteerEditorHelper.AddOrUpdateInList <GoalListItem, GoalDescription>(m_SerialisedGoals, m_ListItems[i]);
            }

            bool successful = !shouldSaveToFile || PuppeteerManager.Instance.SaveGoals();

            if (successful)
            {
                for (int i = 0; i < m_ListItems.Count; ++i)
                {
                    m_ListItems[i].MarkUnsavedChanges(false);
                    TryClearUnsavedMarker();
                }
            }
        }
Example #22
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);
        }
Example #23
0
        private void AddNewWorldStateItem(VisualElement _targetContainer, WorldStateDescription _worldStateDescription)
        {
            if (m_SelectedListItem is ActionListItem selectedActionListItem)
            {
                ActionDescription selectedDescription = selectedActionListItem.GetDescription();

                WorldStateItem worldStateItem;

                if (_targetContainer == m_ActionConfigurator.EffectsContainer)
                {
                    int newIndex = PuppeteerEditorHelper.Append(ref selectedDescription.Effects, _worldStateDescription);
                    worldStateItem           = CreateWorldStateItem(selectedDescription.Effects[newIndex]);
                    worldStateItem.OnDelete += _item =>
                    {
                        PuppeteerEditorHelper.DeleteWorldStateItem(this, m_SelectedListItem as ActionListItem,
                                                                   ref (m_SelectedListItem as ActionListItem).GetDescription().Effects, _item, null);
                    };
                }
                else
                {
                    int newIndex = PuppeteerEditorHelper.Append(ref selectedDescription.Preconditions, _worldStateDescription);
                    worldStateItem           = CreateWorldStateItem(selectedDescription.Preconditions[newIndex]);
                    worldStateItem.OnDelete += _item =>
                    {
                        PuppeteerEditorHelper.DeleteWorldStateItem(this, m_SelectedListItem as ActionListItem,
                                                                   ref (m_SelectedListItem as ActionListItem).GetDescription().Preconditions, _item, null);
                    };
                }

                _targetContainer.Add(worldStateItem);

                m_SelectedListItem.MarkUnsavedChanges(true);
                AddUnsavedMarker();

                PuppeteerEditorHelper.UpdateSelectedWorldStateItem(ref m_SelectedWorldStateItem, worldStateItem);
            }
        }
Example #24
0
        private void RegisterConfiguratorCallbacks()
        {
            m_ActionConfigurator.ActionField.RegisterCallback <ChangeEvent <Type> >(_event =>
            {
                (m_SelectedListItem as ActionListItem).GetDescription().ExecutableActionType = _event.newValue;
                m_SelectedListItem.MarkUnsavedChanges(true);
                AddUnsavedMarker();
            });

            m_ActionConfigurator.DisplayName.RegisterCallback <FocusOutEvent>(_eventTarget =>
            {
                if (PuppeteerEditorHelper.UpdateDescriptionIfNecessary((_eventTarget.target as TextField), ref (m_SelectedListItem as ActionListItem).GetDescription().DisplayName))
                {
                    m_SelectedListItem.ChangeText((_eventTarget.target as TextField).value);
                    m_SelectedListItem.MarkUnsavedChanges(true);
                    AddUnsavedMarker();
                }
            });

            m_ActionConfigurator.BaseUtility.RegisterCallback <FocusOutEvent>(_eventTarget =>
            {
                if (m_SelectedListItem is ActionListItem selectedActionListItem)
                {
                    float currentUtility = selectedActionListItem.GetDescription().BaseUtility;
                    float newUtility     = (_eventTarget.target as FloatField).value;

                    newUtility = Mathf.Max(newUtility, 1);

                    if (currentUtility != newUtility)
                    {
                        selectedActionListItem.GetDescription().BaseUtility = newUtility;
                        selectedActionListItem.MarkUnsavedChanges(true);
                        AddUnsavedMarker();
                    }
                }
            });
        }
 public bool IsInSync()
 {
     return(Enumerable.SequenceEqual(m_ArchetypeGuids, PuppeteerEditorHelper.GetArchetypeSelectorGUIDs()));
 }
 public static string GetUtilityOperatorName(UtilityOperators _operator)
 {
     return(PuppeteerEditorHelper.UtilityOperatorToString(_operator));
 }
Example #27
0
        private void RegisterConfiguratorCallbacks()
        {
            m_SensorConfigurator.SensorField.RegisterCallback<ChangeEvent<Type>>(_event =>
            {
                (m_SelectedListItem as SensorListItem).GetDescription().ExecutableSensorType = _event.newValue;
                m_SelectedListItem.MarkUnsavedChanges(true);
                AddUnsavedMarker();
            });

            m_SensorConfigurator.DisplayName.RegisterCallback<FocusOutEvent>(_eventTarget =>
            {
                if (PuppeteerEditorHelper.UpdateDescriptionIfNecessary((_eventTarget.target as TextField), ref (m_SelectedListItem as SensorListItem).GetDescription().DisplayName))
                {
                    m_SelectedListItem.ChangeText((_eventTarget.target as TextField).value);
                    m_SelectedListItem.MarkUnsavedChanges(true);
                    AddUnsavedMarker();
                }
            });

            m_SensorConfigurator.ManagedWorldState.RegisterCallback<FocusOutEvent>(_eventTarget =>
            {
                if (m_SelectedListItem is SensorListItem selectedSensorListItem)
                {
                    if (PuppeteerEditorHelper.UpdateDescriptionIfNecessary((_eventTarget.target as TextField), ref selectedSensorListItem.GetDescription().ManagedWorldState))
                    {
                        selectedSensorListItem.MarkUnsavedChanges(true);
                        AddUnsavedMarker();
                    }
                }
            });

            m_SensorConfigurator.ExecutionOrderField.RegisterCallback<FocusOutEvent>(_eventTarget =>
            {
                if (m_SelectedListItem is SensorListItem selectedSensorListItem)
                {
                    if (_eventTarget.target is IntegerField targetField)
                    {
                        targetField.value = Mathf.Max(targetField.value, 0);
                        if (PuppeteerEditorHelper.UpdateDescriptionIfNecessary(targetField, ref selectedSensorListItem.GetDescription().ExecutionOrder))
                        {
                            selectedSensorListItem.MarkUnsavedChanges(true);
                            AddUnsavedMarker();
                        }
                    }
                }
            });

            m_SensorConfigurator.TickRateField.RegisterCallback<FocusOutEvent>(_eventTarget =>
            {
                if (m_SelectedListItem is SensorListItem selectedSensorListItem)
                {
                    if (_eventTarget.target is IntegerField targetField)
                    {
                        targetField.value = Mathf.Max(targetField.value, 1);
                        if (PuppeteerEditorHelper.UpdateDescriptionIfNecessary(targetField, ref selectedSensorListItem.GetDescription().TickRate))
                        {
                            selectedSensorListItem.MarkUnsavedChanges(true);
                            AddUnsavedMarker();
                        }
                    }
                }
            });

            m_SensorConfigurator.ShouldBeTickedToggle.RegisterValueChangedCallback(_changeEvent =>
            {
                if (m_SelectedListItem is SensorListItem selectedSensorListItem)
                {
                    m_SensorConfigurator.TickRateField.SetEnabled(_changeEvent.newValue);
                    m_SensorConfigurator.ExecutionOrderField.SetEnabled(_changeEvent.newValue);
                    selectedSensorListItem.MarkUnsavedChanges(true);
                    AddUnsavedMarker();
                }
            });
        }