Example #1
0
 public GameAssetType(WrathEdXML.AssetDefinition.GameAssetType asset)
     : base(asset)
 {
     if (asset.Entries != null)
     {
         Entries = new BaseEntryType[asset.Entries.Length];
         for (int idx = 0; idx < Entries.Length; ++idx)
         {
             Type entryType = asset.Entries[idx].GetType();
             if (entryType == typeof(WrathEdXML.AssetDefinition.EntryPoidType))
             {
                 Entries[idx] = new EntryPoidType(asset.Entries[idx] as WrathEdXML.AssetDefinition.EntryPoidType);
             }
             else if (entryType == typeof(WrathEdXML.AssetDefinition.EntryFileType))
             {
                 Entries[idx] = new EntryFileType(asset.Entries[idx] as WrathEdXML.AssetDefinition.EntryFileType);
             }
             else if (entryType == typeof(WrathEdXML.AssetDefinition.EntryReferenceType))
             {
                 Entries[idx] = new EntryReferenceType(asset.Entries[idx] as WrathEdXML.AssetDefinition.EntryReferenceType);
             }
             else if (entryType == typeof(WrathEdXML.AssetDefinition.EntryWeakReferenceType))
             {
                 Entries[idx] = new EntryWeakReferenceType(asset.Entries[idx] as WrathEdXML.AssetDefinition.EntryWeakReferenceType);
             }
             else if (entryType == typeof(WrathEdXML.AssetDefinition.EntryType))
             {
                 Entries[idx] = new EntryType(asset.Entries[idx] as WrathEdXML.AssetDefinition.EntryType);
             }
             else if (entryType == typeof(WrathEdXML.AssetDefinition.EntryRelocationType))
             {
                 Entries[idx] = new EntryRelocationType(asset.Entries[idx] as WrathEdXML.AssetDefinition.EntryRelocationType);
             }
             else if (entryType == typeof(WrathEdXML.AssetDefinition.EntryListType))
             {
                 Entries[idx] = new EntryListType(asset.Entries[idx] as WrathEdXML.AssetDefinition.EntryListType);
             }
             else if (entryType == typeof(WrathEdXML.AssetDefinition.EntryChoiceType))
             {
                 Entries[idx] = new EntryChoiceType(asset.Entries[idx] as WrathEdXML.AssetDefinition.EntryChoiceType);
             }
             else if (entryType == typeof(WrathEdXML.AssetDefinition.EntryInheritanceType))
             {
                 Entries[idx] = new EntryInheritanceType(asset.Entries[idx] as WrathEdXML.AssetDefinition.EntryInheritanceType);
             }
         }
     }
     if (asset.Runtime != null)
     {
         Runtime = new RuntimeType(asset.Runtime);
     }
     TypeHash = asset.TypeHash;
     HasSpecialCompileHandling = asset.HasSpecialCompileHandling;
 }
Example #2
0
 public AssetType(WrathEdXML.AssetDefinition.AssetType asset)
     : base(asset)
 {
     if (asset.Entries == null)
     {
         return;
     }
     Entries = new BaseEntryType[asset.Entries.Length];
     for (int idx = 0; idx < Entries.Length; ++idx)
     {
         Type entryType = asset.Entries[idx].GetType();
         if (entryType == typeof(WrathEdXML.AssetDefinition.EntryPoidType))
         {
             Entries[idx] = new EntryPoidType(asset.Entries[idx] as WrathEdXML.AssetDefinition.EntryPoidType);
         }
         else if (entryType == typeof(WrathEdXML.AssetDefinition.EntryFileType))
         {
             Entries[idx] = new EntryFileType(asset.Entries[idx] as WrathEdXML.AssetDefinition.EntryFileType);
         }
         else if (entryType == typeof(WrathEdXML.AssetDefinition.EntryReferenceType))
         {
             Entries[idx] = new EntryReferenceType(asset.Entries[idx] as WrathEdXML.AssetDefinition.EntryReferenceType);
         }
         else if (entryType == typeof(WrathEdXML.AssetDefinition.EntryWeakReferenceType))
         {
             Entries[idx] = new EntryWeakReferenceType(asset.Entries[idx] as WrathEdXML.AssetDefinition.EntryWeakReferenceType);
         }
         else if (entryType == typeof(WrathEdXML.AssetDefinition.EntryType))
         {
             Entries[idx] = new EntryType(asset.Entries[idx] as WrathEdXML.AssetDefinition.EntryType);
         }
         else if (entryType == typeof(WrathEdXML.AssetDefinition.EntryRelocationType))
         {
             Entries[idx] = new EntryRelocationType(asset.Entries[idx] as WrathEdXML.AssetDefinition.EntryRelocationType);
         }
         else if (entryType == typeof(WrathEdXML.AssetDefinition.EntryListType))
         {
             Entries[idx] = new EntryListType(asset.Entries[idx] as WrathEdXML.AssetDefinition.EntryListType);
         }
         else if (entryType == typeof(WrathEdXML.AssetDefinition.EntryChoiceType))
         {
             Entries[idx] = new EntryChoiceType(asset.Entries[idx] as WrathEdXML.AssetDefinition.EntryChoiceType);
         }
         else if (entryType == typeof(WrathEdXML.AssetDefinition.EntryInheritanceType))
         {
             Entries[idx] = new EntryInheritanceType(asset.Entries[idx] as WrathEdXML.AssetDefinition.EntryInheritanceType);
         }
     }
 }
Example #3
0
        public override int GetLength(GameDefinition game)
        {
            int length = 0;

            BaseEntryType[] entries = null;
            if (Runtime != null)
            {
                entries = Runtime.Entries;
            }
            else
            {
                entries = Entries;
            }
            if (entries != null)
            {
                foreach (BaseEntryType entry in entries)
                {
                    Type entryType = entry.GetType();
                    if (entryType == typeof(EntryInheritanceType))
                    {
                        EntryInheritanceType currentEntry = entry as EntryInheritanceType;
                        bool isFound = false;
                        foreach (GameAssetType gameAssetType in game.Assets.GameAssetTypes)
                        {
                            if (gameAssetType.id == currentEntry.AssetType)
                            {
                                isFound = true;
                                length += gameAssetType.GetLength(game);
                                break;
                            }
                        }
                        if (!isFound)
                        {
                            foreach (BaseAssetType baseAssetType in game.Assets.AssetTypes)
                            {
                                if (baseAssetType.id == currentEntry.AssetType)
                                {
                                    isFound = true;
                                    length += baseAssetType.GetLength(game);
                                    break;
                                }
                            }
                        }
                    }
                    else if (entryType == typeof(EntryType))
                    {
                        if (entry.IsVoid)
                        {
                            length += 4 - (length & 3);
                            continue;
                        }
                        EntryType currentEntry = entry as EntryType;
                        switch (currentEntry.AssetType)
                        {
                        case String:
                            length += 8;
                            break;

                        case Angle:
                        case Percentage:
                        case SageInt:
                        case SageReal:
                        case SageUnsignedInt:
                        case Time:
                        case Velocity:
                            length += 4;
                            break;

                        case SageUnsignedShort:
                            length += 2;
                            break;

                        case Byte:
                        case SageBool:
                            ++length;
                            break;

                        default:
                            foreach (BaseAssetType baseAssetType in game.Assets.AssetTypes)
                            {
                                if (baseAssetType.id == currentEntry.AssetType)
                                {
                                    length += baseAssetType.GetLength(game);
                                    break;
                                }
                            }
                            break;
                        }
                    }
                    else if (entryType == typeof(EntryChoiceType))
                    {
                        EntryChoiceType currentEntry = entry as EntryChoiceType;
                        if (currentEntry.MaxLength == 1)
                        {
                            length += 4;
                        }
                        else
                        {
                            length += 8;
                        }
                    }
                    else if (entryType == typeof(EntryFileType) ||
                             entryType == typeof(EntryListType))
                    {
                        length += 8;
                    }
                    else if (entryType == typeof(EntryPoidType) ||
                             entryType == typeof(EntryReferenceType) ||
                             entryType == typeof(EntryWeakReferenceType) ||
                             entryType == typeof(EntryRelocationType))
                    {
                        length += 4;
                    }
                }
            }
            return(length);
        }