Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
老鱼er
et
提交
92b65e08
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,发现更多精彩内容 >>
提交
92b65e08
编写于
11月 28, 2018
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
完善了ObjectPool的可视化
上级
a883cffe
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
183 addition
and
90 deletion
+183
-90
Server/App/Program.cs
Server/App/Program.cs
+1
-0
Server/Model/Entity/Game.cs
Server/Model/Entity/Game.cs
+1
-2
Unity/Assets/Hotfix/Base/Object/Component.cs
Unity/Assets/Hotfix/Base/Object/Component.cs
+6
-6
Unity/Assets/Hotfix/Base/Object/ObjectPool.cs
Unity/Assets/Hotfix/Base/Object/ObjectPool.cs
+92
-41
Unity/Assets/Hotfix/Entity/Game.cs
Unity/Assets/Hotfix/Entity/Game.cs
+2
-4
Unity/Assets/Hotfix/Module/UI/UIComponent.cs
Unity/Assets/Hotfix/Module/UI/UIComponent.cs
+1
-1
Unity/Assets/Model/Base/Object/Component.cs
Unity/Assets/Model/Base/Object/Component.cs
+7
-12
Unity/Assets/Model/Base/Object/ObjectPool.cs
Unity/Assets/Model/Base/Object/ObjectPool.cs
+70
-19
Unity/Assets/Model/Entity/Game.cs
Unity/Assets/Model/Entity/Game.cs
+2
-4
Unity/Assets/Model/Module/UI/UIComponent.cs
Unity/Assets/Model/Module/UI/UIComponent.cs
+1
-1
未找到文件。
Server/App/Program.cs
浏览文件 @
92b65e08
...
...
@@ -35,6 +35,7 @@ namespace App
Log
.
Info
(
$"server start........................
{
startConfig
.
AppId
}
{
startConfig
.
AppType
}
"
);
Game
.
Scene
.
AddComponent
<
TimerComponent
>();
Game
.
Scene
.
AddComponent
<
OpcodeTypeComponent
>();
Game
.
Scene
.
AddComponent
<
MessageDispatcherComponent
>();
...
...
Server/Model/Entity/Game.cs
浏览文件 @
92b65e08
...
...
@@ -12,8 +12,7 @@
{
return
scene
;
}
scene
=
new
Scene
()
{
Name
=
"ClientModel"
};
scene
.
AddComponent
<
TimerComponent
>();
scene
=
new
Scene
();
return
scene
;
}
}
...
...
Unity/Assets/Hotfix/Base/Object/Component.cs
浏览文件 @
92b65e08
...
...
@@ -14,6 +14,8 @@ namespace ETHotfix
public
long
InstanceId
{
get
;
protected
set
;
}
#if !SERVER
public
static
GameObject
Global
{
get
;
}
=
GameObject
.
Find
(
"/Global"
);
[
BsonIgnore
]
public
GameObject
GameObject
{
get
;
protected
set
;
}
#endif
...
...
@@ -69,16 +71,13 @@ namespace ETHotfix
#if !SERVER
if
(
this
.
parent
==
null
)
{
this
.
GameObject
.
transform
.
SetParent
(
G
ameObject
.
Find
(
"/Global"
)
.
transform
,
false
);
this
.
GameObject
.
transform
.
SetParent
(
G
lobal
.
transform
,
false
);
return
;
}
if
(
this
.
GameObject
!=
null
)
if
(
this
.
GameObject
!=
null
&&
this
.
parent
.
GameObject
!=
null
)
{
if
(
this
.
parent
.
GameObject
!=
null
)
{
this
.
GameObject
.
transform
.
SetParent
(
this
.
parent
.
GameObject
.
transform
,
false
);
}
this
.
GameObject
.
transform
.
SetParent
(
this
.
parent
.
GameObject
.
transform
,
false
);
}
#endif
}
...
...
@@ -107,6 +106,7 @@ namespace ETHotfix
this
.
GameObject
=
new
GameObject
();
this
.
GameObject
.
name
=
this
.
GetType
().
Name
;
this
.
GameObject
.
layer
=
LayerNames
.
GetLayerInt
(
LayerNames
.
HIDDEN
);
this
.
GameObject
.
transform
.
SetParent
(
Global
.
transform
,
false
);
this
.
GameObject
.
AddComponent
<
ComponentView
>().
Component
=
this
;
}
#endif
...
...
Unity/Assets/Hotfix/Base/Object/ObjectPool.cs
浏览文件 @
92b65e08
...
...
@@ -3,61 +3,112 @@ using System.Collections.Generic;
namespace
ETHotfix
{
public
class
ObjectPool
:
Component
public
class
ComponentQueue
:
Component
{
private
readonly
Dictionary
<
Type
,
Queue
<
Component
>>
dictionary
=
new
Dictionary
<
Type
,
Queue
<
Component
>>();
public
string
TypeName
{
get
;
}
private
readonly
Queue
<
Component
>
queue
=
new
Queue
<
Component
>();
public
Component
Fetch
(
Type
typ
e
)
public
Component
Queue
(
string
typeNam
e
)
{
Queue
<
Component
>
queue
;
if
(!
this
.
dictionary
.
TryGetValue
(
type
,
out
queue
))
{
queue
=
new
Queue
<
Component
>();
this
.
dictionary
.
Add
(
type
,
queue
);
}
Component
obj
;
if
(
queue
.
Count
>
0
)
{
obj
=
queue
.
Dequeue
();
}
else
{
obj
=
(
Component
)
Activator
.
CreateInstance
(
type
);
}
obj
.
IsFromPool
=
true
;
return
obj
;
this
.
TypeName
=
typeName
;
}
public
T
Fetch
<
T
>()
where
T
:
Component
public
void
Enqueue
(
Component
component
)
{
T
t
=
(
T
)
this
.
Fetch
(
typeof
(
T
))
;
return
t
;
component
.
Parent
=
this
;
this
.
queue
.
Enqueue
(
component
)
;
}
public
void
Recycle
(
Component
obj
)
public
Component
Dequeue
()
{
return
this
.
queue
.
Dequeue
();
}
public
Component
Peek
()
{
obj
.
Parent
=
this
;
Type
type
=
obj
.
GetType
();
Queue
<
Component
>
queue
;
if
(!
this
.
dictionary
.
TryGetValue
(
type
,
out
queue
))
return
this
.
queue
.
Peek
();
}
public
int
Count
{
get
{
queue
=
new
Queue
<
Component
>();
this
.
dictionary
.
Add
(
type
,
queue
);
return
this
.
queue
.
Count
;
}
queue
.
Enqueue
(
obj
);
}
public
void
Clear
()
public
override
void
Dispose
()
{
foreach
(
var
kv
in
this
.
dictionary
)
if
(
this
.
IsDisposed
)
{
foreach
(
Component
component
in
kv
.
Value
)
{
component
.
IsFromPool
=
false
;
component
.
Dispose
();
}
return
;
}
base
.
Dispose
();
while
(
this
.
queue
.
Count
>
0
)
{
Component
component
=
this
.
queue
.
Dequeue
();
component
.
IsFromPool
=
false
;
component
.
Dispose
();
}
this
.
dictionary
.
Clear
();
}
}
public
class
ObjectPool
:
Component
{
public
string
Name
{
get
;
set
;
}
private
readonly
Dictionary
<
Type
,
ComponentQueue
>
dictionary
=
new
Dictionary
<
Type
,
ComponentQueue
>();
public
Component
Fetch
(
Type
type
)
{
Component
obj
;
if
(!
this
.
dictionary
.
TryGetValue
(
type
,
out
ComponentQueue
queue
))
{
obj
=
(
Component
)
Activator
.
CreateInstance
(
type
);
}
else
if
(
queue
.
Count
==
0
)
{
obj
=
(
Component
)
Activator
.
CreateInstance
(
type
);
}
else
{
obj
=
queue
.
Dequeue
();
}
obj
.
IsFromPool
=
true
;
return
obj
;
}
public
T
Fetch
<
T
>()
where
T
:
Component
{
T
t
=
(
T
)
this
.
Fetch
(
typeof
(
T
));
return
t
;
}
public
void
Recycle
(
Component
obj
)
{
obj
.
Parent
=
this
;
Type
type
=
obj
.
GetType
();
ComponentQueue
queue
;
if
(!
this
.
dictionary
.
TryGetValue
(
type
,
out
queue
))
{
queue
=
new
ComponentQueue
(
type
.
Name
);
queue
.
Parent
=
this
;
this
.
dictionary
.
Add
(
type
,
queue
);
}
queue
.
Enqueue
(
obj
);
}
public
void
Clear
()
{
foreach
(
var
kv
in
this
.
dictionary
)
{
kv
.
Value
.
IsFromPool
=
false
;
kv
.
Value
.
Dispose
();
}
this
.
dictionary
.
Clear
();
}
}
}
\ No newline at end of file
Unity/Assets/Hotfix/Entity/Game.cs
浏览文件 @
92b65e08
...
...
@@ -24,8 +24,7 @@ namespace ETHotfix
{
return
scene
;
}
scene
=
new
Scene
()
{
Name
=
"ClientHotfix"
};
scene
.
GameObject
.
transform
.
SetParent
(
scene
.
GameObject
.
transform
.
Find
(
"/Global"
));
scene
=
new
Scene
()
{
Name
=
"ClientH"
};
return
scene
;
}
}
...
...
@@ -40,8 +39,7 @@ namespace ETHotfix
{
return
objectPool
;
}
objectPool
=
new
ObjectPool
();
objectPool
.
GameObject
.
transform
.
SetParent
(
GameObject
.
Find
(
"/Global"
).
transform
);
objectPool
=
new
ObjectPool
()
{
Name
=
"ClientH"
};
return
objectPool
;
}
}
...
...
Unity/Assets/Hotfix/Module/UI/UIComponent.cs
浏览文件 @
92b65e08
...
...
@@ -9,7 +9,7 @@ namespace ETHotfix
{
public
override
void
Awake
(
UIComponent
self
)
{
self
.
Camera
=
GameObject
.
Find
(
"/Global/UICamera"
)
;
self
.
Camera
=
Component
.
Global
.
transform
.
Find
(
"UICamera"
).
gameObject
;
}
}
...
...
Unity/Assets/Model/Base/Object/Component.cs
浏览文件 @
92b65e08
...
...
@@ -14,6 +14,8 @@ namespace ETModel
public
long
InstanceId
{
get
;
protected
set
;
}
#if !SERVER
public
static
GameObject
Global
{
get
;
}
=
GameObject
.
Find
(
"/Global"
);
[
BsonIgnore
]
public
GameObject
GameObject
{
get
;
protected
set
;
}
#endif
...
...
@@ -69,23 +71,16 @@ namespace ETModel
#if !SERVER
if
(
this
.
parent
==
null
)
{
this
.
GameObject
.
transform
.
SetParent
(
G
ameObject
.
Find
(
"/Global"
)
.
transform
,
false
);
this
.
GameObject
.
transform
.
SetParent
(
G
lobal
.
transform
,
false
);
return
;
}
if
(
this
.
GameObject
=
=
null
)
if
(
this
.
GameObject
!=
null
&&
this
.
parent
.
GameObject
!
=
null
)
{
return
;
this
.
GameObject
.
transform
.
SetParent
(
this
.
parent
.
GameObject
.
transform
,
false
)
;
}
if
(
this
.
parent
.
GameObject
==
null
)
{
return
;
}
this
.
GameObject
.
transform
.
SetParent
(
this
.
parent
.
GameObject
.
transform
,
false
);
#endif
}
}
}
public
T
GetParent
<
T
>()
where
T
:
Component
...
...
@@ -111,6 +106,7 @@ namespace ETModel
this
.
GameObject
=
new
GameObject
();
this
.
GameObject
.
name
=
this
.
GetType
().
Name
;
this
.
GameObject
.
layer
=
LayerNames
.
GetLayerInt
(
LayerNames
.
HIDDEN
);
this
.
GameObject
.
transform
.
SetParent
(
Global
.
transform
,
false
);
this
.
GameObject
.
AddComponent
<
ComponentView
>().
Component
=
this
;
}
#endif
...
...
@@ -138,7 +134,6 @@ namespace ETModel
else
{
#if !SERVER
if
(
this
.
GameObject
!=
null
)
{
UnityEngine
.
Object
.
Destroy
(
this
.
GameObject
);
...
...
Unity/Assets/Model/Base/Object/ObjectPool.cs
浏览文件 @
92b65e08
...
...
@@ -3,27 +3,80 @@ using System.Collections.Generic;
namespace
ETModel
{
public
class
ComponentQueue
:
Component
{
public
string
TypeName
{
get
;
}
private
readonly
Queue
<
Component
>
queue
=
new
Queue
<
Component
>();
public
ComponentQueue
(
string
typeName
)
{
this
.
TypeName
=
typeName
;
}
public
void
Enqueue
(
Component
component
)
{
component
.
Parent
=
this
;
this
.
queue
.
Enqueue
(
component
);
}
public
Component
Dequeue
()
{
return
this
.
queue
.
Dequeue
();
}
public
Component
Peek
()
{
return
this
.
queue
.
Peek
();
}
public
int
Count
{
get
{
return
this
.
queue
.
Count
;
}
}
public
override
void
Dispose
()
{
if
(
this
.
IsDisposed
)
{
return
;
}
base
.
Dispose
();
while
(
this
.
queue
.
Count
>
0
)
{
Component
component
=
this
.
queue
.
Dequeue
();
component
.
IsFromPool
=
false
;
component
.
Dispose
();
}
}
}
public
class
ObjectPool
:
Component
{
private
readonly
Dictionary
<
Type
,
Queue
<
Component
>>
dictionary
=
new
Dictionary
<
Type
,
Queue
<
Component
>>();
public
string
Name
{
get
;
set
;
}
private
readonly
Dictionary
<
Type
,
ComponentQueue
>
dictionary
=
new
Dictionary
<
Type
,
ComponentQueue
>();
public
Component
Fetch
(
Type
type
)
{
Queue
<
Component
>
queue
;
if
(!
this
.
dictionary
.
TryGetValue
(
type
,
out
queue
))
Component
obj
;
if
(!
this
.
dictionary
.
TryGetValue
(
type
,
out
ComponentQueue
queue
))
{
queue
=
new
Queue
<
Component
>();
this
.
dictionary
.
Add
(
type
,
queue
);
obj
=
(
Component
)
Activator
.
CreateInstance
(
type
);
}
Component
obj
;
if
(
queue
.
Count
>
0
)
else
if
(
queue
.
Count
==
0
)
{
obj
=
queue
.
Dequeue
(
);
obj
=
(
Component
)
Activator
.
CreateInstance
(
type
);
}
else
{
obj
=
(
Component
)
Activator
.
CreateInstance
(
type
);
}
else
{
obj
=
queue
.
Dequeue
();
}
obj
.
IsFromPool
=
true
;
return
obj
;
}
...
...
@@ -38,10 +91,11 @@ namespace ETModel
{
obj
.
Parent
=
this
;
Type
type
=
obj
.
GetType
();
Queue
<
Component
>
queue
;
ComponentQueue
queue
;
if
(!
this
.
dictionary
.
TryGetValue
(
type
,
out
queue
))
{
queue
=
new
Queue
<
Component
>();
queue
=
new
ComponentQueue
(
type
.
Name
);
queue
.
Parent
=
this
;
this
.
dictionary
.
Add
(
type
,
queue
);
}
queue
.
Enqueue
(
obj
);
...
...
@@ -51,11 +105,8 @@ namespace ETModel
{
foreach
(
var
kv
in
this
.
dictionary
)
{
foreach
(
Component
component
in
kv
.
Value
)
{
component
.
IsFromPool
=
false
;
component
.
Dispose
();
}
kv
.
Value
.
IsFromPool
=
false
;
kv
.
Value
.
Dispose
();
}
this
.
dictionary
.
Clear
();
}
...
...
Unity/Assets/Model/Entity/Game.cs
浏览文件 @
92b65e08
...
...
@@ -24,8 +24,7 @@ namespace ETModel
{
return
scene
;
}
scene
=
new
Scene
();
scene
.
GameObject
.
transform
.
SetParent
(
GameObject
.
Find
(
"/Global"
).
transform
);
scene
=
new
Scene
()
{
Name
=
"ClientM"
};
return
scene
;
}
}
...
...
@@ -40,8 +39,7 @@ namespace ETModel
{
return
objectPool
;
}
objectPool
=
new
ObjectPool
();
objectPool
.
GameObject
.
transform
.
SetParent
(
GameObject
.
Find
(
"/Global"
).
transform
);
objectPool
=
new
ObjectPool
()
{
Name
=
"ClientM"
};
return
objectPool
;
}
}
...
...
Unity/Assets/Model/Module/UI/UIComponent.cs
浏览文件 @
92b65e08
...
...
@@ -8,7 +8,7 @@ namespace ETModel
{
public
override
void
Awake
(
UIComponent
self
)
{
self
.
Camera
=
GameObject
.
Find
(
"/Global/UICamera"
)
;
self
.
Camera
=
Component
.
Global
.
transform
.
Find
(
"UICamera"
).
gameObject
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录