Example #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);
    }
Example #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);
 }
Example #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));
     }
 }
Example #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");
     }
 }
Example #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);
 }
Example #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);
        }
    }
Example #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);
        }
    }