Exemplo n.º 1
0
        private void DoMethodCall()
        {
            if (behaviour.Value == null)
            {
                Finish();
                return;
            }

            if (NeedToUpdateCache())
            {
                if (!DoCache())
                {
                    Debug.LogError(errorString);
                    Finish();
                    return;
                }
            }

            object result;

            if (cachedParameterInfo.Length == 0)
            {
                result = cachedMethodInfo.Invoke(cachedBehaviour.Value, null);
            }
            else
            {
                for (var i = 0; i < parameters.Length; i++)
                {
                    var parameter = parameters[i];
                    parameter.UpdateValue();
                    if (parameter.Type == VariableType.Array)
                    {
                        parameter.UpdateValue();
                        var objectArray    = parameter.GetValue() as object[];
                        var realType       = cachedParameterInfo[i].ParameterType.GetElementType();
                        var convertedArray = Array.CreateInstance(realType, objectArray.Length);
                        for (int index = 0; index < objectArray.Length; index++)
                        {
                            convertedArray.SetValue(objectArray[index], index);
                        }
                        parametersArray[i] = convertedArray;
                    }
                    else
                    {
                        parameter.UpdateValue();
                        parametersArray[i] = parameter.GetValue();
                    }
                }

                result = cachedMethodInfo.Invoke(cachedBehaviour.Value, parametersArray);
            }

            if (storeResult != null && !storeResult.IsNone && storeResult.Type != VariableType.Unknown)
            {
                storeResult.SetValue(result);
            }
        }
Exemplo n.º 2
0
        private void DoGetRandomValue()
        {
            if (storeValue.IsNone)
            {
                return;
            }

            storeValue.SetValue(array.Get(Random.Range(0, array.Length)));
        }
Exemplo n.º 3
0
        public override void OnEnter()
        {
            if (SceneState.instance != null)
            {
                if (toValue.Type == VariableType.Int)
                {
                    toValue.SetValue(global ? SceneState.instance.GetGlobalValue(name.Value) : SceneState.instance.GetValue(name.Value));
                }
                else if (toValue.Type == VariableType.Float)
                {
                    toValue.SetValue(global ? SceneState.instance.GetGlobalValueFloat(name.Value) : SceneState.instance.GetValueFloat(name.Value));
                }
            }

            if (!everyFrame)
            {
                Finish();
            }
        }
Exemplo n.º 4
0
        private void DoMethodCall()
        {
            if (className == null || string.IsNullOrEmpty(className.Value))
            {
                Finish();
                return;
            }

            if (cachedClassName != className.Value || cachedMethodName != methodName.Value)
            {
                errorString = string.Empty;
                if (!DoCache())
                {
                    Debug.LogError(errorString);
                    Finish();
                    return;
                }
            }

            object result = null;

            if (cachedParameterInfo.Length == 0)
            {
                result = cachedMethodInfo.Invoke(null, null);
            }
            else
            {
                for (var i = 0; i < parameters.Length; i++)
                {
                    var parameter = parameters[i];
                    parameter.UpdateValue();
                    parametersArray[i] = parameter.GetValue();
                }

                result = cachedMethodInfo.Invoke(null, parametersArray);
            }

            if (!storeResult.IsNone)
            {
                storeResult.SetValue(result);
            }

                        #if UNITY_EDITOR
            if (debug || LinkerData.DebugAll)
            {
                UnityEngine.Debug.Log("<Color=blue>CallStaticMethod</Color> on " + this.Fsm.GameObjectName + ":" + this.Fsm.Name + "\n" +
                                      "<Color=red>TargetType</Color>\t\t" + cachedType + "\n" +
                                      "<Color=red>Assembly</Color>\t\t" + cachedType.Assembly.FullName + "\n" +
                                      "<Color=red>Method</Color>\t\t\t" + cachedMethodInfo.Name + "\n");

                LinkerData.RegisterClassDependancy(cachedType, cachedType.ToString());
            }
                        #endif
        }
Exemplo n.º 5
0
 private void DoStartFsm()
 {
     storeItem.SetValue(array.Values[currentIndex]);
     fsmTemplateControl.UpdateValues();
     fsmTemplateControl.ApplyOverrides(runFsm);
     runFsm.OnEnable();
     if (!runFsm.Started)
     {
         runFsm.Start();
     }
 }
Exemplo n.º 6
0
        private void DoMethodCall()
        {
            if (behaviour.Value == null)
            {
                Finish();
                return;
            }
            if (NeedToUpdateCache() && !DoCache())
            {
                Debug.LogError(errorString);
                Finish();
                return;
            }
            object value;

            if (cachedParameterInfo.Length == 0)
            {
                value = cachedMethodInfo.Invoke(cachedBehaviour.Value, null);
            }
            else
            {
                for (int i = 0; i < parameters.Length; i++)
                {
                    FsmVar fsmVar = parameters[i];
                    fsmVar.UpdateValue();
                    if (fsmVar.Type == VariableType.Array)
                    {
                        fsmVar.UpdateValue();
                        object[] array       = fsmVar.GetValue() as object[];
                        Type     elementType = cachedParameterInfo[i].ParameterType.GetElementType();
                        Array    array2      = Array.CreateInstance(elementType, array.Length);
                        for (int j = 0; j < array.Length; j++)
                        {
                            array2.SetValue(array[j], j);
                        }
                        parametersArray[i] = array2;
                    }
                    else
                    {
                        fsmVar.UpdateValue();
                        parametersArray[i] = fsmVar.GetValue();
                    }
                }
                value = cachedMethodInfo.Invoke(cachedBehaviour.Value, parametersArray);
            }
            if (storeResult != null && !storeResult.IsNone && storeResult.Type != VariableType.Unknown)
            {
                storeResult.SetValue(value);
            }
        }
Exemplo n.º 7
0
 private void DoGetValue()
 {
     if (!array.IsNone && !storeValue.IsNone)
     {
         if (index.Value >= 0 && index.Value < array.Length)
         {
             storeValue.SetValue(array.Get(index.Value));
         }
         else
         {
             base.Fsm.Event(indexOutOfRange);
         }
     }
 }
Exemplo n.º 8
0
        void DoCheck()
        {
            var sceneState = global.Value ? SceneState.instance.global : SceneState.instance.local;

            switch (toValue.Type)
            {
            case VariableType.Int:
                toValue.SetValue(sceneState.GetValue(name.Value));
                break;

            case VariableType.Float:
                toValue.SetValue(sceneState.GetValueFloat(name.Value));
                break;

            case VariableType.String:
                toValue.SetValue(sceneState.GetValueString(name.Value));
                break;

            case VariableType.Bool:
                toValue.SetValue(sceneState.GetValue(name.Value) != 0);
                break;
            }
        }
        void ggop()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (!UpdateCache(go, fsmName.Value))
            {
                return;
            }

            var fsmArray = fsm.FsmVariables.GetFsmArray(variableName.Value);



            if (nextItemIndex >= fsmArray.Length)
            {
                nextItemIndex      = 0;
                currentIndex.Value = fsmArray.Length - 1;
                Fsm.Event(finishedEvent);
                return;
            }


            result.SetValue(fsmArray.Get(nextItemIndex));

            if (nextItemIndex >= fsmArray.Length)
            {
                nextItemIndex      = 0;
                currentIndex.Value = fsmArray.Length - 1;
                Fsm.Event(finishedEvent);
                return;
            }

            if (endIndex.Value > 0 && nextItemIndex >= endIndex.Value)
            {
                nextItemIndex      = 0;
                currentIndex.Value = endIndex.Value;
                Fsm.Event(finishedEvent);
                return;
            }

            nextItemIndex++;

            currentIndex.Value = nextItemIndex - 1;

            if (loopEvent != null)
            {
                Fsm.Event(loopEvent);
            }
        }
Exemplo n.º 10
0
        public override void OnEnter()
        {
            string luaCodeString = (luaCode != null) ? luaCode.Value : string.Empty;
            bool   debugFlag     = (debug != null) ? debug.Value : false;

            Lua.Result luaResult = Lua.Run(luaCodeString, debugFlag);
            if ((storeResult != null) && storeResult.useVariable)
            {
                switch (storeResult.Type)
                {
                case VariableType.Bool:
                    storeResult.SetValue(luaResult.AsBool);
                    break;

                case VariableType.Float:
                    storeResult.SetValue(luaResult.AsFloat);
                    break;

                case VariableType.Int:
                    storeResult.SetValue(luaResult.AsInt);
                    break;

                case VariableType.String:
                    storeResult.SetValue(luaResult.AsString);
                    break;

                default:
                    if (DialogueDebug.LogWarnings)
                    {
                        Debug.LogWarning(string.Format("{0}: Variable type must be Bool, Float, Int, or String for Lua code '{1}'", DialogueDebug.Prefix, luaCode));
                    }
                    break;
                }
            }
            Finish();
        }
Exemplo n.º 11
0
        void ggop()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (!UpdateCache(go, fsmName.Value))
            {
                return;
            }

            var fsmArray = fsm.FsmVariables.GetFsmArray(variableName.Value);

            randomIndex = Random.Range(0, fsmArray.Length);
            index.Value = randomIndex;
            storeValue.SetValue(fsmArray.Get(index.Value));
        }
Exemplo n.º 12
0
        public void DoesArrayListContains()
        {
            if (!isProxyValid())
            {
                return;
            }

            int i = 0;

            foreach (var item in proxy.arrayList)
            {
                string itemName = item.ToString();

                //remove any object type inside the item name
                if (itemName.Contains(" ("))
                {
                    itemName = itemName.Substring(0, itemName.IndexOf(" ("));
                }

                bool containsName = !contains.Value ? itemName == variableName.Value
                                                                                                                                                                     : itemName.Contains(variableName.Value);

                if (containsName)
                {
                    if (!storeFoundResult.IsNone)
                    {
                        storeFoundResult.UpdateValue();

                        if (storeFoundResult.ObjectType != item.GetType())
                        {
                            LogError("Found ArrayList item isn't of type " + storeFoundResult.Type + "! Please change the Object type of '" + storeFoundResult.variableName + "' in the Variables tab to " + item.GetType() + ".");
                        }

                        storeFoundResult.SetValue(item);
                    }

                    if (!indexOf.IsNone)
                    {
                        indexOf.Value = i;
                    }

                    Fsm.Event(itemFoundEvent);
                }
                i++;
            }

            Fsm.Event(itemNotFoundEvent);
        }
Exemplo n.º 13
0
        void DoGetNextItem()
        {
            // no more children?
            // check first to avoid errors.

            if (nextItemIndex >= array.Length)
            {
                nextItemIndex      = 0;
                currentIndex.Value = array.Length - 1;
                Fsm.Event(finishedEvent);
                return;
            }

            // get next item

            result.SetValue(array.Get(nextItemIndex));

            // no more items?
            // check a second time to avoid process lock and possible infinite loop if the action is called again.
            // Practically, this enabled calling again this state and it will start again iterating from the first child.

            if (nextItemIndex >= array.Length)
            {
                nextItemIndex      = 0;
                currentIndex.Value = array.Length - 1;
                Fsm.Event(finishedEvent);
                return;
            }

            if (endIndex.Value > 0 && nextItemIndex >= endIndex.Value)
            {
                nextItemIndex      = 0;
                currentIndex.Value = endIndex.Value;
                Fsm.Event(finishedEvent);
                return;
            }

            // iterate the next child
            nextItemIndex++;

            currentIndex.Value = nextItemIndex - 1;

            if (loopEvent != null)
            {
                Fsm.Event(loopEvent);
            }
        }
        private void ExecuteAction()
        {
            if (array.IsNone)
            {
                return;
            }

            if (!storeValue.IsNone)
            {
                storeValue.SetValue(array.Get(array.Length - 1));
            }

            if (!storeIndex.IsNone)
            {
                storeIndex.Value = array.Length - 1;
            }
        }
Exemplo n.º 15
0
        private void DoGetValue()
        {
            if (array.IsNone || storeValue.IsNone)
            {
                return;
            }

            if (index.Value >= 0 && index.Value < array.Length)
            {
                storeValue.SetValue(array.Get(index.Value));
            }
            else
            {
                //LogError("Index out of Range: " + index.Value);
                Fsm.Event(indexOutOfRange);
            }
        }
        private void DoGetRandomValue()
        {
            if (storeValue.IsNone)
            {
                return;
            }

            int currItem = Random.Range(0, array.Length);

            if (!repeat.Value)
            {
                while (currItem == prevItem)
                {
                    currItem = Random.Range(0, array.Length);
                }
            }

            storeValue.SetValue(array.Get(currItem));
            prevItem = currItem;
        }
Exemplo n.º 17
0
        private void DoGetStaticValue()
        {
            if (className == null || string.IsNullOrEmpty(className.Value))
            {
                Finish();
                return;
            }

            if (cachedClassName != className.Value || cachedPropertyName != propertyName.Value)
            {
                errorString = string.Empty;
                if (!DoCache())
                {
                    Debug.LogError(errorString);
                    Finish();
                    return;
                }
            }
            propertyValue.SetValue(cachedFieldInfo.GetValue(null));
        }
Exemplo n.º 18
0
        private void DoMethodCall()
        {
            if (behaviour.Value == null)
            {
                Finish();
                return;
            }

            if (NeedToUpdateCache())
            {
                if (!DoCache())
                {
                    Debug.LogError(errorString);
                    Finish();
                    return;
                }
            }

            object result = null;

            if (cachedParameterInfo.Length == 0)
            {
                result = cachedMethodInfo.Invoke(cachedBehaviour.Value, null);
            }
            else
            {
                for (var i = 0; i < parameters.Length; i++)
                {
                    var parameter = parameters[i];
                    parameter.UpdateValue();
                    parametersArray[i] = parameter.GetValue();
                }

                result = cachedMethodInfo.Invoke(cachedBehaviour.Value, parametersArray);
            }

            if (!storeResult.IsNone)
            {
                storeResult.SetValue(result);
            }
        }
Exemplo n.º 19
0
        public override void OnEnter()
        {
            if (!status.IsNone)
            {
                status.Value = (Enum)Enum.ToObject(status.EnumType, LastStatus);
            }
            if (!statusAsInt.IsNone)
            {
                statusAsInt.Value = LastStatus;
            }

            if (!gotMessage.IsNone)
            {
                gotMessage.Value = LastGotMessage;
            }

            if (!message.IsNone)
            {
                if (message.Type == VariableType.Array)
                {
                    object[] _lastMessages = (object[])LastMessage;
                    if (_lastMessages != null)
                    {
                        PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, message, _lastMessages);
                    }
                }
                else
                {
                    message.SetValue(LastMessage);
                }
            }

            if (gotMessageEvent != null && LastGotMessage)
            {
                this.Fsm.Event(gotMessageEvent);
            }

            Finish();
        }
Exemplo n.º 20
0
        private void DoMethodCall()
        {
            if (className == null || string.IsNullOrEmpty(className.Value))
            {
                Finish();
                return;
            }

            if (cachedClassName != className.Value || cachedMethodName != methodName.Value)
            {
                errorString = string.Empty;
                if (!DoCache())
                {
                    Debug.LogError(errorString);
                    Finish();
                    return;
                }
            }

            object result = null;

            if (cachedParameterInfo.Length == 0)
            {
                result = cachedMethodInfo.Invoke(null, null);
            }
            else
            {
                for (var i = 0; i < parameters.Length; i++)
                {
                    var parameter = parameters[i];
                    parameter.UpdateValue();
                    parametersArray[i] = parameter.GetValue();
                }

                result = cachedMethodInfo.Invoke(null, parametersArray);
            }
            storeResult.SetValue(result);
        }
Exemplo n.º 21
0
        private void DoGetRandomValue()
        {
            if (storeValue.IsNone)
            {
                return;
            }

            if (!noRepeat.Value || array.Length == 1)
            {
                randomIndex = Random.Range(0, array.Length);
            }
            else
            {
                do
                {
                    randomIndex = Random.Range(0, array.Length);
                } while (randomIndex == lastIndex);

                lastIndex = randomIndex;
            }

            index.Value = randomIndex;
            storeValue.SetValue(array.Get(index.Value));
        }
Exemplo n.º 22
0
        private void DoMethodCall()
        {
            if (behaviour.Value == null)
            {
                Finish();
                return;
            }

            if (cachedBehaviour != behaviour.Value)
            {
                errorString = string.Empty;
                if (!DoCache())
                {
                    Debug.LogError(errorString);
                    Finish();
                    return;
                }
            }

            object result = null;

            if (cachedParameterInfo.Length == 0)
            {
                result = cachedMethodInfo.Invoke(cachedBehaviour, null);
            }
            else
            {
                for (var i = 0; i < parameters.Length; i++)
                {
                    parametersArray[i] = parameters[i].GetValue();
                }

                result = cachedMethodInfo.Invoke(cachedBehaviour, parametersArray);
            }
            storeResult.SetValue(result);
        }
        void DoInterpolate()
        {
            if (!mSegment.Spline.IsInitialized)
            {
                return;
            }
            bool calc = !Input.IsNone;

            if (calc)
            {
                System.Type metaType = System.Type.GetType(MetaDataType.Value);
                float       inputF   = (UseWorldUnits.Value) ? mSegment.DistanceToLocalF(Input.Value) : Input.Value;

                if (StorePosition.IsNone == false)
                {
                    StorePosition.Value = (UseCache.Value) ? mSegment.InterpolateFast(inputF) : mSegment.Interpolate(inputF);
                }

                if (StoreTangent.IsNone == false)
                {
                    StoreTangent.Value = mSegment.GetTangent(inputF);
                }

                if (StoreUpVector.IsNone == false)
                {
                    StoreUpVector.Value = mSegment.GetOrientationUpFast(inputF);
                }

                if (StoreRotation.IsNone == false)
                {
                    StoreRotation.Value = (StoreUpVector.IsNone) ? mSegment.GetOrientationFast(inputF) : Quaternion.LookRotation(mSegment.GetTangent(inputF), StoreUpVector.Value);
                }

                if (StoreScale.IsNone == false)
                {
                    CurvySplineSegment nextControlPoint = mSegment.Spline.GetNextControlPoint(mSegment);
                    StoreScale.Value = nextControlPoint
                        ? Vector3.Lerp(mSegment.transform.lossyScale, nextControlPoint.transform.lossyScale, inputF)
                        : mSegment.transform.lossyScale;
                }

                if (StoreTF.IsNone == false)
                {
                    StoreTF.Value = mSegment.LocalFToTF(inputF);
                }

                if (StoreSegmentDistance.IsNone == false)
                {
                    StoreSegmentDistance.Value = mSegment.LocalFToDistance(inputF);
                }

                if (StoreDistance.IsNone == false)
                {
                    StoreDistance.Value = (StoreSegmentDistance.IsNone == false) ? StoreSegmentDistance.Value + mSegment.Distance : mSegment.LocalFToDistance(inputF) + mSegment.Distance;
                }

                if (StoreSegmentF.IsNone == false)
                {
                    StoreSegmentF.Value = inputF;
                }

                if (metaType != null)
                {
                    if (metaType.IsSubclassOf(typeof(CurvyMetadataBase)) == false)
                    {
                        //this if statement's branch does not exclude classes inheriting from CurvyMetadataBase but not from CurvyInterpolatableMetadataBase, but that's ok, those classes are handled below
                        Debug.LogError("Meta data type " + metaType.FullName + " should be a subclass of CurvyInterpolatableMetadataBase<T>");
                    }
                    else
                    {
                        if (StoreMetadata.IsNone == false)
                        {
                            MethodInfo genericMethodInfo = mSegment.GetType().GetMethod("GetMetadata").MakeGenericMethod(metaType);
                            StoreMetadata.Value = (Object)genericMethodInfo.Invoke(mSegment, new System.Object[] { false });
                        }
                        if (StoreInterpolatedMetadata.IsNone == false)
                        {
                            Type argumentType = CurvyGetValue.GetInterpolatableMetadataGenericType(metaType);

                            if (argumentType == null)
                            {
                                Debug.LogError("Meta data type " + metaType.FullName + " should be a subclass of CurvyInterpolatableMetadataBase<T>");
                            }
                            else
                            {
                                MethodInfo genericMethodInfo = mSegment.GetType().GetMethod("GetInterpolatedMetadata").MakeGenericMethod(metaType, argumentType);
                                StoreInterpolatedMetadata.SetValue(genericMethodInfo.Invoke(mSegment, new System.Object[] { inputF }));
                            }
                        }
                    }
                }
            }
            // General
            if (StoreLength.IsNone == false)
            {
                StoreLength.Value = mSegment.Length;
            }

            if (StoreSegmentIndex.IsNone == false)
            {
                StoreSegmentIndex.Value = mSegment.Spline.GetSegmentIndex(mSegment);
            }
            if (StoreControlPointIndex.IsNone == false)
            {
                StoreControlPointIndex.Value = mSegment.Spline.GetControlPointIndex(mSegment);
            }
        }
Exemplo n.º 24
0
        void DoInterpolate()
        {
            if (!mSpline.IsInitialized)
            {
                return;
            }
            System.Type metaType = System.Type.GetType(MetaDataType.Value);
            bool        calc     = !Input.IsNone;

            if (calc)
            {
                float f = (UseWorldUnits.Value) ? mSpline.DistanceToTF(Input.Value) : Input.Value;

                if (StorePosition.UseVariable)
                {
                    StorePosition.Value = (UseCache.Value) ? mSpline.InterpolateFast(f) : mSpline.Interpolate(f);
                }

                if (StoreTangent.UseVariable)
                {
                    StoreTangent.Value = mSpline.GetTangent(f);
                }

                if (StoreUpVector.UseVariable)
                {
                    StoreUpVector.Value = mSpline.GetOrientationUpFast(f);
                }

                if (StoreRotation.UseVariable)
                {
                    StoreRotation.Value = (StoreUpVector.IsNone) ? mSpline.GetOrientationFast(f) : Quaternion.LookRotation(mSpline.GetTangent(f), StoreUpVector.Value);
                }

                if (StoreScale.UseVariable)
                {
                    StoreScale.Value = mSpline.InterpolateScale(f);
                }

                if (StoreTF.UseVariable)
                {
                    StoreTF.Value = f;
                }

                if (StoreDistance.UseVariable)
                {
                    StoreDistance.Value = (UseWorldUnits.Value) ? Input.Value : mSpline.TFToDistance(f);
                }
                if (metaType != null)
                {
                    if (StoreMetadata.UseVariable)
                    {
                        StoreMetadata.Value = mSpline.GetMetadata(metaType, f);
                    }
                    if (StoreInterpolatedMetadata.useVariable)
                    {
                        StoreInterpolatedMetadata.SetValue(mSpline.InterpolateMetadata(metaType, f));
                    }
                }


                CurvySplineSegment seg = null;
                float segF             = 0;
                if (StoreSegment.UseVariable)
                {
                    seg = getSegment(f, out segF);
                    StoreSegment.Value = seg.gameObject;
                }

                if (StoreSegmentF.UseVariable)
                {
                    if (!seg)
                    {
                        seg = getSegment(f, out segF);
                    }
                    StoreSegmentF.Value = segF;
                }

                if (StoreSegmentDistance.UseVariable)
                {
                    if (!seg)
                    {
                        seg = getSegment(f, out segF);
                    }
                    StoreSegmentDistance.Value = seg.LocalFToDistance(segF);
                }
            }
            // General
            if (StoreLength.UseVariable)
            {
                StoreLength.Value = mSpline.Length;
            }

            if (StoreCount.UseVariable)
            {
                StoreCount.Value = (mSpline is CurvySplineGroup) ? ((CurvySplineGroup)mSpline).Count : ((CurvySpline)mSpline).Count;
            }
        }
Exemplo n.º 25
0
 public override void Enter()
 {
     value.SetValue(es3Spreadsheet.GetCell <object>(col.Value, row.Value));
 }
Exemplo n.º 26
0
 public override void Enter()
 {
     value.SetValue(es3Spreadsheet.GetCell(value.RealType, col.Value, row.Value));
 }
        void DoInterpolate()
        {
            if (!mSegment.Spline.IsInitialized)
            {
                return;
            }
            bool calc = !Input.IsNone;

            if (calc)
            {
                System.Type metaType = System.Type.GetType(MetaDataType.Value);
                float       inputF   = (UseWorldUnits.Value) ? mSegment.DistanceToLocalF(Input.Value) : Input.Value;

                if (StorePosition.UseVariable)
                {
                    StorePosition.Value = (UseCache.Value) ? mSegment.InterpolateFast(inputF) : mSegment.Interpolate(inputF);
                }

                if (StoreTangent.UseVariable)
                {
                    StoreTangent.Value = mSegment.GetTangent(inputF);
                }

                if (StoreUpVector.UseVariable)
                {
                    StoreUpVector.Value = mSegment.GetOrientationUpFast(inputF);
                }

                if (StoreRotation.UseVariable)
                {
                    StoreRotation.Value = (StoreUpVector.IsNone) ? mSegment.GetOrientationFast(inputF) : Quaternion.LookRotation(mSegment.GetTangent(inputF), StoreUpVector.Value);
                }

                if (StoreScale.UseVariable)
                {
                    StoreScale.Value = mSegment.InterpolateScale(inputF);
                }

                if (StoreTF.UseVariable)
                {
                    StoreTF.Value = mSegment.LocalFToTF(inputF);
                }

                if (StoreSegmentDistance.UseVariable)
                {
                    StoreSegmentDistance.Value = mSegment.LocalFToDistance(inputF);
                }

                if (StoreDistance.UseVariable)
                {
                    StoreDistance.Value = (StoreSegmentDistance.UseVariable) ? StoreSegmentDistance.Value + mSegment.Distance : mSegment.LocalFToDistance(inputF) + mSegment.Distance;
                }

                if (StoreSegmentF.UseVariable)
                {
                    StoreSegmentF.Value = inputF;
                }

                if (metaType != null)
                {
                    if (StoreMetadata.UseVariable)
                    {
                        StoreMetadata.Value = mSegment.GetMetaData(metaType);
                    }
                    if (StoreInterpolatedMetadata.useVariable)
                    {
                        StoreInterpolatedMetadata.SetValue(mSegment.InterpolateMetadata(metaType, inputF));
                    }
                }
            }
            // General
            if (StoreLength.UseVariable)
            {
                StoreLength.Value = mSegment.Length;
            }

            if (StoreSegmentIndex.UseVariable)
            {
                StoreSegmentIndex.Value = mSegment.SegmentIndex;
            }
            if (StoreControlPointIndex.UseVariable)
            {
                StoreControlPointIndex.Value = mSegment.ControlPointIndex;
            }
        }
        void DoInterpolate()
        {
            if (!mSpline.IsInitialized)
            {
                return;
            }

            System.Type metaDataType;
            {
                if (String.IsNullOrEmpty(MetaDataType.Value))
                {
                    metaDataType = null;
                }
                else
                {
#if NETFX_CORE
                    Type[] knownTypes = this.GetType().GetAllTypes();
#else
                    Type[] knownTypes = TypeExt.GetLoadedTypes();
#endif
                    metaDataType = knownTypes.FirstOrDefault(t => t.FullName == MetaDataType.Value);
                }
            }

            bool calc = !Input.IsNone;
            if (calc)
            {
                float f = (UseWorldUnits.Value) ? mSpline.DistanceToTF(Input.Value) : Input.Value;

                if (StorePosition.IsNone == false)
                {
                    StorePosition.Value = (UseCache.Value) ? mSpline.InterpolateFast(f) : mSpline.Interpolate(f);
                }

                if (StoreTangent.IsNone == false)
                {
                    StoreTangent.Value = mSpline.GetTangent(f);
                }

                if (StoreUpVector.IsNone == false)
                {
                    StoreUpVector.Value = mSpline.GetOrientationUpFast(f);
                }

                if (StoreRotation.IsNone == false)
                {
                    StoreRotation.Value = (StoreUpVector.IsNone) ? mSpline.GetOrientationFast(f) : Quaternion.LookRotation(mSpline.GetTangent(f), StoreUpVector.Value);
                }

                if (StoreScale.IsNone == false)
                {
                    float localF;
                    CurvySplineSegment segment          = mSpline.TFToSegment(f, out localF);
                    CurvySplineSegment nextControlPoint = segment.Spline.GetNextControlPoint(segment);
                    if (ReferenceEquals(segment, null) == false)
                    {
                        StoreScale.Value = nextControlPoint
                            ? Vector3.Lerp(segment.transform.lossyScale, nextControlPoint.transform.lossyScale, localF)
                            : segment.transform.lossyScale;
                    }
                    else
                    {
                        StoreScale.Value = Vector3.zero;
                    }
                }

                if (StoreTF.IsNone == false)
                {
                    StoreTF.Value = f;
                }

                if (StoreDistance.IsNone == false)
                {
                    StoreDistance.Value = (UseWorldUnits.Value) ? Input.Value : mSpline.TFToDistance(f);
                }
                if (metaDataType != null)
                {
                    if (metaDataType.IsSubclassOf(typeof(CurvyMetadataBase)) == false)
                    {
                        //this if statement's branch does not exclude classes inheriting from CurvyMetadataBase but not from CurvyInterpolatableMetadataBase, but that's ok, those classes are handled below
                        Debug.LogError("Meta data type " + metaDataType.FullName + " should be a subclass of CurvyInterpolatableMetadataBase<T>");
                    }
                    else
                    {
                        if (StoreMetadata.IsNone == false)
                        {
                            MethodInfo genericMethodInfo = mSpline.GetType().GetMethod("GetMetadata").MakeGenericMethod(metaDataType);
                            StoreMetadata.Value = (Object)genericMethodInfo.Invoke(mSpline, new System.Object[] { f });
                        }
                        if (StoreInterpolatedMetadata.IsNone == false)
                        {
                            Type argumentType = GetInterpolatableMetadataGenericType(metaDataType);

                            if (argumentType == null)
                            {
                                Debug.LogError("Meta data type " + metaDataType.FullName + " should be a subclass of CurvyInterpolatableMetadataBase<T>");
                            }
                            else
                            {
                                MethodInfo genericMethodInfo = mSpline.GetType().GetMethod("GetInterpolatedMetadata").MakeGenericMethod(metaDataType, argumentType);
                                StoreInterpolatedMetadata.SetValue(genericMethodInfo.Invoke(mSpline, new System.Object[] { f }));
                            }
                        }
                    }
                }


                CurvySplineSegment seg = null;
                float segF             = 0;
                if (StoreSegment.IsNone == false)
                {
                    seg = getSegment(f, out segF);
                    StoreSegment.Value = seg.gameObject;
                }

                if (StoreSegmentF.IsNone == false)
                {
                    if (!seg)
                    {
                        seg = getSegment(f, out segF);
                    }
                    StoreSegmentF.Value = segF;
                }

                if (StoreSegmentDistance.IsNone == false)
                {
                    if (!seg)
                    {
                        seg = getSegment(f, out segF);
                    }
                    StoreSegmentDistance.Value = seg.LocalFToDistance(segF);
                }
            }
            // General
            if (StoreLength.IsNone == false)
            {
                StoreLength.Value = mSpline.Length;
            }

            if (StoreCount.IsNone == false)
            {
                StoreCount.Value = mSpline.Count;
            }
        }