@@ -26,11 +26,14 @@ public static class ExportHelpers
2626{ 
2727    public  static   UObject  HandleStyle ( UObject  style ) 
2828    { 
29-         var  bpGnCast  =  style  as  UBlueprintGeneratedClass ; 
30-         var  styleClassDefaultObject  =  bpGnCast . ClassDefaultObject . Load ( ) ; 
31-         if  ( styleClassDefaultObject . TryGetValue ( out  UBlueprintGeneratedClass  attachmentOverrides ,  "EquippableSkinChroma" ) ) 
29+         if  ( style  !=  null ) 
3230        { 
33-             return  attachmentOverrides . ClassDefaultObject . Load ( ) ; 
31+             var  bpGnCast  =  style  as  UBlueprintGeneratedClass ; 
32+             var  styleClassDefaultObject  =  bpGnCast . ClassDefaultObject . Load ( ) ; 
33+             if  ( styleClassDefaultObject . TryGetValue ( out  UBlueprintGeneratedClass  attachmentOverrides ,  "EquippableSkinChroma" ) ) 
34+             { 
35+                 return  attachmentOverrides . ClassDefaultObject . Load ( ) ; 
36+             } 
3437        } 
3538        return  null ; 
3639    } 
@@ -239,13 +242,13 @@ public static UStaticMesh GetAllWeaponSM()
239242    } 
240243
241244
242-     public  static   Tuple < string [ ] ,  USkeletalMesh [ ] ,  UMaterialInstanceConstant [ ] [ ] ,  UMaterialInstanceConstant [ ] [ ] >  GetWeaponAttatchments ( UScriptMap  scriptMap ,   UObject ?   style ) 
245+     public  static   Tuple < string [ ] ,  USkeletalMesh [ ] ,  UMaterialInstanceConstant [ ] [ ] ,  string [ ] >  GetWeaponAttatchments ( UScriptMap  scriptMap ) 
243246    { 
244247        // initializer for return tuple stuff 
245248        var  fullSockets  =  new  string [ 2 ] ; 
246249        var  fullOverrideMaterials  =  new  UMaterialInstanceConstant [ 2 ] [ ] ; 
247-         var  fullStyleMaterials  =  new  UMaterialInstanceConstant [ 2 ] [ ] ; 
248250        var  meshes  =  new  USkeletalMesh [ 2 ] ; 
251+         var  paramNames  =  new  string [ 2 ] ; 
249252        //  loop  
250253        foreach  ( var  scriptMapVariable  in  scriptMap . Properties ) 
251254        { 
@@ -258,7 +261,6 @@ public static Tuple<string[], USkeletalMesh[], UMaterialInstanceConstant[][], UM
258261            List < List < string > >  currentAttatchList   =  new  List < List < string > > ( ) ; 
259262            currentAttatchList . Add ( new  List < string > ( scope ) ) ; 
260263            currentAttatchList . Add ( new  List < string > ( silencer ) ) ; 
261- 
262264            //  
263265            for  ( int  i  =  0 ;  i  <  currentAttatchList . Count ;  i ++ ) 
264266            { 
@@ -272,41 +274,33 @@ public static Tuple<string[], USkeletalMesh[], UMaterialInstanceConstant[][], UM
272274                fullSockets [ i ]  =  currentAttach [ 2 ] ; 
273275                meshes [ i ]  =  localMesh ; 
274276                fullOverrideMaterials [ i ]  =  localmat ; 
275-                 //handle attachment style mats 
276-                 if  ( GetStyleAttatchmentMats ( style ,  currentAttach [ 1 ] )  !=  null ) 
277-                 { 
278-                     var  styleMats  =  GetStyleAttatchmentMats ( style ,  currentAttach [ 1 ] ) ; 
279-                     fullStyleMaterials [ i ]  =  styleMats ; 
280-                 } 
277+                 paramNames [ i ]  =  currentAttach [ 1 ] ; 
281278            } 
282279        } 
283-         return  Tuple . Create ( fullSockets ,  meshes ,  fullOverrideMaterials ,  fullStyleMaterials ) ; 
280+         return  Tuple . Create ( fullSockets ,  meshes ,  fullOverrideMaterials ,  paramNames ) ; 
284281    } 
285282
286283    public  static   UMaterialInstanceConstant [ ]  GetStyleAttatchmentMats ( UObject  style ,  string  paramName ) 
287284    { 
288-         if  ( style  !=  null ) 
285+         var  bpGnCast  =  style  as  UBlueprintGeneratedClass ; 
286+         var  styleClassDefaultObject  =  bpGnCast . ClassDefaultObject . Load ( ) ; 
287+         if  ( styleClassDefaultObject . TryGetValue ( out  UScriptMap  styleAttachmentOverrides ,  "AttachmentOverrides" ) ) 
289288        { 
290-             var  bpGnCast  =  style  as  UBlueprintGeneratedClass ; 
291-             var  styleClassDefaultObject  =  bpGnCast . ClassDefaultObject . Load ( ) ; 
292-             if  ( styleClassDefaultObject . TryGetValue ( out  UScriptMap  styleAttachmentOverrides ,  "AttachmentOverrides" ) ) 
289+             //  loop  
290+             foreach  ( var  scriptMapVariable  in  styleAttachmentOverrides . Properties ) 
293291            { 
294-                 //  loop  
295-                 foreach  ( var  scriptMapVariable  in  styleAttachmentOverrides . Properties ) 
296-                 { 
297-                     var  scriptMapValue  =  ( FSoftObjectPath ) scriptMapVariable . Value . GenericValue ; 
298-                     var  valueLoaded  =  ( UBlueprintGeneratedClass ) scriptMapValue . Load ( ) ; 
299-                     var  classDefaultObject  =  valueLoaded . ClassDefaultObject . Load ( ) ; 
300-                     classDefaultObject . TryGetValue ( out  UMaterialInstanceConstant [ ]  materials ,  paramName ) ; 
301-                     return  materials ; 
302-                 } 
292+                 var  scriptMapValue  =  ( FSoftObjectPath ) scriptMapVariable . Value . GenericValue ; 
293+                 var  valueLoaded  =  ( UBlueprintGeneratedClass ) scriptMapValue . Load ( ) ; 
294+                 var  classDefaultObject  =  valueLoaded . ClassDefaultObject . Load ( ) ; 
295+                 classDefaultObject . TryGetValue ( out  UMaterialInstanceConstant [ ]  materials ,  paramName ) ; 
296+                 return  materials ; 
303297            } 
304298        } 
305299        return  null ; 
306300    } 
307301
308302
309-     public  static   void  Weapon (  List < ExportPart >  exportParts ,  ExportData   ActualData ,   UObject  style ) 
303+     public  static   void  Weapon (  List < ExportPart >  exportParts ,  UObject  style ) 
310304    { 
311305
312306        var  mainAsset  =  AppVM . MainVM . CurrentAsset . MainAsset ; 
@@ -330,8 +324,8 @@ public static void Weapon( List<ExportPart> exportParts, ExportData ActualData,
330324        } 
331325        //handle style materials for gun mesh 
332326        if  ( style  !=  null  &&  HandleStyle ( style )  !=  null ) 
333-         { 
334-             OverrideMaterials ( HandleStyle ( style ) . GetOrDefault ( "MaterialOverrides " ,  Array . Empty < UMaterialInstanceConstant > ( ) ) ,  exportParts . Last ( ) . StyleMaterials ) ; 
327+         { //get 3P overwrites for 1P gun because riot games ;-; 
328+             OverrideMaterials ( HandleStyle ( style ) . GetOrDefault ( "3p Material Overrides " ,  Array . Empty < UMaterialInstanceConstant > ( ) ) ,  exportParts . Last ( ) . StyleMaterials ) ; 
335329        } 
336330        //mag mesh 
337331        if  ( levelTuple . Item4  !=  null ) 
@@ -362,7 +356,7 @@ public static void Weapon( List<ExportPart> exportParts, ExportData ActualData,
362356        //attachment (scope & silencer) 
363357        if  ( mainAsset . TryGetValue ( out  UScriptMap  attachmentOverrides ,  "AttachmentOverrides" ) ) 
364358        { 
365-             var  attachmentTuple  =  GetWeaponAttatchments ( attachmentOverrides ,   style ) ; 
359+             var  attachmentTuple  =  GetWeaponAttatchments ( attachmentOverrides ) ; 
366360            for  ( int  i  =  0 ;  i  <  attachmentTuple . Item2 . Length ;  i ++ ) 
367361            { 
368362                Mesh ( attachmentTuple . Item2 [ i ] ,  exportParts ) ; 
@@ -374,11 +368,16 @@ public static void Weapon( List<ExportPart> exportParts, ExportData ActualData,
374368                { 
375369                    OverrideMaterials ( attachmentTuple . Item3 [ i ] , exportParts . Last ( ) . OverrideMaterials ) ; 
376370                } 
377-                 if  ( attachmentTuple . Item4 [ i ]  !=  null ) 
371+                 //handle attachment style mats 
372+                 if  ( style  !=  null ) 
378373                { 
379-                     OverrideMaterials ( attachmentTuple . Item4 [ i ] , exportParts . Last ( ) . StyleMaterials ) ; 
374+                     //scope, muzzle 
375+                     string [ ]  matNames  =  new [ ]  {  "3pMaterialOverrides" ,  "1p MaterialOverrides"  } ; 
376+                     if  ( GetStyleAttatchmentMats ( style ,  matNames [ i ] )  !=  null ) 
377+                     { 
378+                         OverrideMaterials ( GetStyleAttatchmentMats ( style ,  matNames [ i ] ) , exportParts . Last ( ) . StyleMaterials ) ; 
379+                     } 
380380                } 
381-                 //attachment style 
382381            } 
383382        } 
384383
0 commit comments