export-table-plugin-csharp 1.1.189

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/.vscode/launch.json +21 -0
  2. package/bin/Json2LiteDB.exe +0 -0
  3. package/bin/Json2LiteDB.pdb +0 -0
  4. package/bin/LiteDB.dll +0 -0
  5. package/bin/LiteDB.xml +7288 -0
  6. package/dist/CSParseTool.d.ts +36 -0
  7. package/dist/CSParseTool.d.ts.map +1 -0
  8. package/dist/CSParseTool.js +533 -0
  9. package/dist/CSProtoParser.d.ts +22 -0
  10. package/dist/CSProtoParser.d.ts.map +1 -0
  11. package/dist/CSProtoParser.js +171 -0
  12. package/dist/ExportCSPlugin.d.ts +9 -0
  13. package/dist/ExportCSPlugin.d.ts.map +1 -0
  14. package/dist/ExportCSPlugin.js +290 -0
  15. package/dist/ExportLiteDBCSPlugin.d.ts +8 -0
  16. package/dist/ExportLiteDBCSPlugin.d.ts.map +1 -0
  17. package/dist/ExportLiteDBCSPlugin.js +221 -0
  18. package/dist/ExportLiteDBUnityCSJsonPlugin.d.ts +11 -0
  19. package/dist/ExportLiteDBUnityCSJsonPlugin.d.ts.map +1 -0
  20. package/dist/ExportLiteDBUnityCSJsonPlugin.js +190 -0
  21. package/dist/ExportUnityCSJsonPlugin.d.ts +10 -0
  22. package/dist/ExportUnityCSJsonPlugin.d.ts.map +1 -0
  23. package/dist/ExportUnityCSJsonPlugin.js +265 -0
  24. package/dist/ExportUnityMMPPlugin.d.ts +8 -0
  25. package/dist/ExportUnityMMPPlugin.d.ts.map +1 -0
  26. package/dist/ExportUnityMMPPlugin.js +116 -0
  27. package/dist/index.d.ts +7 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +15 -0
  30. package/package.json +24 -0
  31. package/res/mmp-cs/BitUtils.cs +171 -0
  32. package/res/mmp-cs/BitUtils.cs.meta +11 -0
  33. package/res/mmp-cs/WritableValueTuple.cs +40 -0
  34. package/res/mmp-cs/WritableValueTuple.cs.meta +11 -0
  35. package/src/CSParseTool.ts +425 -0
  36. package/src/CSProtoParser.ts +137 -0
  37. package/src/ExportCSPlugin.ts +321 -0
  38. package/src/ExportLiteDBCSPlugin.ts +245 -0
  39. package/src/ExportLiteDBUnityCSJsonPlugin.ts +175 -0
  40. package/src/ExportUnityCSJsonPlugin.ts +297 -0
  41. package/src/ExportUnityMMPPlugin.ts +127 -0
  42. package/src/index.ts +14 -0
  43. package/test/testCS.bat +1 -0
  44. package/test/testCSWithProto.bat +1 -0
  45. package/test/testLiteDB.bat +2 -0
  46. package/test/testUJson.bat +2 -0
  47. package/tsconfig.json +101 -0
@@ -0,0 +1,175 @@
1
+
2
+ import { cmm, HandleSheetParams, Field, foreach, IPlugin, st, PluginBase, HandleBatchParams, OutFilePath, makeFirstLetterUpper } from "export-table-lib"
3
+ import * as fs from "fs-extra"
4
+ import { GetUsingJsonToolNamespace, TryConvValue, convMemberName, firstLetterUpper, outputFileSync } from "./CSParseTool";
5
+ import path from "path";
6
+ import * as cp from "child_process"
7
+ import { exportUJson } from "./ExportUnityCSJsonPlugin";
8
+
9
+ var isSkipIndexLoader0 = process.argv.findIndex(v => v == "--SkipIndexLoader") >= 0
10
+
11
+ export function exportUJsonLoader(paras: HandleSheetParams): string | null {
12
+ let {
13
+ datas,
14
+ fields,
15
+ name,
16
+ objects,
17
+ table,
18
+ exportNamespace,
19
+ } = paras;
20
+
21
+ let useJsonToolNamesapce = GetUsingJsonToolNamespace()
22
+
23
+ let RowClass = firstLetterUpper(name)
24
+ var fullName = `${table.workbookName}-${name}`
25
+ // !!!必须开头没有空格
26
+ let temp = `
27
+ using System.Threading.Tasks;
28
+ using LiteDB;
29
+ using UnityEngine;
30
+ ${useJsonToolNamesapce}
31
+
32
+ namespace ${exportNamespace}
33
+ {
34
+ public partial class ${RowClass}
35
+ {
36
+ protected static LiteDatabase Database;
37
+ protected static ILiteCollection<${RowClass}> Collection;
38
+ public const string CollKey = "${fullName.replace("-", "_")}";
39
+ public static Task Load()
40
+ {
41
+ #if UNITY_EDITOR && ENABLE_CONFIG_LOG
42
+ Debug.Log("ReferConfig-${RowClass}");
43
+ #endif
44
+ var key = CollKey;
45
+ var ldb = SharedLiteDB.Database;
46
+ Database = ldb;
47
+ if (!ldb.CollectionExists(key))
48
+ {
49
+ Debug.LogError($"配表资源缺失: {key}");
50
+ }
51
+ Collection = ldb.GetCollection<${RowClass}>(key);
52
+
53
+ return Task.CompletedTask;
54
+ }
55
+ }
56
+ }
57
+ `
58
+ return temp
59
+
60
+ }
61
+
62
+ export async function RemoveJsonFiles(savePaths2: string[]) {
63
+ let deleteTasks = savePaths2.map(async (savePath2) => {
64
+ console.log(`delete file: ${savePath2}`)
65
+ try {
66
+ if (fs.existsSync(savePath2)) {
67
+ fs.removeSync(savePath2);
68
+ }
69
+ } catch (ex) {
70
+ console.error(`error: cannot delete file ${savePath2}`);
71
+ console.error(ex);
72
+ }
73
+ })
74
+
75
+ await Promise.all(deleteTasks)
76
+ }
77
+ export async function ConvJson2LiteDB(litedbpath: string, savePaths: string[]) {
78
+ if (litedbpath != null && litedbpath != "") {
79
+ let modulePath = require.resolve(".")
80
+ let binPath = path.resolve(modulePath, "../../bin/Json2LiteDB.exe")
81
+ // let dbPath = path.resolve("../../../GameClient/Assets/Bundles/GameConfigs/Auto/MainConfig.db.bytes");
82
+ // let dbPath = path.resolve(litedbpath)
83
+ let savePaths2 = savePaths.map(savePath => path.resolve(savePath))
84
+ let cmdParas = savePaths2.concat();
85
+ cmdParas.unshift(litedbpath);
86
+ let cmdParasLine = cmdParas.join(" ");
87
+ let cmdline = `${binPath} ${cmdParasLine}`;
88
+ console.log("execute-cmdline: " + cmdline)
89
+ var output = cp.spawnSync(binPath, cmdParas)
90
+ console.log(output.output.toString())
91
+
92
+ RemoveJsonFiles(savePaths2)
93
+ } else {
94
+ console.log(`no litedbpath given, skip conv database`)
95
+ }
96
+ }
97
+
98
+ export class ExportLiteDBUJsonPlugin extends PluginBase {
99
+ name = "litedbujson"
100
+ tags: string[] = ["litedbujson"]
101
+
102
+ handleSheet(paras: HandleSheetParams) {
103
+ var fullName = `${paras.table.workbookName}-${paras.name}`
104
+ {
105
+ let content1 = exportUJsonLoader(paras)
106
+ if (content1 != null) {
107
+ let savePath = new OutFilePath(paras.outPath, fullName, "Loader.cs").fullPath
108
+ outputFileSync(savePath, content1, "utf-8")
109
+ }
110
+ }
111
+ {
112
+ let content2 = exportUJson(paras)
113
+ if (content2 != null) {
114
+ let savePath = new OutFilePath(paras.outPath, fullName, ".json").fullPath
115
+ outputFileSync(savePath, content2, "utf-8")
116
+ }
117
+
118
+ return content2
119
+ }
120
+ }
121
+
122
+ async handleBatch(paras: HandleBatchParams) {
123
+
124
+ let {
125
+ moreOptions,
126
+ tables,
127
+ exportNamespace,
128
+ } = paras
129
+ let isSkipIndexLoader = moreOptions?.SkipIndexLoader ?? false
130
+ if (isSkipIndexLoader0) {
131
+ isSkipIndexLoader = true
132
+ }
133
+ if (isSkipIndexLoader) {
134
+ return;
135
+ }
136
+
137
+ var temp = `
138
+ using System;
139
+ using System.Collections.Generic;
140
+ using System.Threading.Tasks;
141
+
142
+ namespace ${exportNamespace}
143
+ {
144
+ public static class DefaultConfigLoader{
145
+ public static IEnumerable<Func<Task>> Load(){
146
+ ${foreach(tables.sort((ta, tb) => ta.name.localeCompare(tb.name)), (table) => `
147
+ yield return ${firstLetterUpper(table.name)}.Load;
148
+ `)}
149
+ yield break;
150
+ }
151
+ }
152
+ }
153
+ `
154
+ let savePath = paras.outPath + "/DefaultConfigLoader.cs";
155
+ outputFileSync(savePath, temp, "utf-8");
156
+
157
+ // var options = new program.Command().option("--litedbpath <string>").parse(process.argv).allowUnknownOption(true).opts()
158
+ // let litedbpath = options["litedbpath"]
159
+ let litedbpathIndex = process.argv.indexOf("--litedbpath")
160
+ let litedbpath: string = "";
161
+ if (litedbpathIndex >= 0) {
162
+ litedbpath = process.argv[litedbpathIndex + 1]
163
+ }
164
+ console.log(`litedbpath: ${litedbpath}`);
165
+
166
+ let cmdParas = tables.map(table => {
167
+ var fullName = `${table.workbookName}-${table.name}`
168
+ let savePath = new OutFilePath(paras.outPath, fullName, ".json").fullPath
169
+ return savePath
170
+ })
171
+
172
+ await ConvJson2LiteDB(litedbpath, cmdParas);
173
+
174
+ }
175
+ }
@@ -0,0 +1,297 @@
1
+
2
+ import { cmm, HandleSheetParams, Field, foreach, IPlugin, st, PluginBase, HandleBatchParams, OutFilePath, makeFirstLetterUpper } from "export-table-lib"
3
+ import * as fs from "fs-extra"
4
+ import { GetUsingJsonToolNamespace, TryConvValue, convMemberName, genTupleArrayValue, isEnableMMP, outputFileSync } from "./CSParseTool";
5
+
6
+ var isSkipIndexLoader0 = process.argv.findIndex(v => v == "--SkipIndexLoader") >= 0
7
+ var isWrapObject = process.argv.findIndex(v => v == "--WrapObject") >= 0
8
+
9
+ let firstLetterUpper = makeFirstLetterUpper;
10
+ export function exportUJson(paras: HandleSheetParams): string | null {
11
+ let {
12
+ datas,
13
+ fields,
14
+ name,
15
+ objects,
16
+ table,
17
+ } = paras;
18
+
19
+ var fullName = `${table.workbookName}-${name}`
20
+ let jsonString = JSON.stringify(objects.map(obj => {
21
+ var newObj = Object.create(null);
22
+ for (let f of fields) {
23
+ let key = f.name
24
+ var newKey = convMemberName(key);
25
+ newObj[newKey] = obj[key];
26
+
27
+ let content = obj[key]
28
+ let result = genTupleArrayValue(f, content)
29
+ if (result != null) {
30
+ let { isArray, objs } = result
31
+ if (isArray) {
32
+ newObj[newKey + "Obj"] = objs
33
+ } else {
34
+ if (objs.length > 1) {
35
+ console.log(`配置错误,过多的条目数量: ${content}`)
36
+ }
37
+ newObj[newKey + "Obj"] = objs[0] ?? {}
38
+ }
39
+ }
40
+ }
41
+ // Object.keys(obj).forEach(key => {
42
+ // var newKey = convMemberName(key);
43
+ // newObj[newKey] = obj[key];
44
+ // })
45
+ return newObj
46
+ }));
47
+
48
+ if(isWrapObject){
49
+ jsonString = `{"A":${jsonString}}`
50
+ }
51
+
52
+ return jsonString;
53
+
54
+ // // !!!必须开头没有空格
55
+ // let temp = `%YAML 1.1
56
+ // %TAG !u! tag:unity3d.com,2011:
57
+ // --- !u!114 &11400000
58
+ // MonoBehaviour:
59
+ // m_ObjectHideFlags: 0
60
+ // m_CorrespondingSourceObject: {fileID: 0}
61
+ // m_PrefabInstance: {fileID: 0}
62
+ // m_PrefabAsset: {fileID: 0}
63
+ // m_GameObject: {fileID: 0}
64
+ // m_Enabled: 1
65
+ // m_EditorHideFlags: 0
66
+ // m_Script: {fileID: 11500000, guid: 496f60086c072a8479a6e0b948efb5e8, type: 3}
67
+ // m_Name: ${fullName}
68
+ // m_EditorClassIdentifier:
69
+ // JsonText: ${JSON.stringify(jsonString)}
70
+ // `
71
+ // return temp
72
+
73
+ }
74
+
75
+ export function exportUJsonLoader(paras: HandleSheetParams): string | null {
76
+ let {
77
+ datas,
78
+ fields,
79
+ name,
80
+ objects,
81
+ table,
82
+ exportNamespace,
83
+ allTags,
84
+ } = paras;
85
+
86
+ let useJsonToolNamesapce = GetUsingJsonToolNamespace()
87
+
88
+ let RowClass = firstLetterUpper(name)
89
+ let fullName = `${table.workbookName}-${name}`
90
+
91
+ let isMMP = isEnableMMP || allTags.indexOf('csharp:mmp') != -1
92
+ let fileExt = isMMP ? ".bytes" : ".json"
93
+
94
+ // !!!必须开头没有空格
95
+ let temp = `
96
+ using System.Collections.Generic;
97
+ using System.Threading.Tasks;
98
+ using UnityEngine;
99
+ ${useJsonToolNamesapce}
100
+
101
+ namespace ${exportNamespace}
102
+ {
103
+ public partial class ${RowClass}
104
+ {
105
+ #if UNITY_EDITOR && ENABLE_CONFIG_LOG
106
+ static ${RowClass}()
107
+ {
108
+ Debug.Log("ReferConfig-${RowClass}");
109
+ }
110
+ #endif
111
+ [System.Serializable]
112
+ private struct TempA
113
+ {
114
+ public List<${RowClass}> a;
115
+ }
116
+
117
+ public const string LoadUrl = "Assets/Bundles/GameConfigs/Auto/${fullName}${fileExt}";
118
+ public static int LoadState = 0;
119
+ public static bool IsLoadedSuccessfully => LoadState == 4;
120
+ public static bool IsComplete => LoadState != 0;
121
+
122
+ public static async Task Load()
123
+ {
124
+ if (LoadState <= 0)
125
+ {
126
+ LoadState = 1;
127
+ var loadUrl = LoadUrl;
128
+ var configLiteral = await ConfigAssetLoader.LoadAssetAsync(loadUrl);
129
+ if (configLiteral != null)
130
+ {
131
+ Debug.Log($"解析配表: {loadUrl}");
132
+ try
133
+ {
134
+ // JsonUtility.FromJsonOverwrite("{\"a\":"+configLiteral+"}", obj);
135
+ LoadState = 2;
136
+ ConfigAssetLoader.LoadConfigs(configLiteral, Configs);
137
+ LoadState = 4;
138
+ }
139
+ catch (System.Exception ex)
140
+ {
141
+ LoadState = -2;
142
+ Debug.LogError($"解析配表失败: {loadUrl}");
143
+ throw ex;
144
+ }
145
+ }
146
+ else
147
+ {
148
+ LoadState = -1;
149
+ Debug.LogError($"配表资源缺失: {loadUrl}");
150
+ }
151
+ }
152
+ }
153
+
154
+ #if UNITY_EDITOR
155
+ public static void LoadInEditor(bool force = false, System.Func<string, string> pathConverter = null)
156
+ {
157
+ if ((!force) && UnityEditor.EditorApplication.isPlaying)
158
+ {
159
+ var tip = $"cannot load ${RowClass}[] with LoadInEditor at runtime";
160
+ Debug.LogError(tip);
161
+ throw new System.Exception(tip);
162
+ }
163
+ var loadUrl = pathConverter == null ? LoadUrl : pathConverter(LoadUrl);
164
+ var configLiteral = System.IO.File.ReadAllText(loadUrl, System.Text.Encoding.UTF8);
165
+ if (configLiteral != null)
166
+ {
167
+ Configs.Clear();
168
+ try
169
+ {
170
+ ConfigAssetLoader.LoadConfigs(configLiteral, Configs);
171
+ }
172
+ catch(System.Exception ex)
173
+ {
174
+ Debug.LogError($"解析配表失败: {loadUrl}");
175
+ throw ex;
176
+ }
177
+ }
178
+ else
179
+ {
180
+ Debug.LogError($"配表资源缺失: {loadUrl}");
181
+ }
182
+ }
183
+
184
+ public static void SaveInEditor(bool force = false, System.Func<string, string> pathConverter = null)
185
+ {
186
+ if ((!force) && UnityEditor.EditorApplication.isPlaying)
187
+ {
188
+ var tip = $"cannot load ${RowClass}[] with LoadInEditor at runtime";
189
+ Debug.LogError(tip);
190
+ throw new System.Exception(tip);
191
+ }
192
+
193
+ var loadUrl = pathConverter == null ? LoadUrl : pathConverter(LoadUrl);
194
+ string configLiteral = null;
195
+ try
196
+ {
197
+ configLiteral = ConfigAssetLoader.ToLiteral(Configs);
198
+ }
199
+ catch (System.Exception exception)
200
+ {
201
+ Debug.LogError($"json序列化失败: {loadUrl}");
202
+ throw exception;
203
+ }
204
+
205
+ if (configLiteral != null)
206
+ {
207
+ try
208
+ {
209
+ var content0 = System.IO.File.ReadAllText(loadUrl, System.Text.Encoding.UTF8);
210
+ if (content0 != configLiteral)
211
+ {
212
+ System.IO.File.WriteAllText(loadUrl, configLiteral, System.Text.Encoding.UTF8);
213
+ }
214
+ }
215
+ catch (System.Exception exception)
216
+ {
217
+ Debug.LogError($"写配置文件失败: {loadUrl}");
218
+ throw exception;
219
+ }
220
+ }
221
+ }
222
+ #endif
223
+ }
224
+ }
225
+ `
226
+ return temp
227
+
228
+ }
229
+
230
+ export class ExportUJsonPlugin extends PluginBase {
231
+ name = "ujson"
232
+ tags: string[] = ["ujson"]
233
+
234
+ handleSheet(paras: HandleSheetParams) {
235
+ var fullName = `${paras.table.workbookName}-${paras.name}`
236
+ {
237
+ let content1 = exportUJsonLoader(paras)
238
+ if (content1 != null) {
239
+ let savePath = new OutFilePath(paras.outPath, fullName, "Loader.cs").fullPath
240
+ outputFileSync(savePath, content1, "utf-8")
241
+ }
242
+ }
243
+ {
244
+ let content2 = exportUJson(paras)
245
+ if (content2 != null) {
246
+ let savePath = new OutFilePath(paras.outPath, fullName, ".json").fullPath
247
+ outputFileSync(savePath, content2, "utf-8")
248
+ }
249
+ return content2
250
+ }
251
+ }
252
+
253
+ handleBatch(paras: HandleBatchParams): void {
254
+
255
+ let {
256
+ moreOptions,
257
+ tables,
258
+ exportNamespace,
259
+ } = paras
260
+ let isSkipIndexLoader = moreOptions?.SkipIndexLoader ?? false
261
+ if (isSkipIndexLoader0) {
262
+ isSkipIndexLoader = true
263
+ }
264
+ if (isSkipIndexLoader) {
265
+ return;
266
+ }
267
+
268
+ var temp = `
269
+ using System;
270
+ using System.Collections.Generic;
271
+ using System.Threading.Tasks;
272
+
273
+ namespace ${exportNamespace}
274
+ {
275
+ public static class DefaultConfigLoader{
276
+ public static IEnumerable<Func<Task>> Load(){
277
+ ${foreach(tables.sort((ta, tb) => ta.name.localeCompare(tb.name)), (table) => `
278
+ yield return ${firstLetterUpper(table.name)}.Load;
279
+ `)}
280
+ yield break;
281
+ }
282
+
283
+ #if UNITY_EDITOR
284
+ public static IEnumerable<Action<bool, System.Func<string, string>>> LoadInEditor(){
285
+ ${foreach(tables.sort((ta, tb) => ta.name.localeCompare(tb.name)), (table) => `
286
+ yield return ${firstLetterUpper(table.name)}.LoadInEditor;
287
+ `)}
288
+ yield break;
289
+ }
290
+ #endif
291
+ }
292
+ }
293
+ `
294
+ let savePath = paras.outPath + "/DefaultConfigLoader.cs";
295
+ outputFileSync(savePath, temp, "utf-8");
296
+ }
297
+ }
@@ -0,0 +1,127 @@
1
+
2
+ import { cmm, HandleSheetParams, Field, foreach, IPlugin, st, PluginBase, HandleBatchParams, OutFilePath, makeFirstLetterUpper, iff } from "export-table-lib"
3
+ import * as fs from "fs-extra"
4
+ import { convMemberName, convVarName, getFieldElementType, getFieldType, isTypeArray, outputFileSync, useMMPNamespace } from "./CSParseTool";
5
+
6
+ var isEnableMMPB = process.argv.findIndex(v => v == "--EnableMMPB") >= 0
7
+
8
+ let firstLetterUpper = makeFirstLetterUpper;
9
+
10
+ export function exportMMP(paras: HandleSheetParams): string | null {
11
+ let {
12
+ datas,
13
+ fields,
14
+ name,
15
+ objects,
16
+ table,
17
+ exportNamespace,
18
+ } = paras;
19
+
20
+ let RowClass = firstLetterUpper(name)
21
+ var fullName = `${table.workbookName}-${name}`
22
+ var mmpMark = "[System.Runtime.InteropServices.StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)]";
23
+ // TODO: 支持FK类型
24
+ let temp = `
25
+ using System;
26
+ using System.Collections.Generic;
27
+ using System.Runtime.InteropServices;
28
+ ${useMMPNamespace}
29
+
30
+ namespace ${exportNamespace}
31
+ {
32
+ ${mmpMark}
33
+ public partial class ${RowClass} : IMMPSerializable
34
+ {
35
+ private static int _typeSize = -1;
36
+
37
+ public static int GetTypeSize()
38
+ {
39
+ if (_typeSize >= 0)
40
+ {
41
+ return _typeSize;
42
+ }
43
+
44
+ _typeSize = Marshal.SizeOf<${RowClass}>();
45
+ return _typeSize;
46
+ }
47
+
48
+ public void Serialize(ref SerializeParas paras)
49
+ {
50
+ ${foreach(fields, f => `
51
+ ${iff(f.type == "string[]", () => `
52
+ var ${convVarName(f.name)} = this.${convMemberName(f.name)}; this.${convMemberName(f.name)} = null;
53
+ `)}
54
+ `)}
55
+ Marshal.StructureToPtr(this, paras.Ptr, false);
56
+ ${foreach(fields, f => `
57
+ ${iff(f.type == "string[]", () => `
58
+ this.${convMemberName(f.name)} = ${convVarName(f.name)};
59
+ `)}
60
+ `)}
61
+ paras.Offset += GetTypeSize();
62
+ ${foreach(fields, f => `
63
+ ${iff(f.type == "string", () => `
64
+ // ${f.name}
65
+ BitUtils.FromString(ref paras, this.${convMemberName(f.name)});
66
+ ${iff(f.rawType.startsWith("@") && f.rawType.endsWith("[]"), () => `
67
+ BitUtils.FromSArray(ref paras, this.${convMemberName(f.name)}Obj);
68
+ `)}
69
+ `).elseif(f.type == "string[]", () => `
70
+ // ${f.name}
71
+ BitUtils.FromArray(ref paras, this.${convMemberName(f.name)}, BitUtils.FromString);
72
+ `).elseif(isTypeArray(f), () => `
73
+ // ${f.name}
74
+ BitUtils.FromRawArray(ref paras, this.${convMemberName(f.name)});
75
+ `).else(() => `
76
+ `)}
77
+ `, "\n")}
78
+ }
79
+
80
+ public void Deserialize(ref DeserializeParas paras)
81
+ {
82
+ Marshal.PtrToStructure(paras.Ptr, this);
83
+ paras.Offset += GetTypeSize();
84
+ ${foreach(fields, f => `
85
+ ${iff(f.type == "string", () => `
86
+ // ${f.name}
87
+ this.${convMemberName(f.name)} = BitUtils.ToString(ref paras);
88
+ ${iff(f.rawType.startsWith("@") && f.rawType.endsWith("[]"), () => `
89
+ BitUtils.ToSArray(ref paras, ref this.${convMemberName(f.name)}Obj);
90
+ `)}
91
+ `).elseif(f.type == "string[]", () => `
92
+ // ${f.name}
93
+ this.${convMemberName(f.name)} = BitUtils.ToArray(ref paras, BitUtils.ToString);
94
+ `).elseif(isTypeArray(f), () => `
95
+ // ${f.name}
96
+ this.${convMemberName(f.name)} = BitUtils.ToRawArray<${getFieldElementType(f)}>(ref paras);
97
+ `).else(() => `
98
+ `)}
99
+ `)}
100
+ }
101
+
102
+ public static IEnumerable<IMMPSerializable> AsSerializableEnumerable()
103
+ {
104
+ return Configs;
105
+ }
106
+ }
107
+ }
108
+ `
109
+ return temp
110
+
111
+ }
112
+
113
+ export class ExportUnityMMPPlugin extends PluginBase {
114
+ name = "mmp"
115
+ tags: string[] = ["mmp"]
116
+
117
+ handleSheet(paras: HandleSheetParams) {
118
+ var fullName = `${paras.table.workbookName}-${paras.name}`
119
+ {
120
+ let content1 = exportMMP(paras)
121
+ if (content1 != null) {
122
+ let savePath = new OutFilePath(paras.outPath, fullName, "MMP.cs").fullPath
123
+ outputFileSync(savePath, content1, "utf-8")
124
+ }
125
+ }
126
+ }
127
+ }
package/src/index.ts ADDED
@@ -0,0 +1,14 @@
1
+
2
+ import { ExportPlugin as ExportCSPlugin } from "./ExportCSPlugin"
3
+ import { ExportLiteDBCSPlugin } from "./ExportLiteDBCSPlugin"
4
+ import { ExportLiteDBUJsonPlugin } from "./ExportLiteDBUnityCSJsonPlugin"
5
+ import { ExportUJsonPlugin } from "./ExportUnityCSJsonPlugin"
6
+ import { ExportUnityMMPPlugin } from "./ExportUnityMMPPlugin"
7
+
8
+ export const ExportPlugins = [
9
+ new ExportCSPlugin(),
10
+ new ExportUJsonPlugin(),
11
+ new ExportLiteDBCSPlugin(),
12
+ new ExportLiteDBUJsonPlugin(),
13
+ new ExportUnityMMPPlugin(),
14
+ ]
@@ -0,0 +1 @@
1
+ node E:\DATA\Projects\netease\quicktable\export-table\dist\launch.js export src dist --tags csharp:cs --libs E:\DATA\Projects\netease\quicktable %*
@@ -0,0 +1 @@
1
+ node E:\DATA\Projects\netease\quicktable\export-table\dist\launch.js export src dist --tags csharp:cs --libs E:\DATA\Projects\netease\quicktable --WithProto src/wasmproto.proto --scenes client %*
@@ -0,0 +1,2 @@
1
+ node E:\DATA\Projects\netease\quicktable\export-table\dist\launch.js export src dist --tags csharp:litedbcs --libs E:\DATA\Projects\netease\quicktable %*
2
+ node E:\DATA\Projects\netease\quicktable\export-table\dist\launch.js export src dist --tags csharp:litedbujson --libs E:\DATA\Projects\netease\quicktable --litedbpath ./dist/MainConfig.db.bytes %*
@@ -0,0 +1,2 @@
1
+ node E:\DATA\Projects\netease\quicktable\export-table\dist\launch.js export src dist --tags csharp:mmp;csharp:cs --libs E:\DATA\Projects\netease\quicktable %*
2
+ node E:\DATA\Projects\netease\quicktable\export-table\dist\launch.js export src dist --tags csharp:ujson --EnableMMPB --libs E:\DATA\Projects\netease\quicktable %*