public override void DrawFields(BloxEditorWindow ed, BloxBlockEd bdi) { Comment_Block comment_Block = (Comment_Block)bdi.b; Comment_BlockDrawer.GC_Message.text = comment_Block.message; GUILayout.Label(Comment_BlockDrawer.GC_Message, BloxEdGUI.Styles.ActionLabel); }
public override bool CreateBlockCodeStatements(BloxBlockEd bdi, CodeStatementCollection statements) { CodeExpression valueExpr = BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[0], null) ?? new CodePrimitiveExpression(null); statements.Add(Variable_ScriptGenerator.CreateVarValueSetStatement(bdi, valueExpr)); return(true); }
public static CodeStatement CreateVarValueSetStatement(BloxBlockEd bdi, CodeExpression valueExpr) { Variable_Block variable_Block = (Variable_Block)bdi.b; Type type = (bdi.paramBlocks[0] == null) ? typeof(object) : bdi.paramBlocks[0].sgReturnType; if (variable_Block.varType == plyVariablesType.Event) { string cleanEventVariableName = BloxScriptGenerator.GetCleanEventVariableName(variable_Block.varName, false); if (BloxScriptGenerator.AddEventVariable(cleanEventVariableName, type, null, -1, true)) { return(new CodeAssignStatement(new CodeVariableReferenceExpression(cleanEventVariableName), valueExpr)); } return(new CodeVariableDeclarationStatement(type, cleanEventVariableName, valueExpr)); } if (variable_Block.varType == plyVariablesType.Blox) { return(new CodeExpressionStatement(new CodeMethodInvokeExpression(new CodeVariableReferenceExpression(BloxScriptGenerator.GetCleanBloxVariableName(variable_Block.varName)), "SetValue", valueExpr))); } if (variable_Block.varType == plyVariablesType.Object) { return(new CodeExpressionStatement(new CodeMethodInvokeExpression(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[1], null) ?? new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "gameObject"), "GetComponent", new CodeTypeReference(typeof(ObjectVariables)))), "SetVarValue", new CodePrimitiveExpression(variable_Block.varName), valueExpr))); } if (variable_Block.varType == plyVariablesType.Global) { return(new CodeExpressionStatement(new CodeMethodInvokeExpression(new CodePropertyReferenceExpression(new CodeTypeReferenceExpression(typeof(GlobalVariables)), "Instance"), "SetVarValue", new CodePrimitiveExpression(variable_Block.varName), valueExpr))); } return(null); }
public override void DrawHead(BloxEditorWindow ed, BloxBlockEd bdi) { Variable_Block variable_Block = (Variable_Block)bdi.b; Variable_BlockDrawer.GC_VarName.text = variable_Block.varName; if (bdi.owningBlock == null) { GUILayout.Label(Variable_BlockDrawer.GC_Set, BloxEdGUI.Styles.ActionLabel); GUILayout.Label(Variable_BlockDrawer.GC_Ico[(int)variable_Block.varType], BloxEdGUI.Styles.IconLabel); GUILayout.Label(Variable_BlockDrawer.GC_VarName, BloxEdGUI.Styles.ActionBoldLabel); GUILayout.Label(Variable_BlockDrawer.GC_Eq, BloxEdGUI.Styles.ActionLabel); } else { GUILayout.Label(Variable_BlockDrawer.GC_Ico[(int)variable_Block.varType], BloxEdGUI.Styles.IconLabel); GUILayout.Label(Variable_BlockDrawer.GC_VarName, BloxEdGUI.Styles.ActionLabel); if (bdi.b.paramBlocks[0] != null) { bdi.b.paramBlocks[0] = null; bdi.paramBlocks[0] = null; GUI.changed = true; } if (variable_Block.varType == plyVariablesType.Object) { ed.DrawBlockField(null, bdi, 1); } else if (bdi.b.paramBlocks[1] != null) { bdi.b.paramBlocks[1] = null; bdi.paramBlocks[1] = null; GUI.changed = true; } } }
public BloxBlockEd(BloxBlock b, BloxBlockEd prev, BloxBlockEd parentBlock, BloxBlockEd owningBlock, int fieldIdx) { UnityEngine.Debug.Log("BloxBlockEd init" + b.returnType + b + owningBlock); this.b = b; this.def = BloxEd.Instance.FindBlockDef(b); this.prev = prev; this.parentBlock = parentBlock; this.owningBlock = owningBlock; this.fieldIdx = fieldIdx; if (b.contextBlock != null) { this.contextBlock = new BloxBlockEd(b.contextBlock, null, null, this, -1); } if (((b.paramBlocks != null) ? b.paramBlocks.Length : 0) != 0) { this.paramBlocks = new BloxBlockEd[b.paramBlocks.Length]; for (int i = 0; i < b.paramBlocks.Length; i++) { if (b.paramBlocks[i] != null) { this.paramBlocks[i] = new BloxBlockEd(b.paramBlocks[i], null, null, this, i); } } } if (b.firstChild != null) { this.firstChild = new BloxBlockEd(b.firstChild, null, this, null, -1); } this.UpdateNextBlock(parentBlock); }
public override void DrawProperties(BloxEditorWindow ed, BloxBlockEd bdi) { Type_Block obj = (Type_Block)bdi.b; EditorGUILayout.PrefixLabel(Type_BlockDrawer.GC_Message); obj.typeName = EditorGUILayout.TextField(obj.typeName); }
public override bool CreateBlockCodeStatements(BloxBlockEd bdi, CodeStatementCollection statements) { if (bdi.paramBlocks[0] != null && bdi.paramBlocks[0].b.GetType() == typeof(Variable_Block)) { CodeExpression left = BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[0], typeof(float)); CodePrimitiveExpression codePrimitiveExpression = new CodePrimitiveExpression(0f); CodeStatement codeStatement = Variable_ScriptGenerator.CreateVarValueSetStatement(bdi.paramBlocks[0], codePrimitiveExpression); if (codeStatement == null) { throw new Exception("error: setVar0F"); } CodeStatement codeStatement2 = Variable_ScriptGenerator.CreateVarValueSetStatement(bdi.paramBlocks[0], new CodeBinaryOperatorExpression(left, CodeBinaryOperatorType.Subtract, new CodePropertyReferenceExpression(new CodeTypeReferenceExpression(typeof(Time)), "deltaTime"))); if (codeStatement2 == null) { throw new Exception("error: setVarDeltaTime"); } CodeStatement[] array = BloxScriptGenerator.CreateChildBlockCodeStatements(bdi); if (array == null) { throw new Exception("error: childStatements"); } ArrayUtility.Insert(ref array, 0, codeStatement); CodeStatement codeStatement3 = new CodeConditionStatement(new CodeBinaryOperatorExpression(left, CodeBinaryOperatorType.LessThanOrEqual, codePrimitiveExpression), array); CodeStatement value = new CodeConditionStatement(new CodeBinaryOperatorExpression(left, CodeBinaryOperatorType.GreaterThan, codePrimitiveExpression), codeStatement2, codeStatement3); statements.Add(value); return(true); } Debug.LogError("Invalid variable type"); return(false); }
public override void DrawProperties(BloxEditorWindow ed, BloxBlockEd bdi) { //Debug.Log("DrawProperties"); if (bdi.b.paramBlocks == null) { bdi.b.paramBlocks = new BloxBlock[0]; } Debug_Block debug_Block = (Debug_Block)bdi.b; EditorGUILayout.PrefixLabel(Debug_BlockDrawer.GC_Message); debug_Block.message = EditorGUILayout.TextField(debug_Block.message); debug_Block.logType = (Debug_Block.DebugBlockLogType)EditorGUILayout.EnumPopup((Enum)(object)debug_Block.logType); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(Debug_BlockDrawer.GC_Add, plyEdGUI.Styles.MiniButtonLeft, GUILayout.Width(30f))) { ArrayUtility.Add <BloxBlockEd>(ref bdi.paramBlocks, (BloxBlockEd)null); ArrayUtility.Add <BloxBlock>(ref bdi.b.paramBlocks, (BloxBlock)null); GUI.changed = true; } GUI.enabled = (bdi.paramBlocks.Length != 0); if (GUILayout.Button(Debug_BlockDrawer.GC_Remove, plyEdGUI.Styles.MiniButtonRight, GUILayout.Width(30f))) { ArrayUtility.RemoveAt <BloxBlockEd>(ref bdi.paramBlocks, bdi.paramBlocks.Length - 1); ArrayUtility.RemoveAt <BloxBlock>(ref bdi.b.paramBlocks, bdi.b.paramBlocks.Length - 1); GUI.changed = true; } GUI.enabled = true; GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); GUILayout.Label(Debug_BlockDrawer.GC_Info, plyEdGUI.Styles.WordWrappedLabel); }
private CodeStatement[] CreateFalseStatements(BloxBlockEd bdi) { if (bdi.next != null && bdi.next.b.GetType() == typeof(ElseIF_Block)) { bdi = bdi.next; CodeStatement[] array = BloxScriptGenerator.CreateChildBlockCodeStatements(bdi); if (array == null) { return(null); } if (bdi.paramBlocks[0] != null) { CodeExpression codeExpression = BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[0], typeof(bool)); if (codeExpression == null) { return(null); } CodeStatement[] array2 = this.CreateFalseStatements(bdi); if (array2 == null) { return(null); } return(new CodeStatement[1] { new CodeConditionStatement(codeExpression, array, array2) }); } return(array); } return(new CodeStatement[0]); }
private bool UpdateBlockReturnType(BloxBlockEd bdi, ref plyVar theVar) { Variable_Block variable_Block = (Variable_Block)bdi.b; if (variable_Block.varType == plyVariablesType.Blox) { plyVar plyVar = theVar = this.FindVariable(BloxScriptGenerator.processingBlox.variables, variable_Block.varName); if (plyVar == null) { return(false); } if (plyVar.variableType != null) { bdi.sgReturnType = plyVar.variableType; } } else if (variable_Block.varType == plyVariablesType.Global) { plyVar plyVar2 = theVar = this.FindVariable(BloxEd.GlobalVarsObj.variables, variable_Block.varName); if (plyVar2 == null) { return(false); } if (plyVar2.variableType != null) { bdi.sgReturnType = plyVar2.variableType; } } return(true); }
public bool CheckEventBlockDefs() { this.hasUndefinedblocks = false; if (this.firstBlock == null) { return(true); } if (BloxEd.Instance.BlockDefsLoading) { BloxEd.Instance.DoUpdate(); return(false); } if (BloxBlocksList.HasInstance && BloxBlocksList.Instance.IsBuildingList) { BloxBlocksList.Instance.DoUpdate(); return(false); } BloxBlockEd next = this.firstBlock; while (next != null && !this.CheckBlockDef(next)) { next = next.next; } return(true); }
public void Clear() { this.ev = null; this.def = null; this.firstBlock = null; this.hasUndefinedblocks = false; this.unlinkedBlocks.Clear(); }
private void UpdateNextBlock(BloxBlockEd parentBlock) { if (this.b != null && this.b.next != null) { this.next = new BloxBlockEd(this.b.next, this, parentBlock, null, -1); this.next.UpdateNextBlock(parentBlock); } }
public override void DrawProperties(BloxEditorWindow ed, BloxBlockEd bdi) { Variable_Block variable_Block = (Variable_Block)bdi.b; EditorGUIUtility.labelWidth = 75f; variable_Block.varType = (plyVariablesType)EditorGUILayout.Popup(Variable_BlockDrawer.GC_Type, (int)variable_Block.varType, Variable_BlockDrawer.GC_VarTypeNames); variable_Block.varName = EditorGUILayout.TextField(Variable_BlockDrawer.GC_Name, variable_Block.varName); }
/// <summary> /// 加载 事件内 积木 /// </summary> /// <returns></returns> private IEnumerator LoadEvent() { int count = 0; if (this.ev.firstBlock == null) { Debug.Log("LoadEvent .ev.firstBlock == null", "BloxEventEd", UnityEngine.Color.green); this.firstBlock = null; } else { yield return((object)null); this.firstBlock = new BloxBlockEd(this.ev.firstBlock, null, null, null, -1, false); BloxBlockEd bdi2 = this.firstBlock; Debug.Log("bdi2" + bdi2.b.ident, "BloxEventEd", UnityEngine.Color.green); while (bdi2.b.next != null) { count++; if (count >= 1) { count = 0; yield return((object)null); } Debug.Log("Draw linked bdi2.b.next" + bdi2.b.next.ident, "BloxEventEd", UnityEngine.Color.green); bdi2.next = new BloxBlockEd(bdi2.b.next, bdi2, null, null, -1, false); bdi2 = bdi2.next; } } if (this.ev.unlinkedBlocks.Count > 0) { Debug.Log(".ev.unlinkedBlocks.Count " + this.ev.unlinkedBlocks.Count, "BloxEventEd", UnityEngine.Color.green); yield return((object)null); for (int i = 0; i < this.ev.unlinkedBlocks.Count; i++) { Debug.Log("draw unlinked blocks " + this.ev.unlinkedBlocks.Count, "BloxEventEd", UnityEngine.Color.green); BloxBlockEd bdi; BloxBlockEd f_bdi = bdi = new BloxBlockEd(this.ev.unlinkedBlocks[i], null, null, null, -1, false); while (bdi.b.next != null) { count++; if (count >= 1) { count = 0; yield return((object)null); } bdi.next = new BloxBlockEd(bdi.b.next, bdi, null, null, -1, false); bdi = bdi.next; } this.unlinkedBlocks.Add(f_bdi); } } yield return((object)null); //Debug.Log(" this._loading = false", "BloxEventEd", UnityEngine.Color.red); this._loading = false; }
public override CodeExpression CreateBlockCodeExpression(BloxBlockEd bdi) { CodeExpression codeExpression = (bdi.paramBlocks[0] == null) ? new CodePrimitiveExpression(null) : BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[0], null); CodeExpression codeExpression2 = (bdi.paramBlocks[1] == null) ? new CodePrimitiveExpression(null) : BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[1], null); if (codeExpression == null) { throw new Exception("error: left expression"); } if (codeExpression2 == null) { throw new Exception("error: right expression"); } Type type = bdi.b.GetType(); CodeBinaryOperatorType op = CodeBinaryOperatorType.Add; if (type == typeof(SUB_Block)) { op = CodeBinaryOperatorType.Subtract; } else if (type == typeof(MUL_Block)) { op = CodeBinaryOperatorType.Multiply; } else if (type == typeof(DIV_Block)) { op = CodeBinaryOperatorType.Divide; } else if (type == typeof(MOD_Block)) { op = CodeBinaryOperatorType.Modulus; } else if (type == typeof(B_AND_Block)) { op = CodeBinaryOperatorType.BitwiseAnd; } else if (type == typeof(B_OR_Block)) { op = CodeBinaryOperatorType.BitwiseOr; } else { if (type == typeof(B_XOR_Block)) { return(new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(BloxMathsUtil)), "BitwiseXor", codeExpression, codeExpression2)); } if (type == typeof(B_RS_Block)) { return(new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(BloxMathsUtil)), "RightShift", codeExpression, codeExpression2)); } if (type == typeof(B_LS_Block)) { return(new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(BloxMathsUtil)), "LeftShift", codeExpression, codeExpression2)); } } bdi.sgReturnType = ((bdi.paramBlocks[0] != null) ? bdi.paramBlocks[0].sgReturnType : ((bdi.paramBlocks[1] != null) ? bdi.paramBlocks[1].sgReturnType : typeof(object))); return(new CodeBinaryOperatorExpression(codeExpression, op, codeExpression2)); }
public override CodeExpression CreateBlockCodeExpression(BloxBlockEd bdi) { Type type = bdi.b.GetType(); if (type == typeof(NOT_Block)) { CodeExpression codeExpression = BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[0], typeof(bool)); if (codeExpression == null) { throw new Exception("error: value"); } return(new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(BloxUtil)), "NOT", codeExpression)); } CodeBinaryOperatorType codeBinaryOperatorType = CodeBinaryOperatorType.ValueEquality; if (type == typeof(GT_Block)) { codeBinaryOperatorType = CodeBinaryOperatorType.GreaterThan; } else if (type == typeof(GTE_Block)) { codeBinaryOperatorType = CodeBinaryOperatorType.GreaterThanOrEqual; } else if (type == typeof(LT_Block)) { codeBinaryOperatorType = CodeBinaryOperatorType.LessThan; } else if (type == typeof(LTE_Block)) { codeBinaryOperatorType = CodeBinaryOperatorType.LessThanOrEqual; } else if (type == typeof(AND_Block)) { codeBinaryOperatorType = CodeBinaryOperatorType.BooleanAnd; } else if (type == typeof(OR_Block)) { codeBinaryOperatorType = CodeBinaryOperatorType.BooleanOr; } CodeExpression codeExpression2 = (bdi.paramBlocks[0] == null) ? new CodePrimitiveExpression(null) : BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[0], (codeBinaryOperatorType == CodeBinaryOperatorType.BooleanAnd || codeBinaryOperatorType == CodeBinaryOperatorType.BooleanOr) ? typeof(bool) : null); CodeExpression codeExpression3 = (bdi.paramBlocks[1] == null) ? new CodePrimitiveExpression(null) : BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[1], (codeBinaryOperatorType == CodeBinaryOperatorType.BooleanAnd || codeBinaryOperatorType == CodeBinaryOperatorType.BooleanOr) ? typeof(bool) : null); if (codeExpression2 == null) { throw new Exception("error: left expression"); } if (codeExpression3 == null) { throw new Exception("error: right expression"); } if (type == typeof(NEQ_Block)) { CodeExpression codeExpression4 = new CodeBinaryOperatorExpression(codeExpression2, CodeBinaryOperatorType.ValueEquality, codeExpression3); return(new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(BloxUtil)), "NOT", codeExpression4)); } return(new CodeBinaryOperatorExpression(codeExpression2, codeBinaryOperatorType, codeExpression3)); }
private object Edit_ListOrArray(Type type, object value, BloxBlockEd block) { if (this.rol == null) { this.rol = new ReorderableList(new List <object>(), typeof(object), true, false, true, true); this.rol.elementHeight = 19f; this.rol.onAddCallback = this.Edit_ListOrArray_OnAdd; this.rol.onRemoveCallback = this.Edit_ListOrArray_OnRemove; this.rol.drawElementCallback = this.Edit_ListOrArray_DrawElem; this.rol.onReorderCallback = this.Edit_ListOrArray_Reorder; } if (type.IsArray) { if (this.currRolObj != value || this.currRolObj == null) { this.currRolType = type.GetElementType(); Array array = null; if (value == null) { GUI.changed = true; array = (Array)(value = Array.CreateInstance(this.currRolType, 0)); } else { array = (Array)value; } this.currRolObj = value; this.currRolList = new List <object>(); for (int i = 0; i < array.Length; i++) { this.currRolList.Add(array.GetValue(i)); } this.rol.list = this.currRolList; } this.rol.DoLayoutList(); return(this.currRolList.ToArray()); } if (this.currRolObj != value || this.currRolObj == null) { this.currRolType = type.GetGenericArguments()[0]; if (value == null) { GUI.changed = true; value = Activator.CreateInstance(type); this.currRolList = ((IList)value).Cast <object>().ToList(); } else { this.currRolList = ((IList)value).Cast <object>().ToList(); } this.currRolObj = this.currRolList; this.rol.list = this.currRolList; } this.rol.DoLayoutList(); return(this.currRolList); }
public override bool CreateBlockCodeStatements(BloxBlockEd bdi, CodeStatementCollection statements) { if (bdi.parentBlock != null && bdi.parentBlock.IsOrInLoop()) { statements.Add(new CodeExpressionStatement(new CodeSnippetExpression("break"))); return(true); } statements.Add(new CodeMethodReturnStatement()); return(true); }
public override CodeExpression CreateBlockCodeExpression(BloxBlockEd bdi) { CodeExpression codeExpression = BloxScriptGenerator.CreateBlockCodeExpression(bdi.contextBlock, typeof(IList)); if (codeExpression == null) { return(null); } return(new CodePropertyReferenceExpression(codeExpression, "Count")); }
public override bool CreateBlockCodeStatements(BloxBlockEd bdi, CodeStatementCollection statements) { Comment_Block comment_Block = (Comment_Block)bdi.b; if (!string.IsNullOrEmpty(comment_Block.message)) { statements.Add(new CodeCommentStatement(comment_Block.message)); } return(true); }
public override bool CreateBlockCodeStatements(BloxBlockEd bdi, CodeStatementCollection statements) { if (bdi.parentBlock != null && bdi.parentBlock.IsOrInLoop()) { statements.Add(new CodeExpressionStatement(new CodeSnippetExpression("continue"))); return(true); } statements.Add(BloxScriptGenerator.CreateGotoTopStatement()); return(true); }
public override CodeExpression CreateBlockCodeExpression(BloxBlockEd bdi) { CodeExpression codeExpression = BloxScriptGenerator.CreateBlockCodeExpression(bdi.contextBlock, typeof(Array)); if (codeExpression == null) { return(null); } return(new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(BloxUtil)), "ArrayClone", codeExpression)); }
public override void DrawProperties(BloxEditorWindow ed, BloxBlockEd bdi) { if (bdi.b.paramBlocks == null) { bdi.b.paramBlocks = new BloxBlock[0]; } Comment_Block obj = (Comment_Block)bdi.b; EditorGUILayout.PrefixLabel(Comment_BlockDrawer.GC_Head); obj.message = EditorGUILayout.TextArea(obj.message, plyEdGUI.Styles.TextArea); }
public override CodeExpression CreateBlockCodeExpression(BloxBlockEd bdi) { Type type = (bdi.fieldIdx == -1) ? bdi.owningBlock.def.contextType : bdi.owningBlock.ParameterTypes()[bdi.fieldIdx]; if (type != null && type != typeof(GameObject)) { bdi.sgReturnType = type; return(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), "GetComponent", new CodeTypeReference(type)))); } return(new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "gameObject")); }
public override bool CreateBlockCodeStatements(BloxBlockEd bdi, CodeStatementCollection statements) { CodeExpression codeExpression = BloxScriptGenerator.CreateBlockCodeExpression(bdi.contextBlock, typeof(Array)); if (codeExpression == null) { return(false); } statements.Add(new CodeExpressionStatement(new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(BloxUtil)), "ArraySort", codeExpression))); return(true); }
public override bool CreateBlockCodeStatements(BloxBlockEd bdi, CodeStatementCollection statements) { string text = BloxScriptGenerator.CodeSnippetFromCodeExpression(BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[0], typeof(float)) ?? new CodePrimitiveExpression(0f)); if (text == null) { return(false); } statements.Add(new CodeExpressionStatement(new CodeSnippetExpression(string.Format("yield return new UnityEngine.WaitForSeconds({0})", text)))); return(true); }
public override bool CreateBlockCodeStatements(BloxBlockEd bdi, CodeStatementCollection statements) { CodeExpression codeExpression = (bdi.paramBlocks[1] == null) ? new CodePrimitiveExpression(0) : BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[1], typeof(int)); if (codeExpression == null) { throw new Exception("Error: startVal"); } CodeExpression codeExpression2 = (bdi.paramBlocks[2] == null) ? new CodePrimitiveExpression(0) : BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[2], typeof(int)); if (codeExpression2 == null) { throw new Exception("Error: endVal"); } CodeStatement codeStatement = null; CodeExpression codeExpression3 = null; CodeStatement codeStatement2 = null; if (bdi.paramBlocks[0] == null) { string cleanEventVariableName = BloxScriptGenerator.GetCleanEventVariableName("", true); statements.Add(new CodeVariableDeclarationStatement(typeof(int), cleanEventVariableName, new CodePrimitiveExpression(0))); CodeVariableReferenceExpression left = new CodeVariableReferenceExpression(cleanEventVariableName); codeStatement = new CodeAssignStatement(left, codeExpression); codeExpression3 = new CodeBinaryOperatorExpression(left, CodeBinaryOperatorType.LessThan, codeExpression2); codeStatement2 = new CodeAssignStatement(left, new CodeBinaryOperatorExpression(left, CodeBinaryOperatorType.Add, new CodePrimitiveExpression(1))); } else { codeStatement = Variable_ScriptGenerator.CreateVarValueSetStatement(bdi.paramBlocks[0], codeExpression); if (codeStatement == null) { throw new Exception("Error: initSt"); } CodeExpression codeExpression4 = BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[0], typeof(int)); if (codeExpression4 == null) { throw new Exception("error: getVarVal"); } codeExpression3 = new CodeBinaryOperatorExpression(codeExpression4, CodeBinaryOperatorType.LessThan, codeExpression2); codeStatement2 = Variable_ScriptGenerator.CreateVarValueSetStatement(bdi.paramBlocks[0], new CodeBinaryOperatorExpression(codeExpression4, CodeBinaryOperatorType.Add, new CodePrimitiveExpression(1))); if (codeExpression4 == null) { throw new Exception("error: incSt"); } } CodeStatement[] array = BloxScriptGenerator.CreateChildBlockCodeStatements(bdi); if (array == null) { throw new Exception("Error: childStatements"); } statements.Add(new CodeIterationStatement(codeStatement, codeExpression3, codeStatement2, array)); return(true); }
public override CodeExpression CreateBlockCodeExpression(BloxBlockEd bdi) { CodeExpression codeExpression = BloxScriptGenerator.CreateBlockCodeExpression(bdi.contextBlock, typeof(Array)); if (codeExpression == null) { return(null); } CodeExpression codeExpression2 = BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[0], typeof(int)) ?? new CodePrimitiveExpression(0); return(new CodeMethodInvokeExpression(codeExpression, "GetValue", codeExpression2)); }
public override CodeExpression CreateBlockCodeExpression(BloxBlockEd bdi) { CodeExpression codeExpression = BloxScriptGenerator.CreateBlockCodeExpression(bdi.contextBlock, typeof(Array)); if (codeExpression == null) { return(null); } CodeExpression codeExpression2 = BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[0], null) ?? new CodePrimitiveExpression(null); return(new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(BloxUtil)), "ArrayContains", codeExpression, codeExpression2)); }