Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
老鱼er
et
提交
fff1281a
E
et
项目概览
老鱼er
/
et
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
et
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
fff1281a
编写于
2月 08, 2021
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
导表把json转成protobuf格式成功
上级
f2cfa40a
变更
24
隐藏空白更改
内联
并排
Showing
24 changed file
with
248 addition
and
62 deletion
+248
-62
.gitignore
.gitignore
+1
-1
Excel/UnitConfig.xlsx
Excel/UnitConfig.xlsx
+0
-0
Generate/Client/Code/Config/StartMachineConfig.cs
Generate/Client/Code/Config/StartMachineConfig.cs
+3
-2
Generate/Client/Code/Config/StartProcessConfig.cs
Generate/Client/Code/Config/StartProcessConfig.cs
+4
-3
Generate/Client/Code/Config/StartSceneConfig.cs
Generate/Client/Code/Config/StartSceneConfig.cs
+4
-3
Generate/Client/Code/Config/StartZoneConfig.cs
Generate/Client/Code/Config/StartZoneConfig.cs
+4
-3
Generate/Client/Code/Config/UnitConfig.cs
Generate/Client/Code/Config/UnitConfig.cs
+4
-3
Generate/Client/Json/UnitConfig.txt
Generate/Client/Json/UnitConfig.txt
+1
-1
Generate/Server/Code/Config/StartMachineConfig.cs
Generate/Server/Code/Config/StartMachineConfig.cs
+3
-2
Generate/Server/Code/Config/StartProcessConfig.cs
Generate/Server/Code/Config/StartProcessConfig.cs
+4
-3
Generate/Server/Code/Config/StartSceneConfig.cs
Generate/Server/Code/Config/StartSceneConfig.cs
+4
-3
Generate/Server/Code/Config/StartZoneConfig.cs
Generate/Server/Code/Config/StartZoneConfig.cs
+4
-3
Generate/Server/Code/Config/UnitConfig.cs
Generate/Server/Code/Config/UnitConfig.cs
+4
-3
Generate/Server/Json/UnitConfig.txt
Generate/Server/Json/UnitConfig.txt
+1
-1
Server/App/Server.App.csproj
Server/App/Server.App.csproj
+1
-0
Server/Hotfix/Server.Hotfix.csproj
Server/Hotfix/Server.Hotfix.csproj
+1
-0
Server/Model/Server.Model.csproj
Server/Model/Server.Model.csproj
+1
-0
Tools/ExcelExporter/ExcelExporter.csproj
Tools/ExcelExporter/ExcelExporter.csproj
+18
-1
Tools/ExcelExporter/Program.cs
Tools/ExcelExporter/Program.cs
+139
-21
Tools/ExcelExporter/ProtoObject.cs
Tools/ExcelExporter/ProtoObject.cs
+35
-0
Tools/ExcelExporter/Template.txt
Tools/ExcelExporter/Template.txt
+4
-3
Tools/Proto2CS/Proto2CS.csproj
Tools/Proto2CS/Proto2CS.csproj
+1
-0
Unity/Assets/Model/Generate/Config/StartMachineConfig.cs
Unity/Assets/Model/Generate/Config/StartMachineConfig.cs
+2
-1
Unity/Unity.Model.csproj
Unity/Unity.Model.csproj
+5
-5
未找到文件。
.gitignore
浏览文件 @
fff1281a
...
...
@@ -49,4 +49,4 @@ Server/.DS_Store
.objs/
/Unity/.gradle
/*.user
ToolApp/
/ToolApp
Excel/UnitConfig.xlsx
浏览文件 @
fff1281a
无法预览此类型文件
Generate/Client/Code/Config/StartMachineConfig.cs
浏览文件 @
fff1281a
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
MongoDB.Bson.Serialization.Attributes
;
using
ProtoBuf
;
namespace
ET
{
[
ProtoContract
]
[
Config
]
public
partial
class
StartMachineConfigCategory
:
ProtoObject
{
...
...
@@ -62,10 +62,11 @@ namespace ET
{
return
null
;
}
return
this
.
dict
.
Values
.
First
()
;
return
this
.
dict
.
Values
.
GetEnumerator
().
Current
;
}
}
[
ProtoContract
]
public
partial
class
StartMachineConfig
:
IConfig
{
[
ProtoMember
(
1
,
IsRequired
=
true
)]
...
...
Generate/Client/Code/Config/StartProcessConfig.cs
浏览文件 @
fff1281a
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
MongoDB.Bson.Serialization.Attributes
;
using
ProtoBuf
;
namespace
ET
{
[
ProtoContract
]
[
Config
]
public
partial
class
StartProcessConfigCategory
:
ProtoObject
{
...
...
@@ -26,7 +26,7 @@ namespace ET
public
override
void
AfterDeserialization
()
{
foreach
(
Start
Machine
Config
config
in
list
)
foreach
(
Start
Process
Config
config
in
list
)
{
this
.
dict
.
Add
(
config
.
Id
,
config
);
}
...
...
@@ -62,10 +62,11 @@ namespace ET
{
return
null
;
}
return
this
.
dict
.
Values
.
First
()
;
return
this
.
dict
.
Values
.
GetEnumerator
().
Current
;
}
}
[
ProtoContract
]
public
partial
class
StartProcessConfig
:
IConfig
{
[
ProtoMember
(
1
,
IsRequired
=
true
)]
...
...
Generate/Client/Code/Config/StartSceneConfig.cs
浏览文件 @
fff1281a
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
MongoDB.Bson.Serialization.Attributes
;
using
ProtoBuf
;
namespace
ET
{
[
ProtoContract
]
[
Config
]
public
partial
class
StartSceneConfigCategory
:
ProtoObject
{
...
...
@@ -26,7 +26,7 @@ namespace ET
public
override
void
AfterDeserialization
()
{
foreach
(
Start
Machi
neConfig
config
in
list
)
foreach
(
Start
Sce
neConfig
config
in
list
)
{
this
.
dict
.
Add
(
config
.
Id
,
config
);
}
...
...
@@ -62,10 +62,11 @@ namespace ET
{
return
null
;
}
return
this
.
dict
.
Values
.
First
()
;
return
this
.
dict
.
Values
.
GetEnumerator
().
Current
;
}
}
[
ProtoContract
]
public
partial
class
StartSceneConfig
:
IConfig
{
[
ProtoMember
(
1
,
IsRequired
=
true
)]
...
...
Generate/Client/Code/Config/StartZoneConfig.cs
浏览文件 @
fff1281a
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
MongoDB.Bson.Serialization.Attributes
;
using
ProtoBuf
;
namespace
ET
{
[
ProtoContract
]
[
Config
]
public
partial
class
StartZoneConfigCategory
:
ProtoObject
{
...
...
@@ -26,7 +26,7 @@ namespace ET
public
override
void
AfterDeserialization
()
{
foreach
(
Start
Machi
neConfig
config
in
list
)
foreach
(
Start
Zo
neConfig
config
in
list
)
{
this
.
dict
.
Add
(
config
.
Id
,
config
);
}
...
...
@@ -62,10 +62,11 @@ namespace ET
{
return
null
;
}
return
this
.
dict
.
Values
.
First
()
;
return
this
.
dict
.
Values
.
GetEnumerator
().
Current
;
}
}
[
ProtoContract
]
public
partial
class
StartZoneConfig
:
IConfig
{
[
ProtoMember
(
1
,
IsRequired
=
true
)]
...
...
Generate/Client/Code/Config/UnitConfig.cs
浏览文件 @
fff1281a
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
MongoDB.Bson.Serialization.Attributes
;
using
ProtoBuf
;
namespace
ET
{
[
ProtoContract
]
[
Config
]
public
partial
class
UnitConfigCategory
:
ProtoObject
{
...
...
@@ -26,7 +26,7 @@ namespace ET
public
override
void
AfterDeserialization
()
{
foreach
(
StartMachine
Config
config
in
list
)
foreach
(
Unit
Config
config
in
list
)
{
this
.
dict
.
Add
(
config
.
Id
,
config
);
}
...
...
@@ -62,10 +62,11 @@ namespace ET
{
return
null
;
}
return
this
.
dict
.
Values
.
First
()
;
return
this
.
dict
.
Values
.
GetEnumerator
().
Current
;
}
}
[
ProtoContract
]
public
partial
class
UnitConfig
:
IConfig
{
[
ProtoMember
(
1
,
IsRequired
=
true
)]
...
...
Generate/Client/Json/UnitConfig.txt
浏览文件 @
fff1281a
{"list":[
{"_id":1001,"Name":"
测试说明","Desc":"米克尔","Position":带有强力攻击技能,"Height":1,"W
eight":178},
{"_id":1001,"Name":"
米克尔","Desc":"带有强力攻击技能","Position":1,"H
eight":178},
]}
Generate/Server/Code/Config/StartMachineConfig.cs
浏览文件 @
fff1281a
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
MongoDB.Bson.Serialization.Attributes
;
using
ProtoBuf
;
namespace
ET
{
[
ProtoContract
]
[
Config
]
public
partial
class
StartMachineConfigCategory
:
ProtoObject
{
...
...
@@ -62,10 +62,11 @@ namespace ET
{
return
null
;
}
return
this
.
dict
.
Values
.
First
()
;
return
this
.
dict
.
Values
.
GetEnumerator
().
Current
;
}
}
[
ProtoContract
]
public
partial
class
StartMachineConfig
:
IConfig
{
[
ProtoMember
(
1
,
IsRequired
=
true
)]
...
...
Generate/Server/Code/Config/StartProcessConfig.cs
浏览文件 @
fff1281a
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
MongoDB.Bson.Serialization.Attributes
;
using
ProtoBuf
;
namespace
ET
{
[
ProtoContract
]
[
Config
]
public
partial
class
StartProcessConfigCategory
:
ProtoObject
{
...
...
@@ -26,7 +26,7 @@ namespace ET
public
override
void
AfterDeserialization
()
{
foreach
(
Start
Machine
Config
config
in
list
)
foreach
(
Start
Process
Config
config
in
list
)
{
this
.
dict
.
Add
(
config
.
Id
,
config
);
}
...
...
@@ -62,10 +62,11 @@ namespace ET
{
return
null
;
}
return
this
.
dict
.
Values
.
First
()
;
return
this
.
dict
.
Values
.
GetEnumerator
().
Current
;
}
}
[
ProtoContract
]
public
partial
class
StartProcessConfig
:
IConfig
{
[
ProtoMember
(
1
,
IsRequired
=
true
)]
...
...
Generate/Server/Code/Config/StartSceneConfig.cs
浏览文件 @
fff1281a
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
MongoDB.Bson.Serialization.Attributes
;
using
ProtoBuf
;
namespace
ET
{
[
ProtoContract
]
[
Config
]
public
partial
class
StartSceneConfigCategory
:
ProtoObject
{
...
...
@@ -26,7 +26,7 @@ namespace ET
public
override
void
AfterDeserialization
()
{
foreach
(
Start
Machi
neConfig
config
in
list
)
foreach
(
Start
Sce
neConfig
config
in
list
)
{
this
.
dict
.
Add
(
config
.
Id
,
config
);
}
...
...
@@ -62,10 +62,11 @@ namespace ET
{
return
null
;
}
return
this
.
dict
.
Values
.
First
()
;
return
this
.
dict
.
Values
.
GetEnumerator
().
Current
;
}
}
[
ProtoContract
]
public
partial
class
StartSceneConfig
:
IConfig
{
[
ProtoMember
(
1
,
IsRequired
=
true
)]
...
...
Generate/Server/Code/Config/StartZoneConfig.cs
浏览文件 @
fff1281a
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
MongoDB.Bson.Serialization.Attributes
;
using
ProtoBuf
;
namespace
ET
{
[
ProtoContract
]
[
Config
]
public
partial
class
StartZoneConfigCategory
:
ProtoObject
{
...
...
@@ -26,7 +26,7 @@ namespace ET
public
override
void
AfterDeserialization
()
{
foreach
(
Start
Machi
neConfig
config
in
list
)
foreach
(
Start
Zo
neConfig
config
in
list
)
{
this
.
dict
.
Add
(
config
.
Id
,
config
);
}
...
...
@@ -62,10 +62,11 @@ namespace ET
{
return
null
;
}
return
this
.
dict
.
Values
.
First
()
;
return
this
.
dict
.
Values
.
GetEnumerator
().
Current
;
}
}
[
ProtoContract
]
public
partial
class
StartZoneConfig
:
IConfig
{
[
ProtoMember
(
1
,
IsRequired
=
true
)]
...
...
Generate/Server/Code/Config/UnitConfig.cs
浏览文件 @
fff1281a
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
MongoDB.Bson.Serialization.Attributes
;
using
ProtoBuf
;
namespace
ET
{
[
ProtoContract
]
[
Config
]
public
partial
class
UnitConfigCategory
:
ProtoObject
{
...
...
@@ -26,7 +26,7 @@ namespace ET
public
override
void
AfterDeserialization
()
{
foreach
(
StartMachine
Config
config
in
list
)
foreach
(
Unit
Config
config
in
list
)
{
this
.
dict
.
Add
(
config
.
Id
,
config
);
}
...
...
@@ -62,10 +62,11 @@ namespace ET
{
return
null
;
}
return
this
.
dict
.
Values
.
First
()
;
return
this
.
dict
.
Values
.
GetEnumerator
().
Current
;
}
}
[
ProtoContract
]
public
partial
class
UnitConfig
:
IConfig
{
[
ProtoMember
(
1
,
IsRequired
=
true
)]
...
...
Generate/Server/Json/UnitConfig.txt
浏览文件 @
fff1281a
{"list":[
{"_id":1001,"Name":"
测试说明","Desc":"米克尔","Position":带有强力攻击技能,"Height":1,"W
eight":178},
{"_id":1001,"Name":"
米克尔","Desc":"带有强力攻击技能","Position":1,"H
eight":178},
]}
Server/App/Server.App.csproj
浏览文件 @
fff1281a
...
...
@@ -9,6 +9,7 @@
<PropertyGroup>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
...
...
Server/Hotfix/Server.Hotfix.csproj
浏览文件 @
fff1281a
...
...
@@ -6,6 +6,7 @@
</PropertyGroup>
<PropertyGroup>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE2_0;SERVER;NOT_CLIENT</DefineConstants>
...
...
Server/Model/Server.Model.csproj
浏览文件 @
fff1281a
...
...
@@ -6,6 +6,7 @@
</PropertyGroup>
<PropertyGroup>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE2_0;SERVER;NOT_CLIENT</DefineConstants>
...
...
Tools/ExcelExporter/ExcelExporter.csproj
浏览文件 @
fff1281a
...
...
@@ -20,12 +20,29 @@
<ItemGroup>
<PackageReference Include="EPPlus" Version="5.5.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.9.0" />
</ItemGroup>
<ItemGroup>
<None Update="Template.txt">
<CopyToOutputDirectory>
PreserveNewest
</CopyToOutputDirectory>
<CopyToOutputDirectory>
Always
</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Server\ThirdParty\Server.ThirdParty.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Unity\Assets\Model\Core\Object\BaseAttribute.cs">
<Link>BaseAttribute.cs</Link>
</Compile>
<Compile Include="..\..\Unity\Assets\Model\Module\Config\ConfigAttribute.cs">
<Link>ConfigAttribute.cs</Link>
</Compile>
<Compile Include="..\..\Unity\Assets\Model\Module\Config\IConfig.cs">
<Link>IConfig.cs</Link>
</Compile>
</ItemGroup>
</Project>
Tools/ExcelExporter/Program.cs
浏览文件 @
fff1281a
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.IO
;
using
System.Reflection
;
using
System.Text
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.CSharp
;
using
Microsoft.CodeAnalysis.Emit
;
using
MongoDB.Bson.Serialization
;
using
MongoDB.Bson.Serialization.Attributes
;
using
OfficeOpenXml
;
using
ProtoBuf
;
using
LicenseContext
=
OfficeOpenXml
.
LicenseContext
;
namespace
ET
{
...
...
@@ -38,25 +47,39 @@ namespace ET
private
const
string
jsonDir
=
"../../Generate/{0}/Json"
;
private
const
string
protoDir
=
"../../Generate/{0}/Proto"
;
static
void
Main
(
string
[]
args
)
{
template
=
File
.
ReadAllText
(
"Template.txt"
);
ExcelPackage
.
LicenseContext
=
LicenseContext
.
NonCommercial
;
foreach
(
string
path
in
Directory
.
GetFiles
(
excelDir
,
"*.xlsx"
))
try
{
using
Stream
stream
=
new
FileStream
(
path
,
FileMode
.
Open
,
FileAccess
.
Read
,
FileShare
.
ReadWrite
);
using
ExcelPackage
p
=
new
ExcelPackage
(
stream
);
string
name
=
Path
.
GetFileNameWithoutExtension
(
path
);
template
=
File
.
ReadAllText
(
"Template.txt"
);
ExcelPackage
.
LicenseContext
=
LicenseContext
.
NonCommercial
;
foreach
(
string
path
in
Directory
.
GetFiles
(
excelDir
,
"*.xlsx"
))
{
using
Stream
stream
=
new
FileStream
(
path
,
FileMode
.
Open
,
FileAccess
.
Read
,
FileShare
.
ReadWrite
);
using
ExcelPackage
p
=
new
ExcelPackage
(
stream
);
string
name
=
Path
.
GetFileNameWithoutExtension
(
path
);
ExportExcelClass
(
p
,
name
,
ConfigType
.
Client
);
ExportExcelClass
(
p
,
name
,
ConfigType
.
Server
);
ExportExcelClass
(
p
,
name
,
ConfigType
.
Client
);
ExportExcelClass
(
p
,
name
,
ConfigType
.
Server
);
ExportExcelJson
(
p
,
name
,
ConfigType
.
Client
);
ExportExcelJson
(
p
,
name
,
ConfigType
.
Server
);
ExportExcelJson
(
p
,
name
,
ConfigType
.
Client
);
ExportExcelJson
(
p
,
name
,
ConfigType
.
Server
);
}
ExportExcelProtobuf
(
ConfigType
.
Client
);
ExportExcelProtobuf
(
ConfigType
.
Server
);
Console
.
WriteLine
(
"导表成功!"
);
}
catch
(
Exception
e
)
{
Console
.
WriteLine
(
e
);
}
}
#
region
导出
class
#region 导出class
static
void
ExportExcelClass
(
ExcelPackage
p
,
string
name
,
ConfigType
configType
)
{
List
<
HeadInfo
>
classField
=
new
List
<
HeadInfo
>();
...
...
@@ -92,7 +115,12 @@ namespace ET
static
void
ExportClass
(
string
protoName
,
List
<
HeadInfo
>
classField
,
ConfigType
configType
)
{
string
exportPath
=
Path
.
Combine
(
string
.
Format
(
classDir
,
configType
.
ToString
()),
$"
{
protoName
}
.cs"
);
string
dir
=
string
.
Format
(
classDir
,
configType
.
ToString
());
if
(!
Directory
.
Exists
(
dir
))
{
Directory
.
CreateDirectory
(
dir
);
}
string
exportPath
=
Path
.
Combine
(
dir
,
$"
{
protoName
}
.cs"
);
using
FileStream
txt
=
new
FileStream
(
exportPath
,
FileMode
.
Create
);
using
StreamWriter
sw
=
new
StreamWriter
(
txt
);
...
...
@@ -111,8 +139,9 @@ namespace ET
string
content
=
template
.
Replace
(
"(ConfigName)"
,
protoName
).
Replace
((
"(Fields)"
),
sb
.
ToString
());
sw
.
Write
(
content
);
}
#
endregion
#endregion
#region 导出json
static
void
ExportExcelJson
(
ExcelPackage
p
,
string
name
,
ConfigType
configType
)
{
StringBuilder
sb
=
new
StringBuilder
();
...
...
@@ -123,7 +152,13 @@ namespace ET
}
sb
.
AppendLine
(
"]}"
);
string
jsonPath
=
Path
.
Combine
(
string
.
Format
(
jsonDir
,
configType
.
ToString
()),
$"
{
name
}
.txt"
);
string
dir
=
string
.
Format
(
jsonDir
,
configType
.
ToString
());
if
(!
Directory
.
Exists
(
dir
))
{
Directory
.
CreateDirectory
(
dir
);
}
string
jsonPath
=
Path
.
Combine
(
dir
,
$"
{
name
}
.txt"
);
using
FileStream
txt
=
new
FileStream
(
jsonPath
,
FileMode
.
Create
);
using
StreamWriter
sw
=
new
StreamWriter
(
txt
);
sw
.
Write
(
sb
.
ToString
());
...
...
@@ -132,22 +167,25 @@ namespace ET
static
void
ExportSheetJson
(
ExcelWorksheet
worksheet
,
ConfigType
configType
,
StringBuilder
sb
)
{
int
infoRow
=
2
;
List
<
HeadInfo
>
headInfos
=
new
List
<
HeadInfo
>();
headInfos
.
Add
(
new
HeadInfo
());
headInfos
.
Add
(
new
HeadInfo
());
headInfos
.
Add
(
new
HeadInfo
());
HeadInfo
[]
headInfos
=
new
HeadInfo
[
100
];
for
(
int
col
=
3
;
col
<=
worksheet
.
Dimension
.
End
.
Column
;
++
col
)
{
string
fieldCS
=
worksheet
.
Cells
[
infoRow
,
col
].
Text
.
Trim
();
if
(
fieldCS
.
Contains
(
"#"
))
{
continue
;
}
string
fieldName
=
worksheet
.
Cells
[
infoRow
+
2
,
col
].
Text
.
Trim
();
if
(
fieldName
==
""
)
{
continue
;
}
string
fieldCS
=
worksheet
.
Cells
[
infoRow
,
col
].
Text
.
Trim
();
string
fieldDesc
=
worksheet
.
Cells
[
infoRow
+
1
,
col
].
Text
.
Trim
();
string
fieldType
=
worksheet
.
Cells
[
infoRow
+
3
,
col
].
Text
.
Trim
();
headInfos
.
Add
(
new
HeadInfo
(
fieldCS
,
fieldDesc
,
fieldName
,
fieldType
)
);
headInfos
[
col
]
=
new
HeadInfo
(
fieldCS
,
fieldDesc
,
fieldName
,
fieldType
);
}
for
(
int
row
=
6
;
row
<=
worksheet
.
Dimension
.
End
.
Row
;
++
row
)
...
...
@@ -156,6 +194,10 @@ namespace ET
for
(
int
col
=
3
;
col
<
worksheet
.
Dimension
.
End
.
Column
;
++
col
)
{
HeadInfo
headInfo
=
headInfos
[
col
];
if
(
headInfo
.
FieldAttribute
==
null
)
{
continue
;
}
if
(
headInfo
.
FieldAttribute
.
Contains
(
"#"
))
{
continue
;
...
...
@@ -198,5 +240,81 @@ namespace ET
throw
new
Exception
(
$"不支持此类型:
{
type
}
"
);
}
}
#endregion
// 根据生成的类,动态编译把json转成protobuf
private
static
void
ExportExcelProtobuf
(
ConfigType
configType
)
{
string
classPath
=
string
.
Format
(
classDir
,
configType
);
List
<
SyntaxTree
>
syntaxTrees
=
new
List
<
SyntaxTree
>();
List
<
string
>
protoNames
=
new
List
<
string
>();
foreach
(
string
classFile
in
Directory
.
GetFiles
(
classPath
,
"*.cs"
))
{
protoNames
.
Add
(
Path
.
GetFileNameWithoutExtension
(
classFile
));
syntaxTrees
.
Add
(
CSharpSyntaxTree
.
ParseText
(
File
.
ReadAllText
(
classFile
)));
}
List
<
PortableExecutableReference
>
references
=
new
List
<
PortableExecutableReference
>();
string
assemblyPath
=
Path
.
GetDirectoryName
(
typeof
(
object
).
Assembly
.
Location
);
references
.
Add
(
AssemblyMetadata
.
CreateFromFile
(
typeof
(
object
).
Assembly
.
Location
).
GetReference
());
references
.
Add
(
AssemblyMetadata
.
CreateFromFile
(
typeof
(
ProtoMemberAttribute
).
Assembly
.
Location
).
GetReference
());
references
.
Add
(
AssemblyMetadata
.
CreateFromFile
(
typeof
(
BsonDefaultValueAttribute
).
Assembly
.
Location
).
GetReference
());
references
.
Add
(
AssemblyMetadata
.
CreateFromFile
(
typeof
(
IConfig
).
Assembly
.
Location
).
GetReference
());
references
.
Add
(
AssemblyMetadata
.
CreateFromFile
(
typeof
(
Attribute
).
Assembly
.
Location
).
GetReference
());
references
.
Add
(
AssemblyMetadata
.
CreateFromFile
(
Path
.
Combine
(
assemblyPath
,
"mscorlib.dll"
)).
GetReference
());
references
.
Add
(
AssemblyMetadata
.
CreateFromFile
(
Path
.
Combine
(
assemblyPath
,
"System.dll"
)).
GetReference
());
references
.
Add
(
AssemblyMetadata
.
CreateFromFile
(
Path
.
Combine
(
assemblyPath
,
"System.Core.dll"
)).
GetReference
());
references
.
Add
(
AssemblyMetadata
.
CreateFromFile
(
Path
.
Combine
(
assemblyPath
,
"System.Runtime.dll"
)).
GetReference
());
references
.
Add
(
AssemblyMetadata
.
CreateFromFile
(
Path
.
Combine
(
assemblyPath
,
"netstandard.dll"
)).
GetReference
());
references
.
Add
(
AssemblyMetadata
.
CreateFromFile
(
typeof
(
ISupportInitialize
).
Assembly
.
Location
).
GetReference
());
CSharpCompilation
compilation
=
CSharpCompilation
.
Create
(
null
,
syntaxTrees
.
ToArray
(),
references
.
ToArray
(),
new
CSharpCompilationOptions
(
OutputKind
.
DynamicallyLinkedLibrary
));
using
MemoryStream
memSteam
=
new
MemoryStream
();
EmitResult
emitResult
=
compilation
.
Emit
(
memSteam
);
if
(!
emitResult
.
Success
)
{
StringBuilder
stringBuilder
=
new
StringBuilder
();
foreach
(
Diagnostic
t
in
emitResult
.
Diagnostics
)
{
stringBuilder
.
AppendLine
(
t
.
GetMessage
());
}
throw
new
Exception
(
$"动态编译失败:\n
{
stringBuilder
}
"
);
}
memSteam
.
Seek
(
0
,
SeekOrigin
.
Begin
);
Assembly
ass
=
Assembly
.
Load
(
memSteam
.
ToArray
());
string
dir
=
string
.
Format
(
protoDir
,
configType
.
ToString
());
if
(!
Directory
.
Exists
(
dir
))
{
Directory
.
CreateDirectory
(
dir
);
}
foreach
(
string
protoName
in
protoNames
)
{
Type
type
=
ass
.
GetType
(
$"ET.
{
protoName
}
Category"
);
Type
subType
=
ass
.
GetType
(
$"ET.
{
protoName
}
"
);
Serializer
.
NonGeneric
.
PrepareSerializer
(
type
);
Serializer
.
NonGeneric
.
PrepareSerializer
(
subType
);
string
json
=
File
.
ReadAllText
(
Path
.
Combine
(
string
.
Format
(
jsonDir
,
configType
),
$"
{
protoName
}
.txt"
));
object
deserialize
=
BsonSerializer
.
Deserialize
(
json
,
type
);
string
path
=
Path
.
Combine
(
dir
,
$"
{
protoName
}
.bytes"
);
using
FileStream
file
=
File
.
Create
(
path
);
Serializer
.
Serialize
(
file
,
deserialize
);
}
}
}
}
\ No newline at end of file
Tools/ExcelExporter/ProtoObject.cs
0 → 100644
浏览文件 @
fff1281a
using
System
;
using
System.ComponentModel
;
using
ProtoBuf
;
namespace
ET
{
public
abstract
class
Object
:
ISupportInitialize
,
IDisposable
{
public
Object
()
{
}
public
virtual
void
BeginInit
()
{
}
[
ProtoAfterDeserialization
]
public
virtual
void
AfterDeserialization
()
{
this
.
EndInit
();
}
public
virtual
void
EndInit
()
{
}
public
virtual
void
Dispose
()
{
}
}
public
class
ProtoObject
:
Object
{
}
}
\ No newline at end of file
Tools/ExcelExporter/Template.txt
浏览文件 @
fff1281a
using System;
using System.Collections.Generic;
using System.Linq;
using MongoDB.Bson.Serialization.Attributes;
using ProtoBuf;
namespace ET
{
[ProtoContract]
[Config]
public partial class (ConfigName)Category : ProtoObject
{
...
...
@@ -26,7 +26,7 @@ namespace ET
public override void AfterDeserialization()
{
foreach (
StartMachineConfig
config in list)
foreach (
(ConfigName)
config in list)
{
this.dict.Add(config.Id, config);
}
...
...
@@ -62,10 +62,11 @@ namespace ET
{
return null;
}
return this.dict.Values.
First()
;
return this.dict.Values.
GetEnumerator().Current
;
}
}
[ProtoContract]
public partial class (ConfigName): IConfig
{
(Fields)
...
...
Tools/Proto2CS/Proto2CS.csproj
浏览文件 @
fff1281a
...
...
@@ -2,6 +2,7 @@
<PropertyGroup>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>
<PropertyGroup>
...
...
Unity/Assets/Model/Generate/Config/StartMachineConfig.cs
浏览文件 @
fff1281a
...
...
@@ -62,7 +62,8 @@ namespace ET
{
return
null
;
}
return
this
.
dict
.
Values
.
First
();
return
this
.
dict
.
Values
.
GetEnumerator
().
Current
;
}
}
...
...
Unity/Unity.Model.csproj
浏览文件 @
fff1281a
...
...
@@ -60,6 +60,7 @@
<Compile
Include=
"Assets\Model\Module\Message\MessageProxy.cs"
/>
<Compile
Include=
"Assets\Model\EventType.cs"
/>
<Compile
Include=
"Assets\Model\Core\UnOrderMultiMapSet.cs"
/>
<Compile
Include=
"Assets\Model\Generate\Config\UnitConfig.cs"
/>
<Compile
Include=
"Assets\Model\Core\Entity\SceneType.cs"
/>
<Compile
Include=
"Assets\Model\Module\Message\SessionIdleCheckerComponent.cs"
/>
<Compile
Include=
"Assets\Model\Core\Helper\NetworkHelper.cs"
/>
...
...
@@ -72,6 +73,7 @@
<Compile
Include=
"Assets\Model\Module\Resource\AssetsLoaderAsync.cs"
/>
<Compile
Include=
"Assets\Model\Core\Helper\EnumHelper.cs"
/>
<Compile
Include=
"Assets\Model\Core\Object\BaseAttribute.cs"
/>
<Compile
Include=
"Assets\Model\Generate\Config\StartZoneConfig.cs"
/>
<Compile
Include=
"Assets\Model\Module\CoroutineLock\CoroutineLockQueueType.cs"
/>
<Compile
Include=
"Assets\Model\Unit\Unit.cs"
/>
<Compile
Include=
"Assets\Model\Module\Message\MessageSerializeHelper.cs"
/>
...
...
@@ -84,6 +86,7 @@
<Compile
Include=
"Assets\Model\Core\Helper\MethodInfoHelper.cs"
/>
<Compile
Include=
"Assets\Model\Module\Network\Kcp.cs"
/>
<Compile
Include=
"Assets\Model\Core\Helper\FileHelper.cs"
/>
<Compile
Include=
"Assets\Model\Generate\Config\StartProcessConfig.cs"
/>
<Compile
Include=
"Assets\Model\Core\Log\UnityLogger.cs"
/>
<Compile
Include=
"Assets\Model\Core\Object\HideInHierarchy.cs"
/>
<Compile
Include=
"Assets\Model\Module\Config\ConfigAttribute.cs"
/>
...
...
@@ -154,6 +157,7 @@
<Compile
Include=
"Assets\Model\Module\Message\SessionAcceptTimeoutComponent.cs"
/>
<Compile
Include=
"Assets\Model\Module\Numeric\NumericComponent.cs"
/>
<Compile
Include=
"Assets\Model\Module\Message\Session.cs"
/>
<Compile
Include=
"Assets\Model\Generate\Config\StartMachineConfig.cs"
/>
<Compile
Include=
"Assets\Model\Core\Object\NoMemoryCheck.cs"
/>
<Compile
Include=
"Assets\Model\Core\ObjectWait.cs"
/>
<Compile
Include=
"Assets\Model\Core\Object\Entity.cs"
/>
...
...
@@ -175,6 +179,7 @@
<Compile
Include=
"Assets\Model\Generate\OuterProtoOpcode.cs"
/>
<Compile
Include=
"Assets\Model\Core\Object\ProtoObject.cs"
/>
<Compile
Include=
"Assets\Model\Module\Message\ProtobufHelper.cs"
/>
<Compile
Include=
"Assets\Model\Generate\Config\StartSceneConfig.cs"
/>
<Compile
Include=
"Assets\Model\Module\Message\NetThreadComponent.cs"
/>
<Compile
Include=
"Assets\Model\Core\Helper\TimeHelper.cs"
/>
<Compile
Include=
"Assets\Model\Core\Object\ISerializeToEntity.cs"
/>
...
...
@@ -197,11 +202,6 @@
<Compile
Include=
"Assets\Model\Core\Async\ETTaskHelper.cs"
/>
<Compile
Include=
"Assets\Model\Module\NetworkTCP\TChannel.cs"
/>
<Compile
Include=
"Assets\Model\Module\Network\AChannel.cs"
/>
<Compile
Include=
"Assets\Model\Generate\Config\UnitConfig.cs"
/>
<Compile
Include=
"Assets\Model\Generate\Config\StartSceneConfig.cs"
/>
<Compile
Include=
"Assets\Model\Generate\Config\StartZoneConfig.cs"
/>
<Compile
Include=
"Assets\Model\Generate\Config\StartProcessConfig.cs"
/>
<Compile
Include=
"Assets\Model\Generate\Config\StartMachineConfig.cs"
/>
<None
Include=
"Assets\Model\Unity.Model.asmdef"
/>
<Reference
Include=
"UnityEngine"
>
<HintPath>
/Applications/Unity/Hub/Editor/2020.2.2f1c1/Unity.app/Contents/Managed/UnityEngine/UnityEngine.dll
</HintPath>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录