public IConfactory Get(Type t) { IConfactory confectory = null; if (activeConfectories.ContainsKey(t)) { confectory = activeConfectories[t]; } else { if (!inCreationTypes.Contains(t)) { if (sceneChecker == null) { CreateSceneSwitchChecker(); } inCreationTypes.Add(t); confectory = CreateConfectory(t); inCreationTypes.Remove(t); } else { Debug.LogWarning("Confectory " + t.Name + " already in construction, don't try to access it!"); } } return(confectory); }
public void Delete(Type t) { if (activeConfectories.ContainsKey(t)) { if (!inDeletionTypes.Contains(t)) { inDeletionTypes.Add(t); IConfactory confactory = activeConfectories[t]; activeConfectories.Remove(t); confactory.ConClear(); if (confactory.GetType().IsSubclassOf(typeof(MonoBehaviour))) { GameObject.Destroy((confactory as MonoBehaviour).gameObject); } inDeletionTypes.Remove(t); if (activeConfectories.Count == 0) { DeleteSceneSwitchChecker(); } } else { Debug.LogWarning("Confectory " + t.Name + " already in process of deletion, don't try to delete it!"); } } }
private IConfactory GetRepresentingConfactory(IConfactory confactory) { IConfactory confactoryToReturn = null; IConStructUser conStructUser = confactory as IConStructUser; IConfactory lastReturn = null; if (conStructUser != null) { while (conStructUser != null && (lastReturn != confactoryToReturn || confactoryToReturn == null)) { lastReturn = conStructUser as IConfactory; confactoryToReturn = conStructUser.ConStruct(this); conStructUser = confactoryToReturn as IConStructUser; } } if (confactoryToReturn == null) { confactoryToReturn = confactory; } return(confactoryToReturn); }