Ink.Parsed.Weave.GenerateRuntimeObject C# (CSharp) Method

GenerateRuntimeObject() public method

public GenerateRuntimeObject ( ) : Runtime.Object
return Runtime.Object
        public override Runtime.Object GenerateRuntimeObject ()
        {
            _rootContainer = currentContainer = new Runtime.Container();
            looseEnds = new List<Parsed.Object> ();

            gatherPointsToResolve = new List<GatherPointToResolve> ();

            // Iterate through content for the block at this level of indentation
            //  - Normal content is nested under Choices and Gathers
            //  - Blocks that are further indented cause recursion
            //  - Keep track of loose ends so that they can be diverted to Gathers
            foreach(var obj in content) {

                // Choice or Gather
                if (obj is IWeavePoint) {
                    AddRuntimeForWeavePoint ((IWeavePoint)obj);
                } 

                // Non-weave point
                else {

                    // Nested weave
                    if (obj is Weave) {
                        var weave = (Weave)obj;
                        AddRuntimeForNestedWeave (weave);
                        gatherPointsToResolve.AddRange (weave.gatherPointsToResolve);
                    }

                    // Other object
                    // May be complex object that contains statements - e.g. a multi-line conditional
                    else {

                        // Find any nested explicit gather points within this object
                        // (including the object itself)
                        // i.e. instances of "->" without a target that's meant to go 
                        // to the next gather point.
                        var innerExplicitGathers = obj.FindAll<Divert> (d => d.isToGather);
                        if (innerExplicitGathers.Count > 0)
                            looseEnds.AddRange (innerExplicitGathers.ToArray());

                        // Add content
                        AddGeneralRuntimeContent (obj.runtimeObject);
                    }

                    // Keep track of nested choices within this (possibly complex) object,
                    // so that the next Gather knows whether to auto-enter
                    // (it auto-enters when there are no choices)
                    var innerChoices = obj.FindAll<Choice> ();
                    if (innerChoices.Count > 0)
                        hasSeenChoiceInSection = true;

                }
            }

            // Pass any loose ends up the hierarhcy
            PassLooseEndsToAncestors();

            return _rootContainer;
        }