public void ReadObjects(string fileName)
 {
     MappedObjectData.Clear();
     MappedObjects.Clear();
     for (var i = 0; i < Count; i++)
     {
         var dataBytes    = new byte[DataLength];
         var objectOffset = Offset + (i * Size);
         using (var fs = File.OpenRead(fileName))
         {
             fs.Seek(objectOffset, SeekOrigin.Begin);
             fs.Read(dataBytes, 0, DataLength);
         }
         Type type         = typeof(T);
         var  ctor         = type.GetConstructor(new[] { typeof(byte[]), typeof(long) });
         var  mappedObject = (T)ctor.Invoke(new object[] { dataBytes, objectOffset });
         if (mappedObject.Id == -1)
         {
             mappedObject.Id = i;
         }
         if (MappedObjectData.ContainsKey(mappedObject.Id))
         {
             MappedObjectData[mappedObject.Id].AddOffset(objectOffset, dataBytes);
         }
         else
         {
             MappedObjectData.Add(mappedObject.Id, mappedObject);
             MappedObjects.Add(mappedObject);
         }
     }
 }
 public T GetMappedObject(int id)
 {
     if (MappedObjectData.ContainsKey(id))
     {
         return(MappedObjectData[id]);
     }
     return(null);
 }
        internal void SetEnemyNames()
        {
            var enemyNames = Properties.Resources.EnemyNames.Split('\n');

            for (int i = 0; i < enemyNames.Length; i++)
            {
                if (MappedObjectData.ContainsKey(i))
                {
                    MappedObjectData[i].Name = enemyNames[i].Replace("\r", "").Trim();
                }
            }
        }
Ejemplo n.º 4
0
 public MappedFile (MappedObjectData data, IMetaDataStorage storage, IFileSystemInfoFactory fsFactory = null)
     : base(data, storage, fsFactory)
 {
 }
 public void AddMappedObject(T mappedObject)
 {
     MappedObjectData.Add(mappedObject.Id, mappedObject);
     MappedObjects.Add(mappedObject);
 }
Ejemplo n.º 6
0
 public MappedFile(MappedObjectData data, IMetaDataStorage storage, IFileSystemInfoFactory fsFactory = null)
     : base(data, storage, fsFactory)
 {
 }