public static void DrawTargetSelector(ICECreatureControl _control, TargetSelectorConditionObject _selector) { if (_selector == null) { return; } ICEEditorLayout.BeginHorizontal(); ICEEditorLayout.EndHorizontal(); }
public static void DrawTargetSelectors(ICECreatureControl _control, TargetSelectorsObject _selectors, TargetType _type, float _min_distance, float _max_distance) { string _help = Info.TARGET_SELECTION_CRITERIA; if (_type == TargetType.HOME) { _help = Info.TARGET_SELECTION_CRITERIA + "\n\n" + Info.TARGET_SELECTION_CRITERIA_HOME; } // TARGET SELECTION CRITERIAS if (_type == TargetType.HOME) { _selectors.UseSelectionCriteriaForHome = ICEEditorLayout.Toggle("Target Selection Criteria", "The HOME target should always have the lowest priority, but if you want you could adapt these settings also.", _selectors.UseSelectionCriteriaForHome, _help); } else { ICEEditorLayout.Label("Target Selection Criteria", false); } if (_type == TargetType.HOME && _selectors.UseSelectionCriteriaForHome == false) { _selectors.Priority = 0; _selectors.SelectionRange = 0; _selectors.SelectionAngle = 0; _selectors.UseAdvanced = false; return; } EditorGUI.indentLevel++; // PRIORITY BEGIN ICEEditorLayout.BeginHorizontal(); if (_selectors.CanUseDefaultPriority) { _selectors.Priority = (int)ICEEditorLayout.AutoSlider("Priority", "", _selectors.Priority, 1, 0, 100, ref _selectors.UseDefaultPriority, _selectors.DefaultPriority); } else { _selectors.Priority = (int)ICEEditorLayout.DefaultSlider("Priority", "Priority to select this target!", _selectors.Priority, 1, 0, 100, _selectors.GetDefaultPriorityByType(_type)); } ICEEditorLayout.EndHorizontal(_help); // PRIORITY END /* * if( _selectors.UseAdvanced ) * { * ICEEditorLayout.DrawProgressBar("Dynamic Priority", _selectors.GetPriority( _type ) ); * }*/ string _range_title = "Selection Range"; if (_selectors.SelectionRange == 0) { _range_title += " (infinite)"; } else { _range_title += " (limited)"; } // SELECTION RANGE BEGIN ICEEditorLayout.BeginHorizontal(); _selectors.SelectionRange = ICEEditorLayout.DefaultSlider(_range_title, "If the selection range greater than 0 this target will only select if the creature is within the specified range", _selectors.SelectionRange, Init.SELECTION_RANGE_STEP, _min_distance, _max_distance, _selectors.GetDefaultRangeByType(_type)); if (_selectors.UseFieldOfView) { GUI.backgroundColor = Color.yellow; } if (GUILayout.Button(new GUIContent("FOV", "Field Of View - the target must be visible for the creature"), ICEEditorStyle.CMDButtonDouble)) { _selectors.UseFieldOfView = !_selectors.UseFieldOfView; } GUI.backgroundColor = ICEEditorLayout.DefaultBackgroundColor; if (_selectors.UseAdvanced) { if (GUILayout.Button(new GUIContent("AND", "Add additional AND conditions"), ICEEditorStyle.CMDButtonDouble)) { _selectors.Selectors.Add(new TargetSelectorObject(ConditionalOperatorType.AND)); } if (GUILayout.Button(new GUIContent("OR", "Add additional OR conditions"), ICEEditorStyle.CMDButtonDouble)) { _selectors.Selectors.Add(new TargetSelectorObject(ConditionalOperatorType.AND)); } //if (GUILayout.Button( new GUIContent( "THEN", "Add optional statements for cases the conditions are complied with or completed within the timescales determined" ) , ICEEditorStyle.CMDButtonDouble ) ) // _selectors.Statements.Add( new TargetSelectorStatementObject() ); if (GUILayout.Button(new GUIContent("RESET", "Removes all groups and conditions"), ICEEditorStyle.CMDButtonDouble)) { _selectors.Selectors.Clear(); } } if (_selectors.UseAdvanced) { GUI.backgroundColor = new Vector4(1, 0.6f, 0.3f, 1); } else { GUI.backgroundColor = Color.green; } if (GUILayout.Button(new GUIContent("ADV", "Use advanced selector settings"), ICEEditorStyle.CMDButtonDouble)) { _selectors.UseAdvanced = !_selectors.UseAdvanced; } GUI.backgroundColor = ICEEditorLayout.DefaultBackgroundColor; ICEEditorLayout.EndHorizontal(); // SELECTION RANGE END EditorGUI.BeginDisabledGroup(_selectors.SelectionRange == 0); EditorGUI.indentLevel++; string _angle_title = "Angular Restriction"; if (_selectors.SelectionAngle == 0 || _selectors.SelectionAngle == 180) { _angle_title += " (full-circle)"; } else if (_selectors.SelectionAngle == 90) { _angle_title += " (semi-circle)"; } else if (_selectors.SelectionAngle == 45) { _angle_title += " (quadrant)"; } else { _angle_title += " (sector)"; } // SELECTION ANGLE BEGIN ICEEditorLayout.BeginHorizontal(); _selectors.SelectionAngle = ICEEditorLayout.DefaultSlider(_angle_title, "", _selectors.SelectionAngle * 2, Init.SELECTION_ANGLE_STEP, Init.SELECTION_ANGLE_MIN, Init.SELECTION_ANGLE_MAX, _selectors.GetDefaultAngleByType(_type)) / 2; if (GUILayout.Button(new GUIContent("90", ""), ICEEditorStyle.CMDButtonDouble)) { _selectors.SelectionAngle = 45; } if (GUILayout.Button(new GUIContent("180", ""), ICEEditorStyle.CMDButtonDouble)) { _selectors.SelectionAngle = 90; } if (GUILayout.Button(new GUIContent("360", ""), ICEEditorStyle.CMDButtonDouble)) { _selectors.SelectionAngle = 180; } ICEEditorLayout.EndHorizontal(); EditorGUI.indentLevel--; EditorGUI.EndDisabledGroup(); // SELECTION ANGLE END if (_selectors.UseAdvanced) { Info.Help(Info.TARGET_SELECTION_CRITERIA_ADVANCED); // SELECTOR GROUPS BEGIN foreach (TargetSelectorObject _selector in _selectors.Selectors) { EditorGUI.indentLevel++; for (int i = 0; i < _selector.Conditions.Count; i++) { if (i > 0) { EditorGUI.indentLevel++; } TargetSelectorConditionObject _condition = _selector.Conditions[i]; string _prefix = _condition.ConditionToString(); string _operator = _condition.OperatorToString(); ICEEditorLayout.BeginHorizontal(); if (_condition.ExpressionType == TargetSelectorExpressionType.NONE) { _condition.ExpressionType = (TargetSelectorExpressionType)ICEEditorLayout.EnumPopup(_prefix, "Adds an additional selector of the defined type", TargetSelectorExpressionType.NONE); } else if (_condition.ExpressionType == TargetSelectorExpressionType.DISTANCE) { _condition.Distance = ICEEditorLayout.Slider(_prefix + " Distance " + _operator, "If the selection range greater than 0 this target will only select if the creature is within the specified range", _condition.Distance, Init.SELECTION_RANGE_STEP, Init.SELECTION_RANGE_MIN, Init.SELECTION_RANGE_MAX); } else if (_condition.ExpressionType == TargetSelectorExpressionType.BEHAVIOR) { _condition.BehaviourModeKey = EditorBehaviour.BehaviourPopup(_control, _prefix + " Behaviour " + _operator, "", _condition.BehaviourModeKey); } else if (_condition.ExpressionType == TargetSelectorExpressionType.POSITION) { _condition.PositionType = (TargetSelectorPositionType)ICEEditorLayout.EnumPopup(_prefix + " Creatures Position " + _operator, "Adds an additional selector of the defined type", _condition.PositionType); } else if (_condition.ExpressionType == TargetSelectorExpressionType.PRECURSOR) { if (_condition.PrecursorType == TargetPrecursorType.TYPE) { _condition.PrecursorTargetType = (TargetType)ICEEditorLayout.EnumPopup(_prefix + " Precursor Type " + _operator, "This target will only select if the active target has the specified type.", _condition.PrecursorTargetType); } else if (_condition.PrecursorType == TargetPrecursorType.TAG) { _condition.PrecursorTargetTag = EditorGUILayout.TagField(_prefix + " Precursor Tag " + _operator, _condition.PrecursorTargetTag); } else if (_condition.PrecursorType == TargetPrecursorType.NAME) { _condition.PrecursorTargetName = DrawTargetPopup(_control, _prefix + " Precursor Name " + _operator, "This target will only select if the active target has the specified name.", _condition.PrecursorTargetName); } if (GUILayout.Button(new GUIContent(_condition.PrecursorType.ToString(), "Select precursor type"), ICEEditorStyle.CMDButtonDouble)) { if (_condition.PrecursorType == TargetPrecursorType.TAG) { _condition.PrecursorType = 0; } else { _condition.PrecursorType++; } } } // STANDARD BUTTONS BEGIN if (GUILayout.Button(new GUIContent(_prefix, "Changes conditional operator"), ICEEditorStyle.CMDButtonDouble)) { if (_condition.ConditionType == ConditionalOperatorType.AND) { _condition.ConditionType = ConditionalOperatorType.OR; } else { _condition.ConditionType = ConditionalOperatorType.AND; } } if (GUILayout.Button(new GUIContent(_operator, "Changes relational operator"), ICEEditorStyle.CMDButtonDouble)) { if (_condition.ExpressionType == TargetSelectorExpressionType.DISTANCE) { if (_condition.Operator == LogicalOperatorType.GREATER_OR_EQUAL) { _condition.Operator = 0; } else { _condition.Operator++; } } else { if (_condition.Operator == LogicalOperatorType.NOT) { _condition.Operator = 0; } else { _condition.Operator++; } } } if (GUILayout.Button(new GUIContent("DEL", "Removes this condition"), ICEEditorStyle.CMDButtonDouble)) { _selector.Conditions.Remove(_condition); return; } // STANDARD BUTTONS END ICEEditorLayout.EndHorizontal(); if (i > 0) { EditorGUI.indentLevel--; } } // SELECTOR STATMENTS BEGIN //if( _selector.Statements.Count > 0 ) // DrawTargetSelectorStatement( _control, _selector.Statements ); // SELECTOR STATMENTS END // SELECTOR ADD BEGIN ICEEditorLayout.BeginHorizontal(); if (_selector.Statements.Count > 0) { DrawTargetSelectorStatementContent(_control, _selector.Statements[0]); } else { ICEEditorLayout.Label(" ", false); } if (GUILayout.Button(new GUIContent("THEN", "Add Statement"), ICEEditorStyle.CMDButtonDouble)) { if (_selector.Statements.Count == 0) { _selector.Statements.Add(new TargetSelectorStatementObject()); } else { _selector.Statements.Clear(); } return; } if (GUILayout.Button(new GUIContent("AND", "Add AND condition"), ICEEditorStyle.CMDButtonDouble)) { _selector.Conditions.Add(new TargetSelectorConditionObject(ConditionalOperatorType.AND)); return; } if (GUILayout.Button(new GUIContent("OR", "Add OR condition"), ICEEditorStyle.CMDButtonDouble)) { _selector.Conditions.Add(new TargetSelectorConditionObject(ConditionalOperatorType.OR)); return; } if (GUILayout.Button(new GUIContent("DEL", "Removes the selected group"), ICEEditorStyle.CMDButtonDouble)) { _selectors.Selectors.Remove(_selector); return; } ICEEditorLayout.EndHorizontal(); // SELECTOR ADD END EditorGUI.indentLevel--; } // SELECTOR GROUPS END // SELECTOR STATMENTS BEGIN //if( _selectors.Statements.Count > 0 ) // DrawTargetSelectorStatement( _control, _selectors.Statements ); // SELECTOR STATMENTS END } EditorGUI.indentLevel--; }