LSLib.Granny.GR2.GR2Reader.ReadStructDefinition C# (CSharp) Méthode

ReadStructDefinition() public méthode

public ReadStructDefinition ( ) : StructDefinition
Résultat StructDefinition
        public StructDefinition ReadStructDefinition()
        {
            var defn = new StructDefinition();
            while (true)
            {
                var member = ReadMemberDefinition();
                if (member.IsValid)
                    defn.Members.Add(member);
                else
                    break;
            }

            return defn;
        }

Usage Example

Exemple #1
0
        public StructDefinition Resolve(GR2Reader gr2)
        {
            Debug.Assert(IsValid);
            // Type definitions use a 2-level cache
            // First we'll check the reference itself, if it has a cached ref to the resolved type
            // If it has, we have nothing to do

            // If the struct wasn't resolved yet, try the type definition cache
            // When a type definition is read from the GR2 file, it is stored here using its definition address as a key
            if (Type == null)
            {
                gr2.Types.TryGetValue(this, out Type);
            }

            if (Type == null)
            {
                // We haven't seen this type before, read its definition from the file and cache it
#if DEBUG_GR2_SERIALIZATION
                System.Console.WriteLine(String.Format(" ===== Struct definition at {0:X8} ===== ", Offset));
#endif
                var originalPos = gr2.Stream.Position;
                gr2.Seek(this);
                Type = gr2.ReadStructDefinition();
                gr2.Stream.Seek(originalPos, SeekOrigin.Begin);
                gr2.Types[this] = Type;
            }

            return(Type);
        }