public LogicClass.CompileScriptsData GetCompileScriptsData(string namespaceName) { LogicClass.CompileScriptsData compileScriptsData = new LogicClass.CompileScriptsData(); compileScriptsData.ClassName = this.className; string[] array = LogicSystemManager.Instance.UsingNamespacesToCodeGeneration.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string item = array[i]; compileScriptsData.Strings.Add(item); } compileScriptsData.Strings.Add(""); compileScriptsData.Strings.Add(string.Format("namespace {0}", namespaceName)); compileScriptsData.Strings.Add("{"); string item2; if (this is LogicEntityClass) { item2 = "\tpublic class " + this.className + " : Engine.EntitySystem.LogicSystem.LogicEntityObject"; } else { item2 = "\tpublic static class " + this.className; } compileScriptsData.Strings.Add(item2); compileScriptsData.Strings.Add("\t{"); this.GetCompileScriptsClassBody(namespaceName, compileScriptsData); compileScriptsData.Strings.Add("\t}"); compileScriptsData.Strings.Add("}"); return(compileScriptsData); }
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(""); } }
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); }