示例#1
0
    public ComponentBehaviour[] ExtendAndAddItemToArray(ComponentBehaviour[] original, ComponentBehaviour itemToAdd)
    {
        int size = original.Length;

        ComponentBehaviour[] finalArray = new ComponentBehaviour[size + 1];
        for (int i = 0; i < size; i++)
        {
            finalArray[i] = original[i];
        }
        finalArray[finalArray.Length - 1] = itemToAdd;
        return(finalArray);
    }
示例#2
0
    public bool CheckIfArrayContainsItem(ComponentBehaviour[] arrayToCheck, ComponentBehaviour objectToCheckFor)
    {
        int size = arrayToCheck.Length;

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

        return(false);
    }
示例#3
0
    public ComponentBehaviour[] ShrinkAndRemoveItemToArray(ComponentBehaviour[] original, ComponentBehaviour itemToRemove)
    {
        int size = original.Length;

        ComponentBehaviour[] finalArray = new ComponentBehaviour[size - 1];
        for (int i = 0; i < size; i++)
        {
            if (original[i] == itemToRemove)
            {
                continue;
            }

            finalArray[i] = original[i];
        }
        return(finalArray);
    }
示例#4
0
    private void AddItemToArray(ComponentBehaviour behaviour)
    {
        if (behaviour.GetType().GetMethod("OnUpdate").DeclaringType != typeof(ComponentBehaviour))
        {
            regularArray = ExtendAndAddItemToArray(regularArray, behaviour);
            regularUpdateArrayCount++;
        }

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

        if (behaviour.GetType().GetMethod("OnLateUpdate").DeclaringType != typeof(ComponentBehaviour))
        {
            lateArray = ExtendAndAddItemToArray(lateArray, behaviour);
            lateUpdateArrayCount++;
        }

        if (behaviour.GetType().GetMethod("Tick").DeclaringType != typeof(ComponentBehaviour))
        {
            regularTickArray = ExtendAndAddItemToArray(regularTickArray, behaviour);
            regularTickArrayCount++;
        }

        if (behaviour.GetType().GetMethod("FixedTick").DeclaringType != typeof(ComponentBehaviour))
        {
            fixedTickArray = ExtendAndAddItemToArray(fixedTickArray, behaviour);
            fixedTickArrayCount++;
        }

        if (behaviour.GetType().GetMethod("LateTick").DeclaringType == typeof(ComponentBehaviour))
        {
            return;
        }

        lateTickArray = ExtendAndAddItemToArray(lateTickArray, behaviour);
        lateTickArrayCount++;
    }
示例#5
0
    private void RemoveSpecificItemFromArray(ComponentBehaviour behaviour)
    {
        if (CheckIfArrayContainsItem(regularArray, behaviour))
        {
            regularArray = ShrinkAndRemoveItemToArray(regularArray, behaviour);
            regularUpdateArrayCount--;
        }

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

        if (CheckIfArrayContainsItem(lateArray, behaviour))
        {
            lateArray = ShrinkAndRemoveItemToArray(lateArray, behaviour);
            lateUpdateArrayCount--;
        }

        if (CheckIfArrayContainsItem(regularTickArray, behaviour))
        {
            regularTickArray = ShrinkAndRemoveItemToArray(regularTickArray, behaviour);
            regularTickArrayCount--;
        }

        if (CheckIfArrayContainsItem(fixedTickArray, behaviour))
        {
            fixedTickArray = ShrinkAndRemoveItemToArray(fixedTickArray, behaviour);
            fixedTickArrayCount--;
        }

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

        lateTickArray = ShrinkAndRemoveItemToArray(lateTickArray, behaviour);
        lateTickArrayCount--;
    }
示例#6
0
    public static void RemoveSpecificItemAndDestroyIt(ComponentBehaviour behaviour)
    {
        instance.RemoveSpecificItemFromArray(behaviour);

        Destroy(behaviour.gameObject);
    }
示例#7
0
 public static void RemoveSpecificItem(ComponentBehaviour behaviour)
 {
     instance.RemoveSpecificItemFromArray(behaviour);
 }
示例#8
0
 public static void AddItem(ComponentBehaviour behaviour)
 {
     instance.AddItemToArray(behaviour);
 }