public void RemoveEffect(GOAPState _effect) { if (effects.Remove(_effect)) { onEffectRemoved?.Invoke(_effect); } }
public void RemovePrecondition(GOAPState _precondition) { if (preconditions.Remove(_precondition)) { onPreconditionRemoved?.Invoke(_precondition); } }
void OnEffectRemoved(GOAPState _newEffect) { if (EffectElements.TryGetValue(_newEffect, out VisualElement e)) { effectFoldout.Remove(e); EffectElements.Remove(_newEffect); } }
void OnPreconditionRemoved(GOAPState _condition) { if (ConditionElements.TryGetValue(_condition, out VisualElement e)) { conditionFoldout.Remove(e); ConditionElements.Remove(_condition); } }
void OnEffectAdded(GOAPState _newEffect) { VisualElement v = CreateToggle(_newEffect, (ele, state) => { T_Model.RemoveEffect(state); }); effectFoldout.Add(v); EffectElements[_newEffect] = v; }
void OnPreconditionAdded(GOAPState _newCondition) { VisualElement v = CreateToggle(_newCondition, (ele, state) => { T_Model.RemovePrecondition(state); }); conditionFoldout.Add(v); ConditionElements[_newCondition] = v; }
VisualElement CreateToggle(GOAPState _state, Action <VisualElement, GOAPState> _onBtnRemoveClicked) { VisualElement box = new VisualElement(); box.style.flexDirection = FlexDirection.Row; Toggle toggle = new Toggle(); toggle.value = _state.Value; toggle.RegisterValueChangedCallback(evt => { _state.Value = evt.newValue; }); toggle.style.width = 20; box.Add(toggle); TextField keyField = new TextField(); keyField.value = _state.Key; keyField.RegisterValueChangedCallback(evt => { _state.Key = evt.newValue; }); keyField.style.flexGrow = 1; keyField.RegisterCallback <FocusInEvent>(evt => { Input.imeCompositionMode = IMECompositionMode.On; }); keyField.RegisterCallback <FocusOutEvent>(evt => { Input.imeCompositionMode = IMECompositionMode.Auto; }); box.Add(keyField); box.Add(CreateSmallButton(EditorGUIUtility.FindTexture("P4_DeletedLocal"), 14, () => { _onBtnRemoveClicked?.Invoke(box, _state); })); box.userData = _state; return(box); }
public void AddEffect(GOAPState _effect) { effects.Add(_effect); onEffectAdded?.Invoke(_effect); }
public void AddPrecondition(GOAPState _precondition) { preconditions.Add(_precondition); onPreconditionAdded?.Invoke(_precondition); }