Example #1
0
        private AaronCarPartAttribute ConvertAttribute(CarPartAttribute rawAttribute)
        {
            AaronCarPartAttribute attribute = new AaronCarPartAttribute();

            attribute.Name = HashResolver.Resolve(rawAttribute.NameHash);

            switch (attribute.Name)
            {
            case "TEXTURE":
            case "LOD_CHARACTERS_OFFSET":
            case "NAME_OFFSET":
                this.LoadSingleAttribString(attribute, rawAttribute);
                break;

            case "LOD_BASE_NAME":
                this.LoadDoubleAttribString(attribute, rawAttribute);
                break;

            default:
                //attribute.Value = rawAttribute.iParam;
                this.SetAttributeValue(attribute, rawAttribute);
                break;
            }
            return(attribute);
        }
Example #2
0
        private SynchronizedObservableCollection <AaronCarPartAttribute> PrepareAttributes(DBCarPart dbCarPart)
        {
            SynchronizedObservableCollection <AaronCarPartAttribute> attributes = new SynchronizedObservableCollection <AaronCarPartAttribute>();
            AttributeOffsetTable attributeOffsetTable = _attributeOffsetTables[dbCarPart.AttributeTableOffset];

            foreach (var offset in attributeOffsetTable.Offsets)
            {
                var rawAttribute = _attributes[offset];
                AaronCarPartAttribute newAttribute = this.ConvertAttribute(rawAttribute);
                //AaronCarPartAttribute newAttribute = new AaronCarPartAttribute();
                //newAttribute.Name = HashResolver.Resolve(rawAttribute.NameHash);
                //newAttribute.Value = rawAttribute.iParam;


                //switch (newAttribute.Hash)
                //{
                //    case 0xB1027477:
                //    case 0x46B79643:
                //    case 0xFD35FE70:
                //    case 0x7D65A926:
                //        this.LoadSingleAttribString(newAttribute, rawAttribute);
                //        break;
                //    case 0xFE613B98:
                //        this.LoadDoubleAttribString(newAttribute, rawAttribute);
                //        break;
                //}

                attributes.Add(newAttribute);
            }

            return(attributes);
        }
Example #3
0
        private void LoadSingleAttribString(AaronCarPartAttribute attribute, CarPartAttribute rawAttribute)
        {
            if (rawAttribute.uParam != 0xFFFFFFFF)
            {
                var str = _stringOffsetDictionary[rawAttribute.uParam * 4];

                attribute.Strings.Add(str);
            }
            else
            {
                attribute.Strings.Add("");
            }
        }
Example #4
0
        private void LoadDoubleAttribString(AaronCarPartAttribute attribute, CarPartAttribute rawAttribute)
        {
            ushort component1 = (ushort)(rawAttribute.uParam & 0xFFFF);
            ushort component2 = (ushort)((rawAttribute.uParam >> 16) & 0xFFFF);

            if (component1 != 0xFFFFu)
            {
                attribute.Strings.Add(_stringOffsetDictionary[component1 * 4]);
            }
            else
            {
                attribute.Strings.Add("");
            }

            if (component2 != 0xFFFFu)
            {
                attribute.Strings.Add(_stringOffsetDictionary[component2 * 4]);
            }
            else
            {
                attribute.Strings.Add("");
            }
        }
Example #5
0
        private void SetAttributeValue(AaronCarPartAttribute attribute, CarPartAttribute rawAttribute)
        {
            switch (attribute.Name)
            {
            case "LOD_NAME_PREFIX_SELECTOR":
            case "MAX_LOD":
            case "CV":
            case "LANGUAGEHASH":
            case "KITNUMBER":
            case "MODEL_TABLE_OFFSET":
            case "MORPHTARGET_NUM":
            case "0xE80A3B62":
            case "0xCE7D8DB5":
            case "0xEB0101E2":
            case "0x7D29CF3E":
            case "0xEBB03E66":
            case "RED":
            case "GREEN":
            case "BLUE":
            case "GLOSS":
            case "MATTE":
            case "0x6BA02C05":
            case "SWATCH":
            case "0xD68A7BAB":
            case "PAINTGROUP":
            case "MAT0":
            case "MAT1":
            case "MAT2":
            case "MAT3":
            case "MAT4":
            case "MAT5":
            case "MAT6":
            case "MAT7":
            case "TEXTUREHASH":
            case "0xC9818DFC":
            case "MATNAMEA":
            case "MATNAMEB":
            case "DAMAGELEVEL":
            case "0x04B39858":
            case "GROUPLANGUAGEHASH":
            case "0x5412A1D9":
                attribute.Value = rawAttribute.uParam;
                break;

            case "PARTID_UPGRADE_GROUP":
                if (trackedUpgradeGroups.Add(rawAttribute.uParam))
                {
                    ushort sp = (ushort)rawAttribute.uParam;
                    Debug.WriteLine("PARTID_UPGRADE_GROUP: {0} ({1})", Convert.ToString(sp & 0xff, 2).PadLeft(8, '0'), rawAttribute.uParam);
                    Debug.WriteLine((CarPartID)(sp >> 8));
                }
                goto default;

            //    attribute.Value = (CarPartID)(rawAttribute.iParam >> 8);
            //    break;
            case "STOCK":
                attribute.Value = rawAttribute.iParam == 1;
                break;

            case "BLEND":
                attribute.Value = rawAttribute.fParam;
                break;

            default:
                //if (trackedUnknownAttributes.Add(rawAttribute))
                //{
                //    Debug.WriteLine("Unknown attribute: {0} U {1} I {2} F {3}", attribute.Name, rawAttribute.uParam, rawAttribute.iParam, rawAttribute.fParam);
                //}
                attribute.Value = rawAttribute.uParam;
                break;
            }
        }