Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
guo450212436
et
提交
4acaef07
E
et
项目概览
guo450212436
/
et
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
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,发现更多精彩内容 >>
提交
4acaef07
编写于
6月 15, 2015
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加EnumHelper.FromString方法
上级
8ab531a1
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
11 addition
and
46 deletion
+11
-46
CSharp/App/Modules/BehaviorTreeModule/NodeDataEditor.xaml.cs
CSharp/App/Modules/BehaviorTreeModule/NodeDataEditor.xaml.cs
+2
-1
CSharp/Game/Model/Component/MessageComponent.cs
CSharp/Game/Model/Component/MessageComponent.cs
+1
-12
CSharp/Game/Model/Component/NetworkComponent.cs
CSharp/Game/Model/Component/NetworkComponent.cs
+1
-1
CSharp/Game/Model/IRegister.cs
CSharp/Game/Model/IRegister.cs
+1
-13
CSharp/Game/Model/Opcode.cs
CSharp/Game/Model/Opcode.cs
+1
-1
CSharp/Game/Model/OpcodeHelper.cs
CSharp/Game/Model/OpcodeHelper.cs
+0
-18
CSharp/Platform/Common/Helper/EnumHelper.cs
CSharp/Platform/Common/Helper/EnumHelper.cs
+5
-0
未找到文件。
CSharp/App/Modules/BehaviorTreeModule/NodeDataEditor.xaml.cs
浏览文件 @
4acaef07
using
System
;
using
System.Windows
;
using
System.Windows.Controls
;
using
Common.Helper
;
using
Model
;
namespace
Modules.BehaviorTreeModule
...
...
@@ -58,7 +59,7 @@ namespace Modules.BehaviorTreeModule
return
;
}
this
.
TreeNodeViewModel
.
Type
=
(
int
)
Enum
.
Parse
(
typeof
(
NodeType
),
this
.
cbType
.
SelectedValue
.
ToString
().
Trim
());
(
int
)
Enum
Helper
.
FromString
<
NodeType
>(
this
.
cbType
.
SelectedValue
.
ToString
().
Trim
());
}
}
}
\ No newline at end of file
CSharp/Game/Model/Component/MessageComponent.cs
浏览文件 @
4acaef07
...
...
@@ -50,7 +50,7 @@ namespace Model
public
void
Register
<
T
,
R
>(
Func
<
T
,
R
>
func
)
{
Opcode
opcode
=
(
Opcode
)
Enum
.
Parse
(
typeof
(
Opcode
),
typeof
(
T
).
Name
);
Opcode
opcode
=
EnumHelper
.
FromString
<
Opcode
>(
typeof
(
T
).
Name
);
events
.
Add
(
opcode
,
messageBytes
=>
{
T
t
=
MongoHelper
.
FromBson
<
T
>(
messageBytes
,
6
);
...
...
@@ -59,17 +59,6 @@ namespace Model
});
}
public
void
RegisterAsync
<
T
,
R
>(
Func
<
T
,
Task
<
R
>>
func
)
{
Opcode
opcode
=
(
Opcode
)
Enum
.
Parse
(
typeof
(
Opcode
),
typeof
(
T
).
Name
);
eventsAsync
.
Add
(
opcode
,
async
messageBytes
=>
{
T
t
=
MongoHelper
.
FromBson
<
T
>(
messageBytes
,
6
);
R
r
=
await
func
(
t
);
return
MongoHelper
.
ToBson
(
r
);
});
}
public
async
Task
<
byte
[
]>
RunAsync
(
Opcode
opcode
,
byte
[]
messageBytes
)
{
Func
<
byte
[],
byte
[
]>
func
=
null
;
...
...
CSharp/Game/Model/Component/NetworkComponent.cs
浏览文件 @
4acaef07
...
...
@@ -169,7 +169,7 @@ namespace Model
++
this
.
requestId
;
byte
[]
requestBuffer
=
MongoHelper
.
ToBson
(
request
);
Opcode
opcode
=
(
Opcode
)
Enum
.
Parse
(
typeof
(
Opcode
),
request
.
GetType
().
Name
);
Opcode
opcode
=
EnumHelper
.
FromString
<
Opcode
>(
request
.
GetType
().
Name
);
byte
[]
opcodeBuffer
=
BitConverter
.
GetBytes
((
ushort
)
opcode
);
byte
[]
idBuffer
=
BitConverter
.
GetBytes
(
this
.
requestId
);
channel
.
SendAsync
(
new
List
<
byte
[
]>
{
opcodeBuffer
,
idBuffer
,
requestBuffer
});
...
...
CSharp/Game/Model/IRegister.cs
浏览文件 @
4acaef07
using
System.Threading.Tasks
;
namespace
Model
namespace
Model
{
public
interface
IRegister
{
...
...
@@ -16,14 +14,4 @@ namespace Model
public
abstract
R
Run
(
T
t
);
}
public
abstract
class
MEventAsync
<
T
,
R
>
:
IRegister
{
public
void
Register
()
{
World
.
Instance
.
GetComponent
<
MessageComponent
>().
RegisterAsync
<
T
,
R
>(
this
.
Run
);
}
public
abstract
Task
<
R
>
Run
(
T
t
);
}
}
\ No newline at end of file
CSharp/Game/Model/Opcode.cs
浏览文件 @
4acaef07
namespace
Model
{
public
enum
Opcode
:
short
public
enum
Opcode
:
u
short
{
CMsgLogin
=
1
,
RpcResponse
=
30000
,
...
...
CSharp/Game/Model/OpcodeHelper.cs
浏览文件 @
4acaef07
...
...
@@ -19,23 +19,5 @@
}
return
false
;
}
public
static
bool
IsRpcRequestMessage
(
Opcode
opcode
)
{
if
((
ushort
)
opcode
>
20000
&&
(
ushort
)
opcode
<
30000
)
{
return
true
;
}
return
false
;
}
public
static
bool
IsRpcResponseMessage
(
Opcode
opcode
)
{
if
((
ushort
)
opcode
>
30000
&&
(
ushort
)
opcode
<
40000
)
{
return
true
;
}
return
false
;
}
}
}
CSharp/Platform/Common/Helper/EnumHelper.cs
浏览文件 @
4acaef07
...
...
@@ -17,5 +17,10 @@ namespace Common.Helper
}
return
-
1
;
}
public
static
T
FromString
<
T
>(
string
str
)
{
return
(
T
)
Enum
.
Parse
(
typeof
(
T
),
str
);
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录