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); }
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); }
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); }
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++; }
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--; }
public static void RemoveSpecificItemAndDestroyIt(ComponentBehaviour behaviour) { instance.RemoveSpecificItemFromArray(behaviour); Destroy(behaviour.gameObject); }
public static void RemoveSpecificItem(ComponentBehaviour behaviour) { instance.RemoveSpecificItemFromArray(behaviour); }
public static void AddItem(ComponentBehaviour behaviour) { instance.AddItemToArray(behaviour); }