protected virtual void GetCompileScriptsClassBody(string namespaceName, LogicClass.CompileScriptsData data) { if (this.CustomScriptCodeCreated && !string.IsNullOrEmpty(this.CustomScriptCode)) { data.LineNumbers.Add(data.Strings.Count); string[] array = this.CustomScriptCode.Split(new char[] { '\n' }, StringSplitOptions.None); for (int i = 0; i < array.Length; i++) { array[i] = array[i].Replace("\r", ""); } string[] array2 = array; for (int j = 0; j < array2.Length; j++) { string str = array2[j]; data.Strings.Add("\t\t" + str); } data.Strings.Add(""); } foreach (LogicVariable current in this.Variables) { if (current.SupportSerialization) { data.Strings.Add("\t\t[Engine.EntitySystem.Entity.FieldSerialize]"); } string text = "\t\tpublic "; if (!(this is LogicEntityClass)) { text += "static "; } string text2 = text; text = string.Concat(new string[] { text2, CJ.TypeToCSharpString(current.VariableType), " ", current.VariableName, ";" }); data.Strings.Add(text); } data.Strings.Add("\t\t"); foreach (LogicMethod current2 in this.Methods) { data.LineNumbers.Add(data.Strings.Count + 1); List <string> compileScriptsData = current2.GetCompileScriptsData(namespaceName); foreach (string current3 in compileScriptsData) { data.Strings.Add("\t\t" + current3); } data.Strings.Add(""); } }
public List <string> GetCompileScriptsData(string namespaceName) { List <string> list = new List <string>(); string text = "public "; if (!(base.Parent is LogicEntityClass)) { text += "static "; } if (this.ReturnType != typeof(void)) { text += CJ.TypeToCSharpString(this.ReturnType); } else { text += "void"; } text = text + " " + this.methodName; if (this.parameters.Count != 0) { text += "( "; for (int i = 0; i < this.parameters.Count; i++) { if (i != 0) { text += ", "; } text += CJ.TypeToCSharpString(this.parameters[i].ParameterType); if (!string.IsNullOrEmpty(this.parameters[i].ParameterName)) { text = text + " " + this.parameters[i].ParameterName; } else { text = text + " __emptyParam" + i.ToString(); } } text += " )"; } else { text += "()"; } list.Add(text); list.Add("{"); string[] compileScriptsBody = this.GetCompileScriptsBody(namespaceName); string[] array = compileScriptsBody; for (int j = 0; j < array.Length; j++) { string str = array[j]; list.Add("\t" + str); } list.Add("}"); return(list); }
protected override string[] GetCompileScriptsBody(string namespaceName) { List <string> list = new List <string>(); list.Add(string.Format("Engine.EntitySystem.LogicClass __class = Engine.EntitySystem.LogicSystemManager.Instance.MapClassManager.GetByName( \"{0}\" );", base.ParentClass.ClassName)); list.Add(string.Format("Engine.EntitySystem.LogicSystem.LogicDesignerMethod __method = (Engine.EntitySystem.LogicSystem.LogicDesignerMethod)__class.GetMethodByName( \"{0}\" );", base.MethodName)); string text = ""; if (base.ReturnType != typeof(void)) { text += string.Format("return ({0})", CJ.TypeToCSharpString(base.ReturnType)); } text += "__method.Execute( "; if (base.ParentClass is LogicEntityClass) { text += "this"; } else { text += string.Format("EntitySystemWorld.Instance.GetLogicSystemScriptsAssemblyClassByClassName( \"{0}\" )", base.ParentClass.ClassName); } text += string.Format(", new object[ {0} ]", base.Parameters.Count.ToString()); text += "{ "; for (int i = 0; i < base.Parameters.Count; i++) { if (i != 0) { text += ", "; } LogicParameter logicParameter = base.Parameters[i]; if (!string.IsNullOrEmpty(logicParameter.ParameterName)) { text += logicParameter.ParameterName; } else { text = text + "__emptyParam" + i.ToString(); } } text += " } );"; list.Add(text); return(list.ToArray()); }
protected override void GetCompileScriptsClassBody(string namespaceName, LogicClass.CompileScriptsData data) { string text = this.abe; if (this.EntityClassInfo != null) { text = CJ.TypeToCSharpString(this.EntityClassInfo.entityClassType); } data.Strings.Add(string.Format("\t\t{0} __ownerEntity;", text)); data.Strings.Add("\t\t"); data.Strings.Add(string.Format("\t\tpublic {0}( {1} ownerEntity )", base.ClassName, text)); data.Strings.Add("\t\t\t: base( ownerEntity )"); data.Strings.Add("\t\t{"); data.Strings.Add("\t\t\tthis.__ownerEntity = ownerEntity;"); foreach (LogicMethod current in base.Methods) { if (current.IsEntityEventMethod) { string text2 = "\t\t\townerEntity." + current.MethodName + " += "; EventInfo entityEventInfo = current.EntityEventInfo; if (entityEventInfo == null) { Log.Warning("LogicEntityClass: Compilation error: Method \"{0}\" EntityEventInfo = null", current.ToString()); return; } MethodInfo method = entityEventInfo.EventHandlerType.GetMethod("Invoke"); string arg = CJ.TypeToCSharpString(method.GetParameters()[0].ParameterType); text2 += string.Format("delegate( {0} __entity", arg); foreach (LogicParameter current2 in current.Parameters) { string text3 = text2; text2 = string.Concat(new string[] { text3, ", ", CJ.TypeToCSharpString(current2.ParameterType), " ", current2.ParameterName }); } text2 += " ) { "; text2 += "if( Engine.EntitySystem.LogicSystemManager.Instance != null )"; text2 = text2 + current.MethodName + "( "; for (int i = 0; i < current.Parameters.Count; i++) { if (i != 0) { text2 += ", "; } text2 += current.Parameters[i].ParameterName; } text2 += " ); };"; data.Strings.Add(text2); } } data.Strings.Add("\t\t}"); data.Strings.Add("\t\t"); data.Strings.Add(string.Format("\t\tpublic {0} Owner", text)); data.Strings.Add("\t\t{"); data.Strings.Add("\t\t\tget { return __ownerEntity; }"); data.Strings.Add("\t\t}"); data.Strings.Add("\t\t"); base.GetCompileScriptsClassBody(namespaceName, data); }