private static LSEffect GenEffect(string effectCode, int id = -1) { FastStack <LSEffect> pool; if (!EffectPool.TryGetValue(effectCode, out pool)) { return(null); } LSEffect effect = null; if (pool.Count > 0) { effect = pool.Pop(); } else { IEffectData dataItem = CodeDataMap [effectCode]; effect = GameObject.Instantiate <GameObject>(dataItem.GetEffect().gameObject).GetComponent <LSEffect>(); effect.Setup(effectCode); } if (id == -1) { id = GenerateID(); } if (effect.Create(id)) { return(effect); } else { return(GenEffect(effectCode, id)); } }
private static LSEffect GenEffect(string effectCode, int id = -1) { FastStack <LSEffect> pool; if (!EffectPool.TryGetValue(effectCode, out pool)) { Debug.LogError(string.Format("Effect not found with code {0} in pool. Did you remember to add it to the Lockstep Database?", effectCode)); return(null); } LSEffect effect = null; if (pool.Count > 0) { effect = pool.Pop(); } else { IEffectData dataItem = CodeDataMap [effectCode]; effect = GameObject.Instantiate <GameObject>(dataItem.GetEffect().gameObject).GetComponent <LSEffect>(); effect.Setup(effectCode); } if (id == -1) { id = GenerateID(); } if (effect.Create(id)) { return(effect); } else { return(GenEffect(effectCode, id)); } }