public Module AddModule(Module.ID type) { Module module = System.Array.Find(Modules, x => x.GetID() == type); if (module != null) { Debug.Log("Module of type " + type + " already exists in " + GetName() + "."); } else { string id = type + "Module"; module = (Module)ScriptableObject.CreateInstance(id); if (module == null) { Debug.Log("Module of class type " + id + " could not be loaded in " + GetName() + "."); } else { module.Init(this); ArrayExtensions.Add(ref Modules, module); AssetDatabase.AddObjectToAsset(Modules.Last(), this); } } return(module); }
public Module GetModule(Module.ID type) { for (int i = 0; i < Modules.Length; i++) { if (Modules[i].GetID() == type) { return(Modules[i]); } } return(null); }
public void RemoveModule(Module.ID type) { if (System.Array.Find(Modules, x => x.GetID() == type) == null) { Debug.Log("Module of type " + type + " does not exist in " + GetName() + "."); } else { ArrayExtensions.RemoveAt(ref Modules, System.Array.FindIndex(Modules, x => x.GetID() == type)); } }
public void AddModule(Module.ID type) { if (System.Array.Find(Modules, x => x.GetID() == type) != null) { Debug.Log("Module of type " + type + " already exists in " + GetName() + "."); } else { CreateModule(type + "Module"); } }
public Module GetModule(Module.ID type) { for (int i = 0; i < Modules.Length; i++) { if (Modules[i].GetID() == type) { return(Modules[i]); } } //Debug.Log("Module of type " + type + " does not exist in " + GetName() + "."); return(null); }
public void RemoveModule(Module.ID type) { Module module = GetModule(type); if (!module) { Debug.Log("Module of type " + type + " does not exist in " + GetName() + "."); } else { ArrayExtensions.Remove(ref Modules, module); GameObject.DestroyImmediate(module, true); } }
public void RemoveModule(Module.ID type) { Module module = GetModule(type); if (!module) { Debug.Log("Module of type " + type + " does not exist in " + GetName() + "."); } else { ArrayExtensions.Remove(ref Modules, module); Utility.Destroy(module); } }