// The game doesn't load FsmFloats at the same time as gameobjects so sometimes you have to wait a little bit // to get the float values. private IEnumerator _WaitForWaitTimeToBeLoaded(WaitData inputData) { while (inputData.CachedWait.time.Value <= epsilon) { yield return(null); } inputData.SetDefaultWaitTime(inputData.CachedWait.time.Value); speedModifyWaits.Add(inputData); if (active && speedModActive) { _UpdateSingleWait(inputData); } }
// Adds a Wait to the list, stored in the struct format WaitData. Use a constructor to build it. public void AddWaitData(WaitData inputData) { if (inputData.CustomGameObject == null) { inputData.CustomGameObject = gameObject; } if (inputData.CachedWait == null) { inputData.CachedWait = _getOrCacheFSMWait(inputData.FSMStateName, inputData.FSMName, inputData.CustomGameObject, inputData.ElementIndex); } if (inputData.CachedWait == null) { throw new System.NullReferenceException("No Wait Action found on the FSM " + inputData.FSMName + " in state " + inputData.FSMStateName); } float tVal = inputData.CachedWait.time.Value; if (tVal <= epsilon) { StartCoroutine(_WaitForWaitTimeToBeLoaded(inputData)); } else { inputData.SetDefaultWaitTime(tVal); speedModifyWaits.Add(inputData); if (active && speedModActive) { _UpdateSingleWait(inputData); } } }