44using System ;
55using System . Collections . Generic ;
66using System . IO ;
7+ using System . Linq ;
8+ using System . Numerics ;
79using System . Runtime . InteropServices ;
810
911namespace CATHODE
1012{
1113 /* DATA/CHR_INFO/CUSTOMCHARACTERASSETDATA.BIN */
1214 public class CustomCharacterAssetData : CathodeFile
1315 {
14- public List < Entry > Entries = new List < Entry > ( ) ;
16+ public List < AssetDefinition > Entries = new List < AssetDefinition > ( ) ;
1517 public static new Implementation Implementation = Implementation . NONE ;
1618 public CustomCharacterAssetData ( string path ) : base ( path ) { }
1719
@@ -20,8 +22,29 @@ override protected bool LoadInternal()
2022 {
2123 using ( BinaryReader reader = new BinaryReader ( File . OpenRead ( _filepath ) ) )
2224 {
23-
24-
25+ reader . BaseStream . Position += 4 ; //version
26+ int count = reader . ReadInt32 ( ) ;
27+ for ( int i = 0 ; i < count ; i ++ )
28+ {
29+ AssetDefinition assetDef = new AssetDefinition ( ) ;
30+ assetDef . AssetType = ( CharacterAsset ) reader . ReadInt32 ( ) ;
31+ Dictionary < ColourType , int > colourCounts = new Dictionary < ColourType , int > ( ) ;
32+ foreach ( ColourType colour in Enum . GetValues ( typeof ( ColourType ) ) )
33+ {
34+ colourCounts . Add ( colour , reader . ReadInt32 ( ) ) ;
35+ }
36+ foreach ( ColourType colour in Enum . GetValues ( typeof ( ColourType ) ) )
37+ {
38+ assetDef . Tints . Add ( colour , Utilities . ConsumeArray < Vector3 > ( reader , colourCounts [ colour ] ) . ToList ( ) ) ;
39+ }
40+ int decalCount = reader . ReadInt32 ( ) ;
41+ for ( int x = 0 ; x < decalCount ; x ++ )
42+ {
43+ byte [ ] stringBlock = reader . ReadBytes ( 260 ) ;
44+ assetDef . Decals . Add ( Utilities . ReadString ( stringBlock ) ) ;
45+ }
46+ Entries . Add ( assetDef ) ;
47+ }
2548 }
2649 return true ;
2750 }
@@ -30,16 +53,44 @@ override protected bool SaveInternal()
3053 {
3154 using ( BinaryWriter writer = new BinaryWriter ( File . OpenWrite ( _filepath ) ) )
3255 {
33-
56+ writer . Write ( 1 ) ;
57+ writer . Write ( Entries . Count ) ;
58+ foreach ( AssetDefinition assetDef in Entries )
59+ {
60+ writer . Write ( ( int ) assetDef . AssetType ) ;
61+ foreach ( ColourType colour in Enum . GetValues ( typeof ( ColourType ) ) )
62+ {
63+ writer . Write ( assetDef . Tints [ colour ] . Count ) ;
64+ }
65+ foreach ( ColourType colour in Enum . GetValues ( typeof ( ColourType ) ) )
66+ {
67+ Utilities . Write ( writer , assetDef . Tints [ colour ] ) ;
68+ }
69+ writer . Write ( assetDef . Decals . Count ) ;
70+ foreach ( string decal in assetDef . Decals )
71+ {
72+ Utilities . WriteString ( decal , writer ) ;
73+ writer . Write ( new byte [ 260 - decal . Length ] ) ;
74+ }
75+ }
3476 }
3577 return true ;
3678 }
3779 #endregion
3880
3981 #region STRUCTURES
40- public class Entry
82+ public class AssetDefinition
4183 {
84+ public CharacterAsset AssetType ;
85+ public Dictionary < ColourType , List < Vector3 > > Tints = new Dictionary < ColourType , List < Vector3 > > ( ) ;
86+ public List < string > Decals = new List < string > ( ) ;
87+ } ;
4288
89+ public enum ColourType
90+ {
91+ PRIMARY ,
92+ SECONDARY ,
93+ TERTIARY ,
4394 } ;
4495 #endregion
4596 }
0 commit comments