public override bool Initialize() { mPoolManager = new PoolManager2(); SpawnPool2 pool = mPoolManager[PoolKey.SendPacket]; pool.onCreateObject = onCreatObject; pool.onSpawnObject = onSpawnObject; pool.onDespawnObject = onDesPawnObject; return(true); }
protected void onSpawnObject(object obj, object poolKey, SpawnPool2 pool) { IReference refence = obj as IReference; if (null != refence) { refence.Retain(); refence.AutoRelease(); } //return refence; }
protected object onCreatObject(object poolKey, SpawnPool2 pool) { object obj = null; switch ((PoolKey)poolKey) { case PoolKey.SendPacket: obj = new NetSendPacket(); break; } return(obj); }
public void ClosePool(object poolKey) { if (poolKey == null) { throw new ArgumentNullException("poolKey CAN'T be null"); } SpawnPool2 pool = TryGetPool(poolKey); if (null != pool) { pool.DisposeAllObjects(); mPoolDict.Remove(poolKey); } }
public SpawnPool2 TryGetPool(object poolKey) { if (poolKey == null) { throw new ArgumentNullException("poolKey CAN'T be null"); } SpawnPool2 result = null; if (!this.mPoolDict.TryGetValue(poolKey, out result)) { result = null; } return(result); }
public SpawnPool2 this[object poolKey] { get { if (poolKey == null) { throw new ArgumentNullException(); } SpawnPool2 pool = TryGetPool(poolKey); if (null == pool) { //audo 简单实现SpwanPool的使用 pool = new SpawnPool2(); pool.mPoolManager = this; pool.mPoolKey = poolKey; mPoolDict[poolKey] = pool; } return(pool); } }
protected void onDesPawnObject(object obj, object poolkey, SpawnPool2 pool) { }