void AddToPool(UnityEntityTemplate template) { ObjectPool <UnityEntityTemplate> pool; if (_masterPool.TryGetValue(template.Name, out pool)) { if (template.gameObject.activeInHierarchy) { pool.Return(template); } } else { pool = new ObjectPool <UnityEntityTemplate>(template); _masterPool.Add(template.Name, pool); } }
public void Link(Contexts contexts, GameEntity entity, IEntityTemplate template) { this.contexts = contexts; this.entity = entity; this._template = (UnityEntityTemplate)template; var link = this.gameObject.GetEntityLink(); if (link != null && link.entity != null) { this.link = link; } else { this.link = this.gameObject.Link(entity, contexts.game); } Initialize(contexts, entity); RegisterListeners(entity); entity.AddGameToDestroyListener(this); }