diff options
Diffstat (limited to 'Client/Assets/Scripts/XMainClient')
-rw-r--r-- | Client/Assets/Scripts/XMainClient/XComponentMgr.cs | 3 | ||||
-rw-r--r-- | Client/Assets/Scripts/XMainClient/XObject.cs | 3 | ||||
-rw-r--r-- | Client/Assets/Scripts/XMainClient/XStateMachine.cs | 2 |
3 files changed, 6 insertions, 2 deletions
diff --git a/Client/Assets/Scripts/XMainClient/XComponentMgr.cs b/Client/Assets/Scripts/XMainClient/XComponentMgr.cs index e690d0c5..9aba5136 100644 --- a/Client/Assets/Scripts/XMainClient/XComponentMgr.cs +++ b/Client/Assets/Scripts/XMainClient/XComponentMgr.cs @@ -8,6 +8,7 @@ namespace XMainClient {
private Dictionary<uint, int> _slots = new Dictionary<uint, int>();
+ // 复用component的池子
private Dictionary<uint, XComponentMgr.ComponentCache> _componentCache = new Dictionary<uint, XComponentMgr.ComponentCache>();
public static int ComponenCreatetCount = 0;
@@ -329,6 +330,7 @@ namespace XMainClient {
XComponent xcomponent = null;
XComponentMgr.ComponentCache componentCache = null;
+ // 先从池子中取
bool flag = this._componentCache.TryGetValue(uuid, out componentCache);
if (flag)
{
@@ -379,6 +381,7 @@ namespace XMainClient bool flag2 = this._componentCache.TryGetValue(c.ID, out componentCache);
if (flag2)
{
+ // 放到池子里
componentCache.componentCache.Enqueue(c);
}
}
diff --git a/Client/Assets/Scripts/XMainClient/XObject.cs b/Client/Assets/Scripts/XMainClient/XObject.cs index 4dfc105f..b82ac51c 100644 --- a/Client/Assets/Scripts/XMainClient/XObject.cs +++ b/Client/Assets/Scripts/XMainClient/XObject.cs @@ -61,6 +61,7 @@ namespace XMainClient return true;
}
+ //销毁、回收对象
public virtual void Uninitilize()
{
bool flag = this.internalIterator != null;
@@ -72,7 +73,7 @@ namespace XMainClient xcomponent.OnDetachFromHost();
this.OnComponentDetached(xcomponent);
this.Components.RemoveAt(i);
- XSingleton<XComponentMgr>.singleton.RemoveComponent(xcomponent);
+ XSingleton<XComponentMgr>.singleton.RemoveComponent(xcomponent); // 回收组件
}
ListPool<XComponent>.Release(this.internalIterator);
this.internalIterator = null;
diff --git a/Client/Assets/Scripts/XMainClient/XStateMachine.cs b/Client/Assets/Scripts/XMainClient/XStateMachine.cs index 0dd73785..50cfda9e 100644 --- a/Client/Assets/Scripts/XMainClient/XStateMachine.cs +++ b/Client/Assets/Scripts/XMainClient/XStateMachine.cs @@ -61,7 +61,7 @@ namespace XMainClient }
}
- public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("StateMachine");
+ public new static readonly uint uuID = XCommon.singleton.XHash("StateMachine");
private IXStateTransform _current = null;
|