Esempio n. 1
0
        public Array_Structure AddWrapperArray(MetaWrapper[] items)
        {
            if ((items == null) || (items.Length == 0))
            {
                return(new Array_Structure());
            }

            var sa = new Array_Structure();

            sa.Count1 = (ushort)items.Length;
            sa.Count2 = sa.Count1;
            for (int i = 0; i < items.Length; i++)
            {
                var item  = items[i];
                var meptr = item.Save(this);
                if (i == 0)
                {
                    MetaBuilderPointer mbp = new MetaBuilderPointer();
                    mbp.BlockID = meptr.BlockID;
                    mbp.Offset  = meptr.Offset;
                    sa.Pointer  = mbp.Pointer;
                }
            }
            return(sa);
        }
Esempio n. 2
0
 public static T[] GetItemArrayRaw <T>(PsoFile pso, Array_Structure arr) where T : struct
 {
     if ((arr.Count1 > 0) && (arr.Pointer > 0))
     {
         var entry = pso.DataMapSection.Entries[(int)arr.PointerDataIndex];
         return(ConvertDataArrayRaw <T>(pso.DataSection.Data, entry.Offset, arr.Count1));
     }
     return(null);
 }
Esempio n. 3
0
 public static ushort[] GetUShortArray(PsoFile pso, Array_Structure arr)
 {
     ushort[] ushorts = GetUShortArrayRaw(pso, arr);
     if (ushorts == null)
     {
         return(null);
     }
     for (int i = 0; i < ushorts.Length; i++)
     {
         ushorts[i] = MetaTypes.SwapBytes(ushorts[i]);
     }
     return(ushorts);
 }
Esempio n. 4
0
        public static ushort[] GetUShortArrayRaw(PsoFile pso, Array_Structure arr)
        {
            byte[] data    = pso.DataSection.Data;
            var    entryid = arr.Pointer & 0xFFF;

            if ((entryid == 0) || (entryid > pso.DataMapSection.EntriesCount))
            {
                return(null);
            }
            var entryoffset = (arr.Pointer & 0xFFFFFF) >> 12;
            var arrentry    = pso.DataMapSection.Entries[(int)entryid - 1];
            int totoffset   = arrentry.Offset + (int)entryoffset;

            ushort[] readdata = ConvertDataArrayRaw <ushort>(data, totoffset, arr.Count1);
            return(readdata);
        }
Esempio n. 5
0
 public static T[] GetItemArray <T>(PsoFile pso, Array_Structure arr) where T : struct, IPsoSwapEnd
 {
     if ((arr.Count1 > 0) && (arr.Pointer > 0))
     {
         var entry = pso.DataMapSection.Entries[(int)arr.PointerDataIndex];
         var res   = ConvertDataArrayRaw <T>(pso.DataSection.Data, entry.Offset, arr.Count1);
         if (res != null)
         {
             for (int i = 0; i < res.Length; i++)
             {
                 res[i].SwapEnd();
             }
         }
         return(res);
     }
     return(null);
 }
Esempio n. 6
0
 public static T[] GetObjectArray <T, U>(PsoFile pso, Array_Structure arr) where U : struct, IPsoSwapEnd where T : PsoClass <U>, new()
 {
     U[] items = GetItemArray <U>(pso, arr);
     if (items == null)
     {
         return(null);
     }
     if (items.Length == 0)
     {
         return(null);
     }
     T[] result = new T[items.Length];
     for (int i = 0; i < items.Length; i++)
     {
         T newitem = new T();
         newitem.Init(pso, ref items[i]);
         result[i] = newitem;
     }
     return(result);
 }