Skip to content

Commit 6c1223a

Browse files
committed
continued
1 parent b4ea613 commit 6c1223a

2 files changed

Lines changed: 57 additions & 6 deletions

File tree

CathodeLib/Scripts/CATHODE/CustomCharacterAssetData.cs

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
using System;
55
using System.Collections.Generic;
66
using System.IO;
7+
using System.Linq;
8+
using System.Numerics;
79
using System.Runtime.InteropServices;
810

911
namespace 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
}

CathodeLib/Scripts/CATHODE/CustomCharacterInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class CustomCharacterInfo : CathodeFile
1515
public List<CharacterDefinition> CharacterDefinitions = new List<CharacterDefinition>();
1616
public Dictionary<CharacterPopulation, List<Preset>> Presets = new Dictionary<CharacterPopulation, List<Preset>>();
1717

18-
public static new Implementation Implementation = Implementation.NONE;
18+
public static new Implementation Implementation = Implementation.CREATE | Implementation.SAVE | Implementation.LOAD;
1919
public CustomCharacterInfo(string path) : base(path) { }
2020

2121
#region FILE_IO

0 commit comments

Comments
 (0)