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]); }
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 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 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)); }
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 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) { 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 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 = 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 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)); }
public override bool CreateBlockCodeStatements(BloxBlockEd bdi, CodeStatementCollection statements) { Debug_Block debug_Block = (Debug_Block)bdi.b; string text = "UnityEngine.Debug."; if (((bdi.paramBlocks != null) ? bdi.paramBlocks.Length : 0) != 0) { switch (debug_Block.logType) { case Debug_Block.DebugBlockLogType.Log: text += "LogFormat"; break; case Debug_Block.DebugBlockLogType.Warning: text += "WarningFormat"; break; case Debug_Block.DebugBlockLogType.Error: text += "ErrorFormat"; break; } CodeExpression[] array = new CodeExpression[bdi.paramBlocks.Length + 1]; string text2 = debug_Block.message; for (int i = 0; i < bdi.paramBlocks.Length; i++) { text2 = text2 + ((i == 0) ? " " : ", ") + "{" + i + "}"; array[i + 1] = (BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[i], null) ?? new CodePrimitiveExpression("null")); } array[0] = new CodePrimitiveExpression(text2); statements.Add(new CodeExpressionStatement(new CodeMethodInvokeExpression(null, text, array))); return(true); } switch (debug_Block.logType) { case Debug_Block.DebugBlockLogType.Log: text += "Log"; break; case Debug_Block.DebugBlockLogType.Warning: text += "Warning"; break; case Debug_Block.DebugBlockLogType.Error: text += "Error"; break; } CodeExpression[] parameters = new CodeExpression[1] { new CodePrimitiveExpression(debug_Block.message) }; statements.Add(new CodeExpressionStatement(new CodeMethodInvokeExpression(null, text, parameters))); return(true); }
public override CodeExpression CreateBlockCodeExpression(BloxBlockEd bdi) { CodeExpression codeExpression = BloxScriptGenerator.CreateBlockCodeExpression(bdi.contextBlock, typeof(IList)); if (codeExpression == null) { return(null); } CodeExpression codeExpression2 = BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[0], typeof(int)) ?? new CodePrimitiveExpression(0); return(new CodeIndexerExpression(codeExpression, 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], typeof(int)) ?? new CodePrimitiveExpression(0); return(new CodeMethodInvokeExpression(codeExpression, "GetValue", codeExpression2)); }
public override bool CreateBlockCodeStatements(BloxBlockEd bdi, CodeStatementCollection statements) { CodeExpression codeExpression = BloxScriptGenerator.CreateBlockCodeExpression(bdi.contextBlock, typeof(IList)); if (codeExpression == null) { return(false); } CodeExpression codeExpression2 = BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[0], null) ?? new CodePrimitiveExpression(null); CodeExpression expression = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(BloxUtil)), "ListAdd", codeExpression, codeExpression2); statements.Add(new CodeExpressionStatement(expression)); return(true); }
public override bool CreateBlockCodeStatements(BloxBlockEd bdi, CodeStatementCollection statements) { CodeExpression codeExpression = BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[0], typeof(bool)); if (codeExpression == null) { throw new Exception("error: condition"); } CodeStatement[] array = BloxScriptGenerator.CreateChildBlockCodeStatements(bdi); if (array == null) { throw new Exception("Error: childStatements"); } statements.Add(new CodeIterationStatement(new CodeSnippetStatement(""), codeExpression, new CodeSnippetStatement(""), array)); return(true); }
public override bool CreateBlockCodeStatements(BloxBlockEd bdi, CodeStatementCollection statements) { CodeExpression codeExpression = BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[0], typeof(bool)); if (codeExpression == null) { throw new Exception("error: condition"); } CodeStatement[] array = BloxScriptGenerator.CreateChildBlockCodeStatements(bdi); if (array == null) { throw new Exception("error: trueStatements"); } CodeStatement[] array2 = this.CreateFalseStatements(bdi); if (array2 == null) { throw new Exception("error: falseStatements"); } statements.Add(new CodeConditionStatement(codeExpression, array, array2)); return(true); }
public override bool CreateBlockCodeStatements(BloxBlockEd bdi, CodeStatementCollection statements) { if (!Array_Add_ScriptGenerator.IsValidContext(bdi.contextBlock)) { return(false); } CodeExpression codeExpression = BloxScriptGenerator.CreateBlockCodeExpression(bdi.contextBlock, typeof(Array)); if (codeExpression == null) { return(false); } CodeExpression valueExpr = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(BloxUtil)), "ArrayClear", codeExpression); if (bdi.contextBlock.b.GetType() == typeof(Variable_Block)) { statements.Add(Variable_ScriptGenerator.CreateVarValueSetStatement(bdi.contextBlock, valueExpr)); return(true); } statements.Add(BloxScriptGenerator.CreateMemberSetExpression(bdi.contextBlock, valueExpr, typeof(Array))); return(true); }
public override bool CreateBlockCodeStatements(BloxBlockEd bdi, CodeStatementCollection statements) { CodeExpression codeExpression = null; if (bdi.paramBlocks[1] == null) { codeExpression = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "bloxContainer"); } else { CodeExpression codeExpression2 = BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[1], null); if (codeExpression2 == null) { return(false); } codeExpression = new CodeFieldReferenceExpression(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeTypeReferenceExpression(typeof(BloxUtil)), "GetComponent", new CodeTypeReference(typeof(BloxContainer))), codeExpression2), "bloxContainer"); } CodeExpression[] array = new CodeExpression[(bdi.paramBlocks.Length > 3) ? 3 : 2]; array[0] = BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[0], typeof(string)); if (array[0] == null) { Debug.LogError("Event name missing."); return(false); } array[1] = (BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[2], typeof(float)) ?? new CodePrimitiveExpression(0f)); if (bdi.paramBlocks.Length > 3) { CodeExpression[] array2 = new CodeExpression[bdi.paramBlocks.Length - 3]; for (int i = 3; i < bdi.paramBlocks.Length; i++) { CodeExpression codeExpression3 = BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[i], null) ?? new CodePrimitiveExpression(null); array2[i - 3] = new CodeObjectCreateExpression(typeof(BloxEventArg), new CodePrimitiveExpression("param" + (i - 3)), codeExpression3); } array[2] = new CodeArrayCreateExpression(typeof(BloxEventArg), array2); } statements.Add(new CodeExpressionStatement(new CodeMethodInvokeExpression(codeExpression, "TriggerEvent", array))); return(true); }
public static void Menu_ScriptGen_CompileAll() { BloxScriptGenerator.GenerateAllScripts(); }
public static void Menu_ScriptGen_RemoveAll() { BloxScriptGenerator.RemoveAllScripts(); }
public override CodeExpression CreateBlockCodeExpression(BloxBlockEd bdi) { Variable_Block variable_Block = (Variable_Block)bdi.b; plyVar plyVar = null; if (!this.UpdateBlockReturnType(bdi, ref plyVar)) { Debug.LogErrorFormat("The [{0}] variable [{1}] is not defined.", variable_Block.varType, variable_Block.varName); return(null); } if (variable_Block.varType == plyVariablesType.Event) { if (BloxScriptGenerator.processingEvent.def.pars.Length != 0) { BloxEventDef.Param[] pars = BloxScriptGenerator.processingEvent.def.pars; for (int i = 0; i < pars.Length; i++) { BloxEventDef.Param param = pars[i]; if (param.name == variable_Block.varName) { bdi.sgReturnType = param.type; return(new CodeVariableReferenceExpression(variable_Block.varName)); } } } string cleanEventVariableName = BloxScriptGenerator.GetCleanEventVariableName(variable_Block.varName, false); if (BloxScriptGenerator.processingEvent.ev.ident == "Custom" && cleanEventVariableName.StartsWith("param") && cleanEventVariableName.Length > 5) { int argIdx = -1; if (int.TryParse(cleanEventVariableName.Substring(5), out argIdx)) { Type type = (bdi.fieldIdx == -1) ? bdi.owningBlock.def.contextType : bdi.owningBlock.ParameterTypes()[bdi.fieldIdx]; if (type == null) { type = typeof(object); } BloxScriptGenerator.AddEventVariable(cleanEventVariableName, type, null, argIdx, false); } } else { Type type2 = (bdi.fieldIdx == -1) ? bdi.owningBlock.def.contextType : bdi.owningBlock.ParameterTypes()[bdi.fieldIdx]; if (type2 == null) { type2 = typeof(object); } BloxScriptGenerator.AddEventVariable(cleanEventVariableName, type2, null, -1, false); } Type eventVariableType = BloxScriptGenerator.GetEventVariableType(cleanEventVariableName); if (eventVariableType != null) { bdi.sgReturnType = eventVariableType; } return(new CodeVariableReferenceExpression(cleanEventVariableName)); } if (variable_Block.varType == plyVariablesType.Blox) { CodeExpression targetObject = new CodeVariableReferenceExpression(BloxScriptGenerator.GetCleanBloxVariableName(variable_Block.varName)); Type type3 = (bdi.fieldIdx == -1) ? bdi.owningBlock.def.contextType : bdi.owningBlock.ParameterTypes()[bdi.fieldIdx]; if (type3 != null) { plyVarValueHandler valueHandler = plyVar.ValueHandler; Type type4 = (valueHandler != null) ? valueHandler.GetType() : null; if (type4 == typeof(plyVar_GameObject) || type4 == typeof(plyVar_Component)) { if (typeof(GameObject).IsAssignableFrom(type3)) { bdi.sgReturnType = type3; return(new CodeMethodInvokeExpression(targetObject, "GetGameObject")); } if (typeof(Component).IsAssignableFrom(type3)) { bdi.sgReturnType = type3; return(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(targetObject, "GetComponent", new CodeTypeReference(type3)))); } } else if (plyVar.ValueHandler.GetType() == typeof(plyVar_UnityObject)) { bdi.sgReturnType = type3; return(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(targetObject, "GetObject", new CodeTypeReference(type3)))); } } return(new CodeMethodInvokeExpression(targetObject, "GetValue")); } if (variable_Block.varType == plyVariablesType.Object) { CodeExpression targetObject2 = BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[1], null) ?? new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "gameObject"); targetObject2 = new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(targetObject2, "GetComponent", new CodeTypeReference(typeof(ObjectVariables)))); Type type5 = (bdi.fieldIdx == -1) ? bdi.owningBlock.def.contextType : bdi.owningBlock.ParameterTypes()[bdi.fieldIdx]; if (type5 != null) { if (typeof(GameObject).IsAssignableFrom(type5)) { bdi.sgReturnType = type5; return(new CodeMethodInvokeExpression(targetObject2, "GetGameObjectVarValue", new CodePrimitiveExpression(variable_Block.varName))); } if (typeof(Component).IsAssignableFrom(type5)) { bdi.sgReturnType = type5; return(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(targetObject2, "GetComponentVarValue", new CodeTypeReference(type5)), new CodePrimitiveExpression(variable_Block.varName))); } if (typeof(UnityEngine.Object).IsAssignableFrom(type5)) { bdi.sgReturnType = type5; return(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(targetObject2, "GetUnityObjectVarValue", new CodeTypeReference(type5)), new CodePrimitiveExpression(variable_Block.varName))); } } return(new CodeMethodInvokeExpression(targetObject2, "GetVarValue", new CodePrimitiveExpression(variable_Block.varName))); } if (variable_Block.varType == plyVariablesType.Global) { CodeExpression targetObject3 = new CodeVariableReferenceExpression(BloxScriptGenerator.GetCleanGlobalVariableName(variable_Block.varName)); Type type6 = (bdi.fieldIdx == -1) ? bdi.owningBlock.def.contextType : bdi.owningBlock.ParameterTypes()[bdi.fieldIdx]; if (type6 != null) { plyVarValueHandler valueHandler2 = plyVar.ValueHandler; Type type7 = (valueHandler2 != null) ? valueHandler2.GetType() : null; if (type7 == typeof(plyVar_GameObject) || type7 == typeof(plyVar_Component)) { if (typeof(GameObject).IsAssignableFrom(type6)) { bdi.sgReturnType = type6; return(new CodeMethodInvokeExpression(targetObject3, "GetGameObject")); } if (typeof(Component).IsAssignableFrom(type6)) { bdi.sgReturnType = type6; return(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(targetObject3, "GetComponent", new CodeTypeReference(type6)))); } } else if (plyVar.ValueHandler.GetType() == typeof(plyVar_UnityObject)) { bdi.sgReturnType = type6; return(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(targetObject3, "GetObject", new CodeTypeReference(type6)))); } } return(new CodeMethodInvokeExpression(targetObject3, "GetValue")); } return(null); }
public override CodeExpression CreateBlockCodeExpression(BloxBlockEd bdi) { CodeExpression obj = (bdi.paramBlocks[0] == null) ? new CodePrimitiveExpression(null) : BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[0], null); CodeExpression codeExpression = (bdi.paramBlocks[1] == null) ? new CodePrimitiveExpression(null) : BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[1], null); if (obj == null) { throw new Exception("error: left expression"); } if (codeExpression == 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; } return(new CodeBinaryOperatorExpression(obj, op, codeExpression)); }
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)); }