Esempio n. 1
0
        internal void Step(CallStack callstack)
        {
            _stepWatch.Stop();

            var stack = new string[callstack.elements.Count];

            for (int i = 0; i < stack.Length; i++)
            {
                var    objPath          = callstack.elements[i].currentPointer.path;
                string stackElementName = "";

                for (int c = 0; c < objPath.length; c++)
                {
                    var comp = objPath.GetComponent(c);
                    if (!comp.isIndex)
                    {
                        stackElementName = comp.name;
                        break;
                    }
                }

                stack[i] = stackElementName;
            }

            _currStepStack = stack;

            var currObj = callstack.currentElement.currentPointer.Resolve();

            string stepType           = null;
            var    controlCommandStep = currObj as ControlCommand;

            if (controlCommandStep)
            {
                stepType = controlCommandStep.commandType.ToString() + " CC";
            }
            else
            {
                stepType = currObj.GetType().Name;
            }

            _currStepDetails = new StepDetails {
                type = stepType,
                obj  = currObj
            };

            _stepWatch.Start();
        }
        internal void StartExternalFunctionEvaluation(Container funcContainer, params object[] arguments)
        {
            // We'll start a new callstack, so keep hold of the original,
            // as well as the evaluation stack so we know if the function
            // returned something
            _originalCallstack             = callStack;
            _originalEvaluationStackHeight = evaluationStack.Count;

            // Create a new base call stack element.
            callStack = new CallStack(funcContainer);
            callStack.currentElement.type = PushPopType.Function;

            // Change the callstack the variableState is looking at to be
            // this temporary function evaluation one. We'll restore it afterwards
            variablesState.callStack = callStack;

            // By setting ourselves in external function evaluation mode,
            // we're saying it's okay to end the flow without a Done or End,
            // but with a ~ return instead.
            _isExternalFunctionEvaluation = true;

            PassArgumentsToEvaluationStack(arguments);
        }
Esempio n. 3
0
        internal StoryState(Story story)
        {
            this.story = story;

            _outputStream = new List<Runtime.Object> ();

            evaluationStack = new List<Runtime.Object> ();

            callStack = new CallStack (story.rootContentContainer);
            variablesState = new VariablesState (callStack);

            visitCounts = new Dictionary<string, int> ();
            turnIndices = new Dictionary<string, int> ();
            currentTurnIndex = -1;

            // Seed the shuffle random numbers
            int timeSeed = DateTime.Now.Millisecond;
            storySeed = (new Random (timeSeed)).Next () % 100;

            currentChoices = new List<Choice> ();

            GoToStart();
        }
Esempio n. 4
0
        internal StoryState(Story story)
        {
            this.story = story;

            _outputStream = new List <Runtime.Object> ();

            evaluationStack = new List <Runtime.Object> ();

            callStack      = new CallStack(story.rootContentContainer);
            variablesState = new VariablesState(callStack);

            visitCounts      = new Dictionary <string, int> ();
            turnIndices      = new Dictionary <string, int> ();
            currentTurnIndex = -1;

            // Seed the shuffle random numbers
            int timeSeed = DateTime.Now.Millisecond;

            storySeed = (new Random(timeSeed)).Next() % 100;

            currentChoices = new List <Choice> ();

            GoToStart();
        }
Esempio n. 5
0
 internal VariablesState(CallStack callStack, ListDefinitionsOrigin listDefsOrigin)
 {
     _globalVariables = new Dictionary <string, Object> ();
     _callStack       = callStack;
     _listDefsOrigin  = listDefsOrigin;
 }
Esempio n. 6
0
 internal VariablesState(CallStack callStack)
 {
     _globalVariables = new Dictionary <string, Object> ();
     _callStack       = callStack;
 }
Esempio n. 7
0
        internal void StartExternalFunctionEvaluation (Container funcContainer, params object[] arguments)
        {
            // We'll start a new callstack, so keep hold of the original,
            // as well as the evaluation stack so we know if the function 
            // returned something
            _originalCallstack = callStack;
            _originalEvaluationStackHeight = evaluationStack.Count;

            // Create a new base call stack element.
            callStack = new CallStack (funcContainer);
            callStack.currentElement.type = PushPopType.Function;

            // By setting ourselves in external function evaluation mode,
            // we're saying it's okay to end the flow without a Done or End,
            // but with a ~ return instead.
            _isExternalFunctionEvaluation = true;

            // Pass arguments onto the evaluation stack
            if (arguments != null) {
                for (int i = 0; i < arguments.Length; i++) {
                    if (!(arguments [i] is int || arguments [i] is float || arguments [i] is string)) {
                        throw new System.ArgumentException ("ink arguments when calling EvaluateFunction must be int, float or string");
                    }

                    evaluationStack.Add (Runtime.Value.Create (arguments [i]));
                }
            }
        }
Esempio n. 8
0
 public CallStack(CallStack toCopy)
 {
     _threads = new List<Thread> ();
     foreach (var otherThread in toCopy._threads) {
         _threads.Add (otherThread.Copy ());
     }
 }