Exemple #1
0
        public FileInfo RecookToSlot(SkinIdentifier skinIdentifier, string slot)
        {
            var baseObj            = skinIdentifier.RawValue;
            var newObj             = skinIdentifier.RawValue.Replace(skinIdentifier.Slot, slot);
            var newAssetPath       = Path.Combine(_sourceFile.Directory.FullName, newObj + ".uasset");
            var sourceInstancePath = Path.Combine(_sourceFile.Directory.FullName,
                                                  $"{skinIdentifier.Aircraft}_{skinIdentifier.Slot}_Inst.uasset");
            var targetInstancePath = Path.Combine(_sourceFile.Directory.FullName,
                                                  $"{skinIdentifier.Aircraft}_{slot}_Inst.uasset");

            switch (skinIdentifier.Type)
            {
            case "D":
            {
                var ac0 = new AssetWriter(Path.ChangeExtension(_sourceFile.FullName, ".uasset"), null, null);
                try {
                    _logger.LogInformation($"Changing '{baseObj}' to '{newObj}'");
                    var assetPath = ac0.data.GetHeaderReference(0);
                    ac0.data.SetHeaderReference(0, assetPath.Replace(skinIdentifier.RawValue, newObj));
                    var nameRef = ac0.data.SearchHeaderReference(baseObj);
                    ac0.data.SetHeaderReference(nameRef, newObj);
                    ac0.Write(newAssetPath);
                }
                catch (Exception e) {
                    Console.WriteLine(e);
                    throw;
                }

                break;
            }

            case "MREC" or "N":
            {
                if (File.Exists(targetInstancePath))
                {
                    var reader = new InstanceAssetReader(_parserService);
                    var mrec   = skinIdentifier.Type == "MREC"
                            ? reader.FindMREC(targetInstancePath, skinIdentifier)
                            : reader.FindNormal(targetInstancePath, skinIdentifier);
                    if (mrec is { Identifier : { } })
                    {
                        newObj       = mrec.Value.Identifier.RawValue;
                        newAssetPath = newAssetPath.ChangeFileName(Path.GetFileNameWithoutExtension(mrec.Value.Path));
                    }
                }
Exemple #2
0
 protected abstract IEnumerable <BuildInstruction>?HandleSkinIdentifier(SkinIdentifier skinIdentifier,
                                                                        FileInfo sourceFile);