public static string BlueprintIdSelection( GUIContent label, string selectedBlueprintId, InspectorTypeTable inspectorComponentTypes, IBlueprintManager blueprintManager) { // Store all blueprint ids for access from a pulldown menu. var blueprintIds = blueprintManager.Blueprints.Select(blueprint => blueprint.Key).ToArray(); // Show blueprint dropdown. var oldSelectedBlueprintIndex = Array.IndexOf(blueprintIds, selectedBlueprintId); var selectedBlueprintIndex = EditorGUILayout.Popup( label, oldSelectedBlueprintIndex, blueprintIds.Select(blueprintId => new GUIContent(blueprintId)).ToArray()); if (selectedBlueprintIndex != oldSelectedBlueprintIndex) { // Update selected blueprint of the target entity. return(blueprintIds[selectedBlueprintIndex >= 0 ? selectedBlueprintIndex : 0]); } else { return(selectedBlueprintId); } }
public static void BlueprintComponentsField( Blueprint blueprint, IAttributeTable configuration, InspectorTypeTable inspectorTypeTable, IBlueprintManager blueprintManager) { // Compute maximum label width. float maxLabelWidth = 0; foreach (var componentType in blueprint.GetAllComponentTypes()) { var inspectorType = inspectorTypeTable[componentType]; foreach (var componentProperty in inspectorType.Properties) { var textDimensions = GUI.skin.label.CalcSize(new GUIContent(componentProperty.Name)); maxLabelWidth = MathUtils.Max(textDimensions.x, maxLabelWidth); } } EditorGUIUtility.labelWidth = maxLabelWidth; foreach (var componentType in blueprint.GetAllComponentTypes()) { var inspectorType = inspectorTypeTable[componentType]; // Draw inspector. AttributeTableField(inspectorType, configuration, inspectorTypeTable, blueprintManager); } }
public static int CreateEntity( EntityManager entityManager, IBlueprintManager blueprintManager, string blueprintId) { return(CreateEntity(entityManager, blueprintManager, blueprintId, null)); }
public static int CreateEntity( EntityManager entityManager, IBlueprintManager blueprintManager, string blueprintId) { return CreateEntity(entityManager, blueprintManager, blueprintId, null); }
/// <summary> /// Draws an inspector for the passed attribute table. /// </summary> /// <param name="inspectorType">Type to draw inspector controls for.</param> /// <param name="attributeTable">Attribute to draw inspector for.</param> /// <param name="inspectorTypeTable"></param> /// <param name="blueprintManager"></param> public static void AttributeTableField( InspectorType inspectorType, IAttributeTable attributeTable, InspectorTypeTable inspectorTypeTable, IBlueprintManager blueprintManager) { foreach (var inspectorProperty in inspectorType.Properties) { // Get current value. object currentValue = attributeTable.GetValueOrDefault( inspectorProperty.Name, inspectorProperty.Default); // Draw inspector property. object newValue = LogicInspectorPropertyField( inspectorProperty, currentValue, inspectorTypeTable, blueprintManager); // Set new value if changed. if (!Equals(newValue, currentValue)) { attributeTable.SetValue(inspectorProperty.Name, newValue); } } }
/// <summary> /// Tries to resolve the parent references in the blueprints of the specified manager by searching in the /// specified available blueprint manager. /// </summary> /// <param name="blueprintManager">Blueprint manager to resolve parent references from.</param> /// <param name="availableBlueprintManager">Blueprint manager to use to search for parent blueprints.</param> public static void TryResolveParents( IBlueprintManager blueprintManager, IBlueprintManager availableBlueprintManager) { foreach (Blueprint blueprint in blueprintManager) { TryResolveParent(blueprint, availableBlueprintManager); } }
/// <summary> /// Resolves the parent reference in the specified blueprint by searching in the specified /// available blueprint manager. /// </summary> /// <param name="blueprint">Blueprint to resolve parent reference for.</param> /// <param name="blueprintManager">Blueprint manager to use to search for parent blueprints.</param> /// <exception cref="KeyNotFoundException">Thrown if parent couldn't be resolved.</exception> public static void ResolveParent(Blueprint blueprint, IBlueprintManager blueprintManager) { if (string.IsNullOrEmpty(blueprint.ParentId) || blueprint.Parent != null) { return; } blueprint.Parent = blueprintManager.GetBlueprint(blueprint.ParentId); }
public static int CreateEntity( EntityManager entityManager, IBlueprintManager blueprintManager, string blueprintId, AttributeTable configuration) { var blueprint = blueprintManager.GetBlueprint(blueprintId); return entityManager.CreateEntity(blueprint, configuration); }
public static List<int> CreateEntities( EntityManager entityManager, IBlueprintManager blueprintManager, IEnumerable<string> blueprintIds) { return blueprintIds.Select( actionBlueprintId => CreateEntity(entityManager, blueprintManager, actionBlueprintId)).ToList(); }
public static List <int> CreateEntities( EntityManager entityManager, IBlueprintManager blueprintManager, IEnumerable <string> blueprintIds) { return (blueprintIds.Select( actionBlueprintId => CreateEntity(entityManager, blueprintManager, actionBlueprintId)).ToList()); }
public static int CreateEntity( EntityManager entityManager, IBlueprintManager blueprintManager, string blueprintId, AttributeTable configuration) { var blueprint = blueprintManager.GetBlueprint(blueprintId); return(entityManager.CreateEntity(blueprint, configuration)); }
/// <summary> /// Tries to resolve the parent reference in the specified blueprint by searching in the specified /// available blueprint manager. /// </summary> /// <param name="blueprint">Blueprint to try to resolve parent reference for.</param> /// <param name="blueprintManager">Blueprint manager to use to search for parent blueprints.</param> /// <returns><c>true</c>, if the parent blueprint could be found, and <c>false</c> otherwise.</returns> public static bool TryResolveParent(Blueprint blueprint, IBlueprintManager blueprintManager) { if (string.IsNullOrEmpty(blueprint.ParentId) || blueprint.Parent != null) { return true; } Blueprint parentBlueprint; bool foundParent = blueprintManager.TryGetBlueprint(blueprint.ParentId, out parentBlueprint); blueprint.Parent = parentBlueprint; return foundParent; }
/// <summary> /// Tries to resolve the parent reference in the specified blueprint by searching in the specified /// available blueprint manager. /// </summary> /// <param name="blueprint">Blueprint to try to resolve parent reference for.</param> /// <param name="blueprintManager">Blueprint manager to use to search for parent blueprints.</param> /// <returns><c>true</c>, if the parent blueprint could be found, and <c>false</c> otherwise.</returns> public static bool TryResolveParent(Blueprint blueprint, IBlueprintManager blueprintManager) { if (string.IsNullOrEmpty(blueprint.ParentId) || blueprint.Parent != null) { return(true); } Blueprint parentBlueprint; bool foundParent = blueprintManager.TryGetBlueprint(blueprint.ParentId, out parentBlueprint); blueprint.Parent = parentBlueprint; return(foundParent); }
private void DrawInspector(InspectorType inspectorType, IAttributeTable configuration, InspectorTypeTable inspectorTypeTable, IBlueprintManager blueprintManager) { foreach (var inspectorProperty in inspectorType.Properties) { // Get current value. object currentValue = configuration.GetValueOrDefault(inspectorProperty.Name, inspectorProperty.Default); object newValue = EditorGUIUtils.LogicInspectorPropertyField(inspectorProperty, currentValue, inspectorTypeTable, blueprintManager); // Set new value if changed. if (!Equals(newValue, currentValue)) { configuration.SetValue(inspectorProperty.Name, newValue); } } }
public WorkflowEngine( IValuesEngine valuesEngine, IYamlSerializers serializers, ISecretTracker secretTracker, IConsole console, IJsonHttpClientFactory clientFactory, IBlueprintManager blueprintManager, IWorkflowLoader workflowLoader) { _valuesEngine = valuesEngine; _serializers = serializers; _secretTracker = secretTracker; _console = console; _clientFactory = clientFactory; _blueprintManager = blueprintManager; _workflowLoader = workflowLoader; }
/// <summary> /// Draws an inspector for the specified logic property. /// </summary> /// <param name="inspectorProperty">Logic property to draw the inspector for.</param> /// <param name="currentValue">Current logic property value.</param> /// <param name="inspectorTypeTable"></param> /// <param name="blueprintManager"></param> /// <returns>New logic property value.</returns> public static object LogicInspectorPropertyField( InspectorPropertyAttribute inspectorProperty, object currentValue, InspectorTypeTable inspectorTypeTable, IBlueprintManager blueprintManager) { if (inspectorProperty.IsList) { // Build array. IList currentList = currentValue as IList; InspectorPropertyAttribute localInspectorProperty = inspectorProperty; IList newList; ListField( true, new GUIContent(inspectorProperty.Name), currentList, count => { IList list = localInspectorProperty.GetEmptyList(); for (int idx = 0; idx < count; idx++) { list.Add(localInspectorProperty.DefaultListItem); } return(list); }, (obj, index) => LogicInspectorPropertyField( localInspectorProperty, obj, new GUIContent("Item " + index), inspectorTypeTable, blueprintManager), out newList); return(newList); } // Draw inspector property. return(LogicInspectorPropertyField( inspectorProperty, currentValue, new GUIContent(inspectorProperty.Name, inspectorProperty.Description), inspectorTypeTable, blueprintManager)); }
public WorkflowCommands( IJsonHttpClientFactory clientFactory, ITemplateEngineFactory templateEngineFactory, IYamlSerializers serializers, IJmesPathQuery jmesPathQuery, IPatternMatcherFactory patternMatcherFactory, ISecretTracker secretTracker, IBlueprintManager blueprintManager, IConsole console) { _clientFactory = clientFactory; _templateEngineFactory = templateEngineFactory; _serializers = serializers; _jmesPathQuery = jmesPathQuery; _patternMatcherFactory = patternMatcherFactory; _secretTracker = secretTracker; _blueprintManager = blueprintManager; _console = console; }
public WorkflowCommands( IWorkflowLoader workflowLoader, IWorkflowEngine workflowEngine, IValuesEngine valuesEngine, ITemplateEngineFactory templateEngineFactory, IYamlSerializers serializers, IPatternMatcherFactory patternMatcherFactory, ISecretTracker secretTracker, IBlueprintManager blueprintManager, IConsole console) { _workflowLoader = workflowLoader; _workflowEngine = workflowEngine; _valuesEngine = valuesEngine; _templateEngineFactory = templateEngineFactory; _serializers = serializers; _patternMatcherFactory = patternMatcherFactory; _secretTracker = secretTracker; _blueprintManager = blueprintManager; _console = console; }
/// <summary> /// Adds the passed blueprint manager to be consulted for future /// blueprint lookups. /// </summary> /// <param name="child">New blueprint manager child to add.</param> public void AddChild(IBlueprintManager child) { this.children.Add(child); }
/// <summary> /// Draws an inspector for the specified logic property. /// </summary> /// <param name="inspectorProperty">Logic property to draw the inspector for.</param> /// <param name="currentValue">Current logic property value.</param> /// <param name="label">Text to show next to the property editor.</param> /// <param name="inspectorTypeTable"></param> /// <param name="blueprintManager"></param> /// <returns>New logic property value.</returns> public static object LogicInspectorPropertyField( InspectorPropertyAttribute inspectorProperty, object currentValue, GUIContent label, InspectorTypeTable inspectorTypeTable, IBlueprintManager blueprintManager) { // Draw inspector control. if (inspectorProperty is InspectorBoolAttribute) { return(EditorGUILayout.Toggle(label, Convert.ToBoolean(currentValue))); } if (inspectorProperty is InspectorStringAttribute || inspectorProperty is InspectorBlueprintAttribute) { return(EditorGUILayout.TextField(label, Convert.ToString(currentValue))); } if (inspectorProperty is InspectorFloatAttribute) { return(EditorGUILayout.FloatField(label, Convert.ToSingle(currentValue))); } if (inspectorProperty is InspectorIntAttribute) { return(EditorGUILayout.IntField(label, Convert.ToInt32(currentValue))); } InspectorEnumAttribute enumInspectorProperty = inspectorProperty as InspectorEnumAttribute; if (enumInspectorProperty != null) { object currentEnumValue = (currentValue != null) ? Convert.ChangeType(currentValue, enumInspectorProperty.PropertyType) : Enum.GetValues(enumInspectorProperty.PropertyType).GetValue(0); return(EditorGUILayout.EnumPopup(label, (Enum)currentEnumValue)); } InspectorVectorAttribute vectorInspectorproperty = inspectorProperty as InspectorVectorAttribute; if (vectorInspectorproperty != null) { if (vectorInspectorproperty.PropertyType == typeof(Vector2I) || vectorInspectorproperty.PropertyType == typeof(List <Vector2I>)) { Vector2I currentVector2IValue = (currentValue != null) ? (Vector2I)currentValue : Vector2I.Zero; return(Vector2IField(label, currentVector2IValue)); } if (vectorInspectorproperty.PropertyType == typeof(Vector2F) || vectorInspectorproperty.PropertyType == typeof(List <Vector2F>)) { Vector2F currentVector2FValue = (currentValue != null) ? (Vector2F)currentValue : Vector2F.Zero; return(Vector2FField(label, currentVector2FValue)); } } InspectorEntityAttribute entityInspector = inspectorProperty as InspectorEntityAttribute; if (entityInspector != null) { EntityConfiguration entityConfiguration = currentValue as EntityConfiguration; if (entityConfiguration == null) { entityConfiguration = new EntityConfiguration(); } entityConfiguration.BlueprintId = BlueprintIdSelection( label, entityConfiguration.BlueprintId, inspectorTypeTable, blueprintManager); if (!string.IsNullOrEmpty(entityConfiguration.BlueprintId)) { Blueprint blueprint = blueprintManager.GetBlueprint(entityConfiguration.BlueprintId); if (blueprint != null) { if (entityConfiguration.Configuration == null) { entityConfiguration.Configuration = new AttributeTable(); } ++EditorGUI.indentLevel; BlueprintComponentsField( blueprint, entityConfiguration.Configuration, inspectorTypeTable, blueprintManager); --EditorGUI.indentLevel; } } return(entityConfiguration); } EditorGUILayout.HelpBox( string.Format( "No inspector found for property {0} of type {1}.", inspectorProperty.Name, inspectorProperty.PropertyType), MessageType.Warning); return(currentValue); }