/// <summary> /// /// </summary> /// <returns></returns> public GameEntityT CreateNewInstance <GameEntityT>() where GameEntityT : WorldEntity { if (m_ConstructorInstance != null) { object returnObject = m_ConstructorInstance.Invoke(); GameEntityT creature = returnObject as GameEntityT; if (creature == null) { LOGs.WriteLine(LogMessageType.MSG_ERROR, "GameEntity.CreateNewInstance(...) - creature == null error!"); return(null); } return(creature); } else { m_ConstructorInstance = DynamicCalls.GetInstanceCreator(GetType()); if (m_ConstructorInstance == null) { throw new Exception("GameEntity.CreateNewInstance(...) - m_ConstructorInstance == null error!"); } GameEntityT creature = m_ConstructorInstance.Invoke() as GameEntityT; if (creature == null) { LOGs.WriteLine(LogMessageType.MSG_ERROR, "GameEntity.CreateNewInstance(...) - creature == null error!"); return(null); } return(creature); } }
/// <summary> /// /// </summary> /// <returns></returns> public ItemT Instance <ItemT>() where ItemT : BaseItem { if (m_ConstructorInstance == null) { throw new Exception("Loot.Instance(...) - m_ConstructorInstance == null error!"); } return(m_ConstructorInstance.Invoke() as ItemT); }