/// <summary> /// 获取继承指定接口的System通用代码 /// </summary> /// <returns></returns> public static string GetOtherSystemCode() { string className = ToolData.selectedContextName + ToolData.otherSystemName + ToolData.systemPosfix; List <string> selectedSystem = GetSelectedSystem(); ScriptBuildHelp build = new ScriptBuildHelp(); build.WriteUsing("Entitas"); build.WriteNameSpace(ToolData.namespaceBase); build.WriteEmptyLine(); build.IndentTimes++; //class build.WriteClass(className, GetSelectedSystem(selectedSystem)); build.IndentTimes++; build.WriteLine("protected Contexts contexts;", true); build.WriteEmptyLine(); //构造 build.WriteFun(className, ScriptBuildHelp.Public, new List <string>(), " ", "Contexts contexts"); build.BackToInsertContent(); build.IndentTimes++; build.WriteLine("this.contexts = contexts;", true); build.IndentTimes--; build.ToContentEnd(); //实现方法 List <string> funcName = GetFuncName(selectedSystem); List <string> keyName = new List <string>(); keyName.Add("void"); foreach (string func in funcName) { build.WriteEmptyLine(); build.WriteFun(func, ScriptBuildHelp.Public, keyName); } return(build.ToString()); }
/// <summary> /// 获取ReactiveSystem通用代码 /// </summary> /// <returns></returns> public static string GetReactiveSystemCode() { string className = ToolData.selectedContextName + ToolData.systemName + ToolData.systemPosfix; string entityName = ToolData.selectedContextName + "Entity"; ScriptBuildHelp build = new ScriptBuildHelp(); build.WriteUsing("Entitas"); build.WriteUsing("System.Collections.Generic"); build.WriteEmptyLine(); //class build.WriteClass(className, "ReactiveSystem<" + entityName + ">"); build.IndentTimes++; build.WriteLine("protected Contexts contexts;", true); build.WriteEmptyLine(); //构造 build.WriteFun(className, ScriptBuildHelp.Public, new List <string>(), ": base(contexts." + ToolData.selectedContextName.ToLower() + ")", "Contexts contexts"); build.BackToInsertContent(); build.IndentTimes++; build.WriteLine("this.contexts = contexts;", true); build.IndentTimes--; build.ToContentEnd(); build.WriteEmptyLine(); //GetTrigger List <string> triggerKeys = new List <string>(); triggerKeys.Add("override"); triggerKeys.Add("ICollector<" + entityName + ">"); build.WriteFun("GetTrigger", ScriptBuildHelp.Protected, triggerKeys, " ", "IContext<" + entityName + "> context"); build.BackToInsertContent(); build.IndentTimes++; build.WriteLine("return context.CreateCollector(" + ToolData.selectedContextName + "Matcher." + ToolData.selectedContextName + ToolData.systemName + ");", true); build.IndentTimes--; build.ToContentEnd(); build.WriteEmptyLine(); //Filter List <string> filterKeys = new List <string>(); filterKeys.Add("override"); filterKeys.Add("bool"); build.WriteFun("Filter", ScriptBuildHelp.Protected, filterKeys, "", entityName + " " + "entity"); build.BackToInsertContent(); build.IndentTimes++; build.WriteLine("return entity.has" + ToolData.selectedContextName + ToolData.systemName + ";", true); build.IndentTimes--; build.ToContentEnd(); build.WriteEmptyLine(); //Execute List <string> executeKeys = new List <string>(); executeKeys.Add("override"); executeKeys.Add("void"); build.WriteFun("Execute", ScriptBuildHelp.Protected, executeKeys, "", "List<" + entityName + "> entities"); return(build.ToString()); }
/// <summary> /// 获取Service类通用代码 /// </summary> /// <returns></returns> public static string GetServiceCode() { ScriptBuildHelp build = new ScriptBuildHelp(); string className = ToolData.serviceName + ToolData.servicePostfix; build.WriteUsing("Game.Interface"); build.WriteEmptyLine(); build.WriteNameSpace(ToolData.namespaceBase + "." + ToolData.servicePostfix); build.WriteEmptyLine(); build.IndentTimes++; build.WriteInterface("I" + className, "IInitService"); build.ToContentEnd(); build.WriteEmptyLine(); //class build.WriteClass(className, "I" + className); var keyName = new List <string>(); keyName.Add("void"); build.IndentTimes++; //Init build.WriteFun("Init", ScriptBuildHelp.Public, keyName, "", "Contexts contexts"); build.BackToInsertContent(); build.IndentTimes++; build.WriteLine("//contexts.service.SetGameService" + className + "(this);", true); build.IndentTimes--; build.ToContentEnd(); build.WriteEmptyLine(); var key = new List <string>(); key.Add("int"); //GetPriority build.WriteFun("GetPriority", ScriptBuildHelp.Public, key); build.BackToInsertContent(); build.IndentTimes++; build.WriteLine("return 0;", true); build.IndentTimes--; build.ToContentEnd(); return(build.ToString()); }