Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
guo450212436
et
提交
d668c194
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,发现更多精彩内容 >>
提交
d668c194
编写于
9月 27, 2016
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
重新设计了Entity的层次关系api
上级
5864e5b0
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
173 addition
and
193 deletion
+173
-193
Unity/Assets/Res/Code/Controller.dll.bytes
Unity/Assets/Res/Code/Controller.dll.bytes
+0
-0
Unity/Assets/Res/Code/Controller.dll.bytes.meta
Unity/Assets/Res/Code/Controller.dll.bytes.meta
+0
-4
Unity/Assets/Res/Code/Controller.dll.mdb.bytes
Unity/Assets/Res/Code/Controller.dll.mdb.bytes
+0
-0
Unity/Assets/Res/Code/Controller.dll.mdb.bytes.meta
Unity/Assets/Res/Code/Controller.dll.mdb.bytes.meta
+0
-8
Unity/Assets/Scripts/Base/Object/Entity.cs
Unity/Assets/Scripts/Base/Object/Entity.cs
+78
-2
Unity/Assets/Scripts/Base/Object/Object.cs
Unity/Assets/Scripts/Base/Object/Object.cs
+8
-100
Unity/Assets/Scripts/Component/Scene.cs
Unity/Assets/Scripts/Component/Scene.cs
+1
-78
Unity/Assets/Scripts/Other/Env.cs
Unity/Assets/Scripts/Other/Env.cs
+86
-1
未找到文件。
Unity/Assets/Res/Code/Controller.dll.bytes
已删除
100644 → 0
浏览文件 @
5864e5b0
文件已删除
Unity/Assets/Res/Code/Controller.dll.bytes.meta
已删除
100644 → 0
浏览文件 @
5864e5b0
fileFormatVersion: 2
guid: ddebf2498a1f6984bbd3290b28570092
TextScriptImporter:
userData:
Unity/Assets/Res/Code/Controller.dll.mdb.bytes
已删除
100644 → 0
浏览文件 @
5864e5b0
文件已删除
Unity/Assets/Res/Code/Controller.dll.mdb.bytes.meta
已删除
100644 → 0
浏览文件 @
5864e5b0
fileFormatVersion: 2
guid: edf597891a39c89458673c2ff0bf977d
timeCreated: 1463827830
licenseType: Pro
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:
Unity/Assets/Scripts/Base/Object/Entity.cs
浏览文件 @
d668c194
...
@@ -10,16 +10,33 @@ namespace Base
...
@@ -10,16 +10,33 @@ namespace Base
{
{
[
BsonElement
,
BsonIgnoreIfNull
]
[
BsonElement
,
BsonIgnoreIfNull
]
private
HashSet
<
Component
<
T
>>
components
=
new
HashSet
<
Component
<
T
>>();
private
HashSet
<
Component
<
T
>>
components
=
new
HashSet
<
Component
<
T
>>();
private
Dictionary
<
Type
,
Component
<
T
>>
componentDict
=
new
Dictionary
<
Type
,
Component
<
T
>>();
private
Dictionary
<
Type
,
Component
<
T
>>
componentDict
=
new
Dictionary
<
Type
,
Component
<
T
>>();
[
BsonIgnore
]
public
T
Parent
{
get
;
set
;
}
public
string
Name
{
get
;
}
[
BsonElement
,
BsonIgnoreIfNull
]
private
Dictionary
<
long
,
T
>
idChildren
;
[
BsonElement
,
BsonIgnoreIfNull
]
private
Dictionary
<
string
,
T
>
nameChildren
;
protected
Entity
()
protected
Entity
()
{
{
this
.
Name
=
""
;
ObjectManager
.
Add
(
this
);
ObjectManager
.
Add
(
this
);
}
}
protected
Entity
(
long
id
):
base
(
id
)
protected
Entity
(
string
name
)
{
{
this
.
Name
=
name
;
ObjectManager
.
Add
(
this
);
}
protected
Entity
(
long
id
,
string
name
):
base
(
id
)
{
this
.
Name
=
name
;
ObjectManager
.
Add
(
this
);
ObjectManager
.
Add
(
this
);
}
}
...
@@ -28,6 +45,59 @@ namespace Base
...
@@ -28,6 +45,59 @@ namespace Base
return
MongoHelper
.
FromBson
<
T
>(
MongoHelper
.
ToBson
(
this
));
return
MongoHelper
.
FromBson
<
T
>(
MongoHelper
.
ToBson
(
this
));
}
}
public
int
Count
{
get
{
return
this
.
idChildren
.
Count
;
}
}
public
void
Add
(
T
t
)
{
t
.
Parent
=
(
T
)
this
;
if
(
this
.
idChildren
==
null
)
{
this
.
idChildren
=
new
Dictionary
<
long
,
T
>();
this
.
nameChildren
=
new
Dictionary
<
string
,
T
>();
}
this
.
idChildren
.
Add
(
t
.
Id
,
t
);
this
.
nameChildren
.
Add
(
t
.
Name
,
t
);
}
private
void
Remove
(
T
t
)
{
this
.
idChildren
.
Remove
(
t
.
Id
);
this
.
nameChildren
.
Remove
(
t
.
Name
);
if
(
this
.
idChildren
.
Count
==
0
)
{
this
.
idChildren
=
null
;
this
.
nameChildren
=
null
;
}
t
.
Dispose
();
}
public
void
Remove
(
long
id
)
{
T
t
;
if
(!
this
.
idChildren
.
TryGetValue
(
id
,
out
t
))
{
return
;
}
this
.
Remove
(
t
);
}
public
void
Remove
(
string
name
)
{
T
t
;
if
(!
this
.
nameChildren
.
TryGetValue
(
name
,
out
t
))
{
return
;
}
this
.
Remove
(
t
);
}
public
override
void
Dispose
()
public
override
void
Dispose
()
{
{
if
(
this
.
Id
==
0
)
if
(
this
.
Id
==
0
)
...
@@ -37,6 +107,11 @@ namespace Base
...
@@ -37,6 +107,11 @@ namespace Base
base
.
Dispose
();
base
.
Dispose
();
foreach
(
T
t
in
this
.
idChildren
.
Values
.
ToArray
())
{
t
.
Dispose
();
}
foreach
(
Component
<
T
>
component
in
this
.
GetComponents
())
foreach
(
Component
<
T
>
component
in
this
.
GetComponents
())
{
{
try
try
...
@@ -48,6 +123,7 @@ namespace Base
...
@@ -48,6 +123,7 @@ namespace Base
Log
.
Error
(
e
.
ToString
());
Log
.
Error
(
e
.
ToString
());
}
}
}
}
this
.
Parent
?.
Remove
(
this
.
Id
);
ObjectManager
.
Remove
(
this
.
Id
);
ObjectManager
.
Remove
(
this
.
Id
);
}
}
...
...
Unity/Assets/Scripts/Base/Object/Object.cs
浏览文件 @
d668c194
using
System
;
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.ComponentModel
;
using
MongoDB.Bson.Serialization.Attributes
;
using
MongoDB.Bson.Serialization.Attributes
;
namespace
Base
namespace
Base
{
{
public
abstract
class
Object
:
I
SupportInitialize
,
IDisposable
,
IEnumerabl
e
public
abstract
class
Object
:
I
Disposable
,
ISupportInitializ
e
{
{
public
static
ObjectManager
ObjectManager
=
new
ObjectManager
();
public
static
ObjectManager
ObjectManager
=
new
ObjectManager
();
[
BsonId
]
[
BsonId
]
public
long
Id
{
get
;
private
set
;
}
public
long
Id
{
get
;
private
set
;
}
public
Dictionary
<
string
,
object
>
Values
{
get
{
return
values
;
}
}
[
BsonElement
,
BsonIgnoreIfNull
]
private
Dictionary
<
string
,
object
>
values
=
new
Dictionary
<
string
,
object
>();
protected
Object
()
protected
Object
()
{
{
Id
=
IdGenerater
.
GenerateId
();
Id
=
IdGenerater
.
GenerateId
();
...
@@ -34,106 +21,27 @@ namespace Base
...
@@ -34,106 +21,27 @@ namespace Base
this
.
Id
=
id
;
this
.
Id
=
id
;
}
}
public
virtual
void
BeginInit
()
public
bool
IsDisposed
()
{
if
(
this
.
values
==
null
)
{
this
.
values
=
new
Dictionary
<
string
,
object
>();
}
}
public
virtual
void
EndInit
()
{
if
(
this
.
values
.
Count
==
0
)
{
this
.
values
=
null
;
}
}
public
object
this
[
string
key
]
{
get
{
return
this
.
values
[
key
];
}
set
{
if
(
this
.
values
==
null
)
{
this
.
values
=
new
Dictionary
<
string
,
object
>();
}
this
.
values
[
key
]
=
value
;
}
}
public
T
Get
<
T
>(
string
key
)
{
if
(
this
.
values
==
null
||
!
this
.
values
.
ContainsKey
(
key
))
{
return
default
(
T
);
}
object
value
=
values
[
key
];
return
(
T
)
value
;
}
public
void
Set
(
string
key
,
object
obj
)
{
if
(
this
.
values
==
null
)
{
this
.
values
=
new
Dictionary
<
string
,
object
>();
}
this
.
values
[
key
]
=
obj
;
}
public
bool
ContainKey
(
string
key
)
{
if
(
this
.
values
==
null
)
{
{
return
false
;
return
this
.
Id
==
0
;
}
return
this
.
values
.
ContainsKey
(
key
);
}
}
public
v
oid
Remove
(
string
key
)
public
v
irtual
void
Dispose
(
)
{
{
if
(
this
.
values
==
null
)
if
(
this
.
Id
==
0
)
{
{
return
;
return
;
}
}
this
.
values
.
Remove
(
key
);
if
(
this
.
values
.
Count
==
0
)
{
this
.
values
=
null
;
}
}
public
void
Add
(
string
key
,
object
value
)
{
if
(
this
.
values
==
null
)
{
this
.
values
=
new
Dictionary
<
string
,
object
>();
}
this
.
values
[
key
]
=
value
;
}
public
IEnumerator
GetEnumerator
()
this
.
Id
=
0
;
{
return
this
.
values
.
GetEnumerator
();
}
}
public
bool
IsDisposed
()
public
virtual
void
BeginInit
()
{
{
return
this
.
Id
==
0
;
}
}
public
virtual
void
Dispose
()
public
virtual
void
EndInit
()
{
if
(
this
.
Id
==
0
)
{
{
return
;
}
this
.
Id
=
0
;
}
}
}
}
}
}
\ No newline at end of file
Unity/Assets/Scripts/Component/Scene.cs
浏览文件 @
d668c194
...
@@ -18,88 +18,13 @@ namespace Base
...
@@ -18,88 +18,13 @@ namespace Base
public
sealed
class
Scene
:
Entity
<
Scene
>
public
sealed
class
Scene
:
Entity
<
Scene
>
{
{
public
Scene
Parent
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
public
SceneType
SceneType
{
get
;
}
public
SceneType
SceneType
{
get
;
}
private
readonly
Dictionary
<
long
,
Scene
>
Children
=
new
Dictionary
<
long
,
Scene
>();
public
Scene
(
string
name
,
SceneType
sceneType
):
base
(
name
)
private
readonly
Dictionary
<
SceneType
,
HashSet
<
Scene
>>
SceneTypeChildren
=
new
Dictionary
<
SceneType
,
HashSet
<
Scene
>>();
public
Scene
(
string
name
,
SceneType
sceneType
)
{
{
this
.
Name
=
name
;
this
.
SceneType
=
sceneType
;
this
.
SceneType
=
sceneType
;
}
}
public
int
Count
{
get
{
return
this
.
Children
.
Count
;
}
}
public
void
Add
(
Scene
scene
)
{
scene
.
Parent
=
this
;
this
.
Children
.
Add
(
scene
.
Id
,
scene
);
HashSet
<
Scene
>
listScene
;
if
(!
this
.
SceneTypeChildren
.
TryGetValue
(
scene
.
SceneType
,
out
listScene
))
{
listScene
=
new
HashSet
<
Scene
>();
this
.
SceneTypeChildren
.
Add
(
scene
.
SceneType
,
listScene
);
}
listScene
.
Add
(
scene
);
}
public
Scene
Get
(
SceneType
sceneType
)
{
HashSet
<
Scene
>
scenes
;
if
(!
this
.
SceneTypeChildren
.
TryGetValue
(
sceneType
,
out
scenes
))
{
return
null
;
}
if
(
scenes
.
Count
==
0
)
{
return
null
;
}
return
scenes
.
First
();
}
public
void
Remove
(
SceneType
sceneType
)
{
HashSet
<
Scene
>
scenes
;
if
(!
this
.
SceneTypeChildren
.
TryGetValue
(
sceneType
,
out
scenes
))
{
return
;
}
foreach
(
Scene
scene
in
scenes
)
{
Children
.
Remove
(
scene
.
Id
);
scene
.
Dispose
();
}
this
.
SceneTypeChildren
.
Remove
(
sceneType
);
}
public
void
Remove
(
long
id
)
{
Scene
scene
;
if
(!
this
.
Children
.
TryGetValue
(
id
,
out
scene
))
{
return
;
}
HashSet
<
Scene
>
scenes
;
if
(!
this
.
SceneTypeChildren
.
TryGetValue
(
scene
.
SceneType
,
out
scenes
))
{
return
;
}
scenes
.
Remove
(
scene
);
scene
.
Dispose
();
}
public
override
void
Dispose
()
public
override
void
Dispose
()
{
{
if
(
this
.
Id
==
0
)
if
(
this
.
Id
==
0
)
...
@@ -108,8 +33,6 @@ namespace Base
...
@@ -108,8 +33,6 @@ namespace Base
}
}
base
.
Dispose
();
base
.
Dispose
();
this
.
Parent
?.
Remove
(
this
.
Id
);
}
}
}
}
}
}
\ No newline at end of file
Unity/Assets/Scripts/Other/Env.cs
浏览文件 @
d668c194
namespace
Base
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
MongoDB.Bson.Serialization.Attributes
;
namespace
Base
{
{
public
class
Env
:
Object
public
class
Env
:
Object
{
{
[
BsonElement
,
BsonIgnoreIfNull
]
private
Dictionary
<
string
,
object
>
values
=
new
Dictionary
<
string
,
object
>();
public
object
this
[
string
key
]
{
get
{
return
this
.
values
[
key
];
}
set
{
if
(
this
.
values
==
null
)
{
this
.
values
=
new
Dictionary
<
string
,
object
>();
}
this
.
values
[
key
]
=
value
;
}
}
public
T
Get
<
T
>(
string
key
)
{
if
(
this
.
values
==
null
||
!
this
.
values
.
ContainsKey
(
key
))
{
return
default
(
T
);
}
object
value
=
values
[
key
];
try
{
return
(
T
)
value
;
}
catch
(
InvalidCastException
e
)
{
throw
new
GameException
(
$"不能把
{
value
.
GetType
()}
转换为
{
typeof
(
T
)}
"
,
e
);
}
}
public
void
Set
(
string
key
,
object
obj
)
{
if
(
this
.
values
==
null
)
{
this
.
values
=
new
Dictionary
<
string
,
object
>();
}
this
.
values
[
key
]
=
obj
;
}
public
bool
ContainKey
(
string
key
)
{
if
(
this
.
values
==
null
)
{
return
false
;
}
return
this
.
values
.
ContainsKey
(
key
);
}
public
void
Remove
(
string
key
)
{
if
(
this
.
values
==
null
)
{
return
;
}
this
.
values
.
Remove
(
key
);
if
(
this
.
values
.
Count
==
0
)
{
this
.
values
=
null
;
}
}
public
void
Add
(
string
key
,
object
value
)
{
if
(
this
.
values
==
null
)
{
this
.
values
=
new
Dictionary
<
string
,
object
>();
}
this
.
values
[
key
]
=
value
;
}
public
IEnumerator
GetEnumerator
()
{
return
this
.
values
.
GetEnumerator
();
}
}
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录