Эх сурвалжийг харах

简化ExcelExporter跟Proto2CS

tanghai 1 жил өмнө
parent
commit
7ab78d00e3

+ 0 - 20
Unity/Packages/cn.etetet.excel/DotNet~/ET.ExcelExporter.csproj

@@ -30,26 +30,6 @@
       <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
     </PropertyGroup>
     
-    <ItemGroup>        
-        <Compile Include="..\..\cn.etetet.core\Runtime\Model\Share\Module\Config\**\*.cs">
-            <Link>Module\Config\%(RecursiveDir)%(FileName)%(Extension)</Link>
-        </Compile>
-
-        <Compile Include="..\..\cn.etetet.core\Runtime\Model\Share\Module\Log\**\*.cs">
-            <Link>Module\Log\%(RecursiveDir)%(FileName)%(Extension)</Link>
-        </Compile>
-
-        <Compile Include="..\..\cn.etetet.core\Runtime\Network\OpcodeRangeDefine.cs">
-          <Link>OpcodeRangeDefine.cs</Link>
-        </Compile>
-    </ItemGroup>
-    
-    <ItemGroup>
-      <None Update="Template.txt">
-        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-      </None>
-    </ItemGroup>
-    
     <ItemGroup>
       <PackageReference Include="EPPlus" Version="7.1.2" />
       <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />

+ 3 - 0
Unity/Packages/cn.etetet.excel/DotNet~/ExcelExporter.cs

@@ -99,6 +99,9 @@ namespace ET
         {
             try
             {
+                // 强制调用一下mongo,避免mongo库被裁剪
+                MongoHelper.ToJson(1);
+                
                 template = File.ReadAllText("Template.txt");
                 ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
                 

+ 1 - 55
Unity/Packages/cn.etetet.excel/DotNet~/Init.cs

@@ -1,68 +1,14 @@
 using System;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Threading;
-using CommandLine;
 
 namespace ET
 {
-    public class ToolScene: IScene
-    {
-        public Fiber Fiber { get; set; }
-
-        public int SceneType
-        {
-            get;
-            set;
-        }
-
-        public ToolScene()
-        {
-        }
-
-        public ToolScene(int sceneType)
-        {
-            this.SceneType = sceneType;
-        }
-    }
-    
-    public struct ToolEvent
-    {
-    }
-    
     internal static class Init
     {
         private static int Main(string[] args)
         {
-            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
-            {
-                Log.Error(e.ExceptionObject.ToString());
-            };
-            
             try
             {
-                // 命令行参数
-                Parser.Default.ParseArguments<Options>(args)
-                    .WithNotParsed(error => throw new Exception($"命令行格式错误! {error}"))
-                    .WithParsed((o)=>World.Instance.AddSingleton(o));
-                
-                World.Instance.AddSingleton<Logger>().Log = new NLogger(Options.Instance.SceneName, Options.Instance.Process, 0);
-                
-                World.Instance.AddSingleton<CodeTypes, Assembly[]>([typeof (Init).Assembly]);
-                World.Instance.AddSingleton<EventSystem>();
-                World.Instance.AddSingleton<SceneTypeSingleton, Type>(typeof(SceneType));
-                
-                // 强制调用一下mongo,避免mongo库被裁剪
-                MongoHelper.ToJson(1);
-                
-                ETTask.ExceptionHandler += Log.Error;
-
-                int sceneType = SceneTypeSingleton.Instance.GetSceneType(Options.Instance.SceneName);
-
-                ToolScene scene = new(sceneType);
-                EventSystem.Instance.Publish(scene, new ToolEvent());
-                
-                Log.Console($"{Options.Instance.SceneName} run finish!");
+                ExcelExporter.Export();
             }
             catch (Exception e)
             {

+ 0 - 7
Unity/Packages/cn.etetet.excel/DotNet~/PackageType.cs

@@ -1,7 +0,0 @@
-namespace ET
-{
-    public static partial class PackageType
-    {
-        public const int ExcelExporter = 12;
-    }
-}

+ 0 - 8
Unity/Packages/cn.etetet.excel/DotNet~/SceneType.cs

@@ -1,8 +0,0 @@
-namespace ET
-{
-    [UniqueId]
-    public static partial class SceneType
-    {
-        public const int All = 0;
-    }
-}

+ 0 - 64
Unity/Packages/cn.etetet.excel/DotNet~/Template.txt

@@ -1,64 +0,0 @@
-using System;
-using System.Collections.Generic;
-using MongoDB.Bson.Serialization.Attributes;
-using MongoDB.Bson.Serialization.Options;
-using System.ComponentModel;
-
-namespace (ns)
-{
-    [Config]
-    public partial class (ConfigName)Category : Singleton<(ConfigName)Category>, IMerge
-    {
-        [BsonElement]
-        [BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
-        private Dictionary<int, (ConfigName)> dict = new();
-		
-        public void Merge(object o)
-        {
-            (ConfigName)Category s = o as (ConfigName)Category;
-            foreach (var kv in s.dict)
-            {
-                this.dict.Add(kv.Key, kv.Value);
-            }
-        }
-		
-        public (ConfigName) Get(int id)
-        {
-            this.dict.TryGetValue(id, out (ConfigName) item);
-
-            if (item == null)
-            {
-                throw new Exception($"配置找不到,配置表名: {nameof ((ConfigName))},配置id: {id}");
-            }
-
-            return item;
-        }
-		
-        public bool Contain(int id)
-        {
-            return this.dict.ContainsKey(id);
-        }
-
-        public Dictionary<int, (ConfigName)> GetAll()
-        {
-            return this.dict;
-        }
-
-        public (ConfigName) GetOne()
-        {
-            if (this.dict == null || this.dict.Count <= 0)
-            {
-                return null;
-            }
-            
-            var enumerator = this.dict.Values.GetEnumerator();
-            enumerator.MoveNext();
-            return enumerator.Current; 
-        }
-    }
-
-	public partial class (ConfigName): ProtoObject, IConfig
-	{
-(Fields)
-	}
-}

+ 0 - 20
Unity/Packages/cn.etetet.excel/DotNet~/ToolEvent_ExcelExporter.cs

@@ -1,20 +0,0 @@
-using System;
-
-namespace ET
-{
-    public static partial class SceneType
-    {
-        public const int ExcelExporter = PackageType.ExcelExporter * 1000 + 1;
-    }
-    
-    [Event(SceneType.ExcelExporter)]
-    public class ToolEvent_ExcelExporter: AEvent<ToolScene, ToolEvent>
-    {
-        protected override async ETTask Run(ToolScene scene, ToolEvent a)
-        {
-            Options.Instance.Console = 1;
-            ExcelExporter.Export();
-            await ETTask.CompletedTask;
-        }
-    }
-}

+ 1 - 55
Unity/Packages/cn.etetet.proto/DotNet~/Init.cs

@@ -1,68 +1,14 @@
 using System;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Threading;
-using CommandLine;
 
 namespace ET
 {
-    public class ToolScene: IScene
-    {
-        public Fiber Fiber { get; set; }
-
-        public int SceneType
-        {
-            get;
-            set;
-        }
-
-        public ToolScene()
-        {
-        }
-
-        public ToolScene(int sceneType)
-        {
-            this.SceneType = sceneType;
-        }
-    }
-    
-    public struct ToolEvent
-    {
-    }
-    
     internal static class Init
     {
         private static int Main(string[] args)
         {
-            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
-            {
-                Log.Error(e.ExceptionObject.ToString());
-            };
-            
             try
             {
-                // 命令行参数
-                Parser.Default.ParseArguments<Options>(args)
-                    .WithNotParsed(error => throw new Exception($"命令行格式错误! {error}"))
-                    .WithParsed((o)=>World.Instance.AddSingleton(o));
-                
-                World.Instance.AddSingleton<Logger>().Log = new NLogger(Options.Instance.SceneName, Options.Instance.Process, 0);
-                
-                World.Instance.AddSingleton<CodeTypes, Assembly[]>([typeof (Init).Assembly]);
-                World.Instance.AddSingleton<EventSystem>();
-                World.Instance.AddSingleton<SceneTypeSingleton, Type>(typeof(SceneType));
-                
-                // 强制调用一下mongo,避免mongo库被裁剪
-                MongoHelper.ToJson(1);
-                
-                ETTask.ExceptionHandler += Log.Error;
-
-                int sceneType = SceneTypeSingleton.Instance.GetSceneType(Options.Instance.SceneName);
-
-                ToolScene scene = new(sceneType);
-                EventSystem.Instance.Publish(scene, new ToolEvent());
-                
-                Log.Console($"{Options.Instance.SceneName} run finish!");
+                Proto2CS.Export();
             }
             catch (Exception e)
             {

+ 0 - 7
Unity/Packages/cn.etetet.proto/DotNet~/PackageType.cs

@@ -1,7 +0,0 @@
-namespace ET
-{
-    public static partial class PackageType
-    {
-        public const int Proto2CS = 11;
-    }
-}

+ 3 - 0
Unity/Packages/cn.etetet.proto/DotNet~/Proto2CS.cs

@@ -30,6 +30,9 @@ namespace ET
 
         public static void Proto2CS()
         {
+            // 强制调用一下mongo,避免mongo库被裁剪
+            MongoHelper.ToJson(1);
+            
             msgOpcode.Clear();
 
             PackagesLock packagesLock = PackageHelper.LoadEtPackagesLock("../Unity");

+ 0 - 8
Unity/Packages/cn.etetet.proto/DotNet~/SceneType.cs

@@ -1,8 +0,0 @@
-namespace ET
-{
-    [UniqueId]
-    public static partial class SceneType
-    {
-        public const int All = 0;
-    }
-}

+ 0 - 20
Unity/Packages/cn.etetet.proto/DotNet~/ToolEvent_Proto2CS.cs

@@ -1,20 +0,0 @@
-using System;
-
-namespace ET
-{
-    public static partial class SceneType
-    {
-        public const int Proto2CS = PackageType.Proto2CS * 1000 + 1;
-    }
-    
-    [Event(SceneType.Proto2CS)]
-    public class ToolEvent_Proto2CS: AEvent<ToolScene, ToolEvent>
-    {
-        protected override async ETTask Run(ToolScene scene, ToolEvent a)
-        {
-            Options.Instance.Console = 1;
-            Proto2CS.Export();
-            await ETTask.CompletedTask;
-        }
-    }
-}