private AgentRemote Create(ListUpgrade type) { AgentPrefabs.TryGetValue(type.GetHashCode(), out AgentRemote res); if (res == null) { return(null); } return(Instantiate(res, Container)); }
public void Release(ListUpgrade type, AgentRemote agent) { if (AgentPools.TryGetValue(type.GetHashCode(), out Pooling <AgentRemote> pool)) { pool.Release(agent); } else { CreatePool(type).Release(agent); } }
public AgentRemote GetItem(ListUpgrade type) { if (AgentPools.TryGetValue(type.GetHashCode(), out Pooling <AgentRemote> pool)) { return(pool.GetItem()); } else { return(CreatePool(type).GetItem()); } }
private Pooling <AgentRemote> CreatePool(ListUpgrade type) { int hashCode = type.GetHashCode(); AgentPools[hashCode] = new Pooling <AgentRemote>( delegate(int insId) { return(CreatePoolingItem(insId, type)); }); return(AgentPools[hashCode]); }