public string ProcessLambda(SystemNode system, SystemLambdaAction lambda, string currentTemplate) { if (!lambda.HasQueryField) { return(s_queryFieldRegex.Replace(currentTemplate, "")); } return(s_queryFieldRegex.Replace(currentTemplate, $".WithStoreEntityQueryInField( ref {lambda.QueryFieldName} )")); }
public string ProcessLambda(SystemNode system, SystemLambdaAction lambda, string currentTemplate) { if (lambda.HasSharedFilter) { currentTemplate = s_sharedFilterDefinitionRegex.Replace(currentTemplate, lambda.SharedFilterDeclaration); return(s_sharedFilterRegex.Replace(currentTemplate, $".WithSharedComponentFilter( {lambda.SharedFilterName} )")); } else { currentTemplate = s_sharedFilterDefinitionRegex.Replace(currentTemplate, string.Empty); return(s_sharedFilterRegex.Replace(currentTemplate, string.Empty)); } }
public string ProcessLambda(SystemNode system, SystemLambdaAction lambda, string currentTemplate) { var transitions = system.TransitionTo(lambda).ToArray(); bool hasTransition = (transitions?.Count() ?? -1) > 0; string transitionsNames = ""; if (hasTransition) { transitionsNames = string.Join(", ", transitions.Select(t => t.Name)); } currentTemplate = CodeGeneratorUtils.ConditionalText(hasTransition, "TRANSITION", currentTemplate); return(s_transitionToRegex.Replace(currentTemplate, transitionsNames)); }
public string ProcessLambda(SystemNode system, SystemLambdaAction lambda, string currentTemplate) { //ForEach StringBuilder foreachBuilder = new StringBuilder(); var refComponents = lambda.Components .Where(c => c.Usage == ComponentLinkUsageType.All && c.AccessType == ComponentLinkAccessType.ReadWrite) .ToArray(); var inComponents = lambda.Components .Where(c => c.Usage == ComponentLinkUsageType.All && c.AccessType == ComponentLinkAccessType.Read) .ToArray(); foreach (var refComponent in refComponents) { var componentName = refComponent.ComponentName; foreachBuilder.Append("ref "); foreachBuilder.Append(componentName); foreachBuilder.Append(" "); foreachBuilder.Append(char.ToLowerInvariant(componentName[0])); foreachBuilder.Append(componentName.Substring(1)); foreachBuilder.Append(", "); } foreach (var inComponent in inComponents) { var componentName = inComponent.ComponentName; foreachBuilder.Append("in "); foreachBuilder.Append(componentName); foreachBuilder.Append(" "); foreachBuilder.Append(char.ToLowerInvariant(componentName[0])); foreachBuilder.Append(componentName.Substring(1)); foreachBuilder.Append(", "); } // Remove space and comma foreachBuilder.Length -= 2; return(s_foreachRegex.Replace(currentTemplate, foreachBuilder.ToString())); }
public string ProcessLambda(SystemNode system, SystemLambdaAction lambda, string currentTemplate) { //With none StringBuilder withNoneBuilder = new StringBuilder(); var withNoneComponents = lambda.Components .Where(c => c.Usage == ComponentLinkUsageType.None) .ToArray(); if (withNoneComponents.Length > 0) { withNoneBuilder.Append(".WithNone<"); for (var i = 0; i < withNoneComponents.Length; i++) { var component = withNoneComponents[i]; if (i != 0) { withNoneBuilder.Append(", "); } withNoneBuilder.Append(component.ComponentName); } withNoneBuilder.Append(">()"); } return(s_withNoneRegex.Replace(currentTemplate, withNoneBuilder.ToString())); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); var wasChanged = GUI.changed; GUI.changed = false; PropertyRect propertyRect = new PropertyRect(position); // Draw name var nameProp = property.FindPropertyRelative("_name"); EditorGUI.PropertyField(propertyRect.AllocateLine(), nameProp); // Draw array var componentsProp = property.FindPropertyRelative("_components"); s_cache.Clear(); GUIDrawers.DrawArray(ref propertyRect, componentsProp, s_cache); // Draw additional settings propertyRect.AllocateLine(); var parallelScheduling = property.FindPropertyRelative("_parallelSchedule"); EditorGUI.LabelField(propertyRect.AllocateWidthFlat(105), s_parallelContent); EditorGUI.PropertyField(propertyRect.AllocateWidthFlat(25), parallelScheduling, EmptyContent); var structuralChanges = property.FindPropertyRelative("_hasStructuralChanges"); EditorGUI.LabelField(propertyRect.AllocateWidthFlat(115), s_structuralChangesContent); EditorGUI.PropertyField(propertyRect.AllocateWidthFlat(25), structuralChanges, EmptyContent); propertyRect.AllocateLine(); var queryField = property.FindPropertyRelative("_queryField"); EditorGUI.LabelField(propertyRect.AllocateWidthFlat(75), s_queryFieldContent); EditorGUI.PropertyField(propertyRect.AllocateRestOfLine(), queryField, EmptyContent); propertyRect.AllocateLine(); var sharedFilter = property.FindPropertyRelative("_sharedFilter").GetPropertyValue <SharedComponentFilter>(); EditorGUI.LabelField(propertyRect.AllocateWidthFlat(75), s_sharedFilterContent); if (sharedFilter.IsValid) { EditorGUI.LabelField(propertyRect.AllocateWidthWithAscesorFlat(25), sharedFilter.FilterName, s_BoldLabelStyle); } else { EditorGUI.LabelField(propertyRect.AllocateWidthWithAscesorFlat(25), EmptyContent); } if (!sharedFilter.IsValid && GUI.Button(propertyRect.AllocateRestOfLine(), PlusContent)) { SharedComponentFilterWindow.ShowWindow((name, declaration) => { property.serializedObject.ApplyModifiedProperties(); sharedFilter.FilterName = name; sharedFilter.ComponentDeclaration = declaration; property.serializedObject.Update(); }); } else if (sharedFilter.IsValid && GUI.Button(propertyRect.AllocateRestOfLine(), MinusContent)) { sharedFilter.Invalid(); } EditorGUI.EndProperty(); if (GUI.changed) { // We can have some structural changes so we need to sync with Unity serialized side property.serializedObject.ApplyModifiedProperties(); SystemLambdaAction systemLambdaAction = property.GetPropertyValue() as SystemLambdaAction; systemLambdaAction?.PropertiesChanged(s_cache); property.serializedObject.Update(); } GUI.changed |= wasChanged; }
public string ProcessLambda(SystemNode system, SystemLambdaAction lambda, string currentTemplate) => CodeGeneratorUtils.ConditionalText(lambda.Parallel, "PARALLEL", currentTemplate);
public string ProcessLambda(SystemNode system, SystemLambdaAction lambda, string currentTemplate) { currentTemplate = CodeGeneratorUtils.ConditionalText(lambda.HasSharedComponent, "HAS_SHARED", currentTemplate); return(CodeGeneratorUtils.ConditionalText(lambda.HasStructuralChanges, "STRUCTURAL_CHANGES", currentTemplate)); }
public string ProcessLambda(SystemNode system, SystemLambdaAction lambda, string currentTemplate) { currentTemplate = s_lambdaNameRegex.Replace(currentTemplate, lambda.FullName(system)); return(s_lambdaLowerNameRegex.Replace(currentTemplate, lambda.Name.ToLower())); }