Beispiel #1
0
        /// <summary>
        /// Reads ASCII encoded AICharacters into this collection from the given stream
        /// </summary>
        /// <param name="replaceExisting">Set to true to overwrite AICharacters which already exist in this collection. </param>
        public void Read(Stream stream, bool replaceExisting)
        {
            using (AIReader air = new AIReader(stream))
            {
                var readHeader = air.Read <AIFileHeader>();
                if (readHeader != null)
                {
                    this.header = readHeader;
                }

                air.Reset(); // for the case that the header was in the middle or not there at all

                AICharacter aic;
                while ((aic = air.Read <AICharacter>()) != null)
                {
                    if (this.ContainsKey(aic.Index))
                    {
                        if (replaceExisting)
                        {
                            this[aic.Index] = aic;
                        }
                        else
                        {
                            throw new Exception(aic.Index + " does already exist in this collection!");
                        }
                    }
                    else
                    {
                        this.Add(aic.Index, aic);
                    }
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Reads ASCII encoded AICharacters into this collection from the given stream
 /// </summary>
 /// <param name="replaceExisting">Set to true to overwrite AICharacters which already exist in this collection. </param>
 public void Read(Stream stream, bool replaceExisting)
 {
     using (AIReader air = new AIReader(stream))
     {
         AICharacter aic;
         while ((aic = air.Read <AICharacter>()) != null)
         {
             if (this.ContainsKey(aic.Index))
             {
                 if (replaceExisting)
                 {
                     this[aic.Index] = aic;
                 }
                 else
                 {
                     throw new Exception(aic.Index + " does already exist in this collection!");
                 }
             }
             else
             {
                 this.Add(aic.Index, aic);
             }
         }
     }
 }