Esempio n. 1
0
        /// <summary>
        /// Parses a blueprint from the specified stream, registering all EntityBlueprints contained by the Stream (and replacing any existing data for them).
        /// The stream is not closed upon completion, and may have multiple EntityBlueprints defined within it.
        /// </summary>
        public static void ParseBlueprint(string Contents)
        {
            LineReader Reader = new LineReader(Contents.Split(new char[] { '\r', '\n' }));

            while (GetNextScope(Reader) != LineScope.EndOfFile)
            {
                // Parse the Entity header, such as name and what it inherits.
                BlueprintHeader Header = ParseHeader(Reader);
                // Parse all components, including properties.
                List <ComponentBlueprint> Components = new List <ComponentBlueprint>();
                while (GetNextScope(Reader) == LineScope.Component)
                {
                    var CurrentComponent = ParseComponentHeader(Reader);
                    List <ComponentProperty> Properties = new List <ComponentProperty>();
                    while (GetNextScope(Reader) == LineScope.Property)
                    {
                        var Property = ParseProperty(CurrentComponent, Reader);
                        Properties.Add(Property);
                    }
                    Type ComponentType      = ResolveType(CurrentComponent.Type);
                    var  ComponentBlueprint = new ComponentBlueprint(ComponentType, CurrentComponent.Name, Properties);
                    Components.Add(ComponentBlueprint);
                }

                ApplyInheritance(Header, Components);
                var Entity = EntityBlueprint.CreateBlueprint(Header.Name, Components);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Parses a blueprint from the specified stream, registering all EntityBlueprints contained by the Stream (and replacing any existing data for them).
        /// The stream is not closed upon completion, and may have multiple EntityBlueprints defined within it.
        /// </summary>
        public static void ParseBlueprint(string Contents)
        {
            LineReader Reader = new LineReader(Contents.Split(new char[] { '\r', '\n' }));
            while(GetNextScope(Reader) != LineScope.EndOfFile) {
                // Parse the Entity header, such as name and what it inherits.
                BlueprintHeader Header = ParseHeader(Reader);
                // Parse all components, including properties.
                List<ComponentBlueprint> Components = new List<ComponentBlueprint>();
                while(GetNextScope(Reader) == LineScope.Component) {
                    var CurrentComponent = ParseComponentHeader(Reader);
                    List<ComponentProperty> Properties = new List<ComponentProperty>();
                    while(GetNextScope(Reader) == LineScope.Property) {
                        var Property = ParseProperty(CurrentComponent, Reader);
                        Properties.Add(Property);
                    }
                    Type ComponentType = ResolveType(CurrentComponent.Type);
                    var ComponentBlueprint = new ComponentBlueprint(ComponentType, CurrentComponent.Name, Properties);
                    Components.Add(ComponentBlueprint);
                }

                ApplyInheritance(Header, Components);
                var Entity = EntityBlueprint.CreateBlueprint(Header.Name, Components);
            }
        }