Example #1
0
 private void AddEntryToDict(FATEntry entry)
 {
     FATEntry.Type entryType = entry.EntryType;
     if (!entriesDict.ContainsKey(entryType))
     {
         entriesDict[entryType] = new Dictionary <ushort, FATEntry>();
     }
     entriesDict[entryType][entry.index] = entry;
 }
Example #2
0
        public static FATEntry Read(Reader reader, Pointer offset)
        {
            FATEntry entry = new FATEntry();

            entry.offset   = offset;
            entry.off_data = reader.ReadUInt32();
            entry.type     = reader.ReadUInt16();
            entry.index    = reader.ReadUInt16();
            return(entry);
        }
Example #3
0
 public void ReadEntries(Reader reader)
 {
     entries = new FATEntry[num_entries];
     Pointer.DoAt(ref reader, off_table, () => {
         for (int i = 0; i < entries.Length; i++)
         {
             entries[i] = FATEntry.Read(reader, Pointer.Current(reader));
             entries[i].entryIndexWithinTable = (uint)i;
             AddEntryToDict(entries[i]);
         }
     });
 }
Example #4
0
        public Type Resolve(Reader reader)
        {
            if (this.type == 0xFFFF)
            {
                return(null);
            }
            R2ROMLoader l = MapLoader.Loader as R2ROMLoader;

            FATEntry.Type entryType = FATEntry.GetEntryType(this.type);
            System.Type   type      = null;
            foreach (KeyValuePair <System.Type, FATEntry.Type> typePair in FATEntry.types)
            {
                if (typePair.Value == entryType)
                {
                    type = typePair.Key;
                    break;
                }
            }
            ushort index = forceFix ? (ushort)(this.index | (ushort)FATEntry.Flag.Fix) : this.index;

            switch (entryType)
            {
            case FATEntry.Type.GeometricElementTriangles:
                Value = l.GetOrRead <GeometricObjectElementTriangles>(reader, index);
                break;

            case FATEntry.Type.GeometricElementSprites:
                Value = l.GetOrRead <GeometricObjectElementSprites>(reader, index);
                break;

            case FATEntry.Type.VisualMaterial:
                Value = l.GetOrRead <VisualMaterial>(reader, index);
                break;

            case FATEntry.Type.GeometricElementCollideTriangles:
                Value = l.GetOrRead <GeometricObjectElementCollideTriangles>(reader, index);
                break;

            case FATEntry.Type.GeometricElementCollideAlignedBoxes:
                Value = l.GetOrRead <GeometricObjectElementCollideAlignedBoxes>(reader, index);
                break;

            case FATEntry.Type.GeometricElementCollideSpheres:
                Value = l.GetOrRead <GeometricObjectElementCollideSpheres>(reader, index);
                break;

            case FATEntry.Type.GameMaterial:
                Value = l.GetOrRead <GameMaterial>(reader, index);
                break;

            case FATEntry.Type.PhysicalObject:
                Value = l.GetOrRead <PhysicalObject>(reader, index);
                break;

            case FATEntry.Type.Sector:
                Value = l.GetOrRead <Sector>(reader, index);
                break;

            default:
                UnityEngine.Debug.LogWarning("GenericReference: Unsupported struct with type " + entryType + "(" + this.type + ")");
                break;
            }
            return(type);
        }