Ejemplo n.º 1
0
    private void AddItemToArray(bl_MonoBehaviour behaviour)
    {
        if (behaviour.GetType().GetMethod("OnUpdate").DeclaringType != typeof(bl_MonoBehaviour))
        {
            regularArray = ExtendAndAddItemToArray(regularArray, behaviour);
            regularUpdateArrayCount++;
        }

        if (behaviour.GetType().GetMethod("OnFixedUpdate").DeclaringType != typeof(bl_MonoBehaviour))
        {
            fixedArray = ExtendAndAddItemToArray(fixedArray, behaviour);
            fixedUpdateArrayCount++;
        }

        if (behaviour.GetType().GetMethod("OnSlowUpdate").DeclaringType != typeof(bl_MonoBehaviour))
        {
            slowArray = ExtendAndAddItemToArray(slowArray, behaviour);
            slowUpdateArrayCount++;
        }

        if (behaviour.GetType().GetMethod("OnLateUpdate").DeclaringType == typeof(bl_MonoBehaviour))
        {
            return;
        }

        lateArray = ExtendAndAddItemToArray(lateArray, behaviour);
        lateUpdateArrayCount++;
    }
Ejemplo n.º 2
0
 public static void RemoveSpecificItem(bl_MonoBehaviour behaviour)
 {
     if (instance != null)
     {
         instance.RemoveSpecificItemFromArray(behaviour);
     }
 }
Ejemplo n.º 3
0
    private void RemoveSpecificItemFromArray(bl_MonoBehaviour behaviour)
    {
        if (CheckIfArrayContainsItem(regularArray, behaviour))
        {
            regularArray = ShrinkAndRemoveItemToArray(regularArray, behaviour);
            regularUpdateArrayCount--;
        }

        if (CheckIfArrayContainsItem(fixedArray, behaviour))
        {
            fixedArray = ShrinkAndRemoveItemToArray(fixedArray, behaviour);
            fixedUpdateArrayCount--;
        }

        if (CheckIfArrayContainsItem(slowArray, behaviour))
        {
            slowArray = ShrinkAndRemoveItemToArray(slowArray, behaviour);
            slowUpdateArrayCount--;
        }

        if (!CheckIfArrayContainsItem(lateArray, behaviour))
        {
            return;
        }

        lateArray = ShrinkAndRemoveItemToArray(lateArray, behaviour);
        lateUpdateArrayCount--;
    }
Ejemplo n.º 4
0
 public static void AddItem(bl_MonoBehaviour behaviour)
 {
     if (instance == null)
     {
         return;
     }
     instance.AddItemToArray(behaviour);
 }
Ejemplo n.º 5
0
 public bl_MonoBehaviour[] ExtendAndAddItemToArray(bl_MonoBehaviour[] original, bl_MonoBehaviour itemToAdd)
 {
     size = original.Length;
     bl_MonoBehaviour[] finalArray = new bl_MonoBehaviour[size + 1];
     for (int i = 0; i < size; i++)
     {
         finalArray[i] = original[i];
     }
     finalArray[finalArray.Length - 1] = itemToAdd;
     return(finalArray);
 }
Ejemplo n.º 6
0
    public bool CheckIfArrayContainsItem(bl_MonoBehaviour[] arrayToCheck, bl_MonoBehaviour objectToCheckFor)
    {
        int size = arrayToCheck.Length;

        for (int i = 0; i < size; i++)
        {
            if (objectToCheckFor == arrayToCheck[i])
            {
                return(true);
            }
        }

        return(false);
    }
Ejemplo n.º 7
0
    public bl_MonoBehaviour[] ShrinkAndRemoveItemToArray(bl_MonoBehaviour[] original, bl_MonoBehaviour itemToRemove)
    {
        int size = original.Length;
        int fix  = 0;

        bl_MonoBehaviour[] finalArray = new bl_MonoBehaviour[size - 1];
        for (int i = 0; i < size; i++)
        {
            if (original[i] != itemToRemove)
            {
                finalArray[i - fix] = original[i];
            }
            else
            {
                fix++;
            }
        }
        return(finalArray);
    }
Ejemplo n.º 8
0
    public static void RemoveSpecificItemAndDestroyIt(bl_MonoBehaviour behaviour)
    {
        instance.RemoveSpecificItemFromArray(behaviour);

        Destroy(behaviour.gameObject);
    }
Ejemplo n.º 9
0
 public static void AddItem(bl_MonoBehaviour behaviour)
 {
     instance.AddItemToArray(behaviour);
 }