예제 #1
0
    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);
    }
예제 #2
0
 public Module GetModule(Module.ID type)
 {
     for (int i = 0; i < Modules.Length; i++)
     {
         if (Modules[i].GetID() == type)
         {
             return(Modules[i]);
         }
     }
     return(null);
 }
예제 #3
0
 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));
     }
 }
예제 #4
0
 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");
     }
 }
예제 #5
0
 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);
 }
예제 #6
0
    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);
        }
    }
예제 #7
0
    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);
        }
    }