Skip to content

Commit e0794f1

Browse files
committed
Merge branch 'staging'
2 parents b677520 + dd3bafe commit e0794f1

23 files changed

+927
-162
lines changed

CathodeLib/CathodeLib.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
<Authors>Matt Filer</Authors>
1111
<Description>Provides support for parsing and writing common Alien: Isolation formats from the Cathode engine.</Description>
1212
<Copyright>Matt Filer 2023</Copyright>
13-
<Version>0.5.0</Version>
13+
<Version>0.5.1</Version>
1414
<OutputType>Library</OutputType>
15-
<AssemblyVersion>0.5.0.0</AssemblyVersion>
16-
<FileVersion>0.5.0.0</FileVersion>
15+
<AssemblyVersion>0.5.1.0</AssemblyVersion>
16+
<FileVersion>0.5.1.0</FileVersion>
1717
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
1818
</PropertyGroup>
1919

@@ -47,6 +47,7 @@
4747
</ItemGroup>
4848

4949
<ItemGroup>
50+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
5051
<PackageReference Include="System.Buffers" Version="4.5.1" />
5152
<PackageReference Include="System.Memory" Version="4.5.4" />
5253
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
using CATHODE.Scripting;
2+
using CathodeLib;
3+
using Newtonsoft.Json;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.IO;
7+
using System.Runtime.InteropServices;
8+
9+
namespace CATHODE
10+
{
11+
/* DATA/ENV/PRODUCTION/x/WORLD/CHARACTERACCESSORYSETS.BIN */
12+
public class CharacterAccessorySets : CathodeFile
13+
{
14+
public List<Entry> Entries = new List<Entry>();
15+
public static new Implementation Implementation = Implementation.CREATE | Implementation.LOAD | Implementation.SAVE;
16+
public CharacterAccessorySets(string path) : base(path) { }
17+
18+
#region FILE_IO
19+
override protected bool LoadInternal()
20+
{
21+
using (BinaryReader reader = new BinaryReader(File.OpenRead(_filepath)))
22+
{
23+
reader.BaseStream.Position = 4;
24+
int entryCount = reader.ReadInt32();
25+
for (int i = 0; i < entryCount; i++)
26+
{
27+
Entry entry = new Entry();
28+
entry.character = Utilities.Consume<CommandsEntityReference>(reader);
29+
30+
entry.shirt_composite = Utilities.Consume<ShortGuid>(reader);
31+
entry.trousers_composite = Utilities.Consume<ShortGuid>(reader);
32+
entry.shoes_composite = Utilities.Consume<ShortGuid>(reader);
33+
entry.head_composite = Utilities.Consume<ShortGuid>(reader);
34+
entry.arms_composite = Utilities.Consume<ShortGuid>(reader);
35+
entry.collision_composite = Utilities.Consume<ShortGuid>(reader);
36+
37+
entry.unk1 = reader.ReadInt32();
38+
39+
entry.unk2 = reader.ReadInt32();
40+
entry.unk3 = reader.ReadInt32();
41+
entry.unk4 = reader.ReadInt32();
42+
entry.unk5 = reader.ReadInt32();
43+
entry.unk6 = reader.ReadInt32();
44+
entry.decal = (Entry.Decal)reader.ReadInt32();
45+
entry.unk8 = reader.ReadInt32();
46+
entry.unk9 = reader.ReadInt32();
47+
entry.unk10 = reader.ReadInt32();
48+
entry.unk11 = reader.ReadInt32();
49+
50+
byte[] stringBlock = reader.ReadBytes(260);
51+
entry.face_skeleton = Utilities.ReadString(stringBlock);
52+
stringBlock = reader.ReadBytes(260);
53+
entry.body_skeleton = Utilities.ReadString(stringBlock);
54+
55+
entry.unk12 = reader.ReadInt32();
56+
entry.unk13 = reader.ReadInt32();
57+
entry.unk14 = reader.ReadInt32();
58+
Entries.Add(entry);
59+
}
60+
}
61+
return true;
62+
}
63+
64+
override protected bool SaveInternal()
65+
{
66+
using (BinaryWriter writer = new BinaryWriter(File.OpenWrite(_filepath)))
67+
{
68+
writer.BaseStream.SetLength(0);
69+
writer.Write(20);
70+
writer.Write(Entries.Count);
71+
for (int i = 0; i < Entries.Count; i++)
72+
{
73+
Utilities.Write(writer, Entries[i].character);
74+
75+
Utilities.Write(writer, Entries[i].shirt_composite);
76+
Utilities.Write(writer, Entries[i].trousers_composite);
77+
Utilities.Write(writer, Entries[i].shoes_composite);
78+
Utilities.Write(writer, Entries[i].head_composite);
79+
Utilities.Write(writer, Entries[i].arms_composite);
80+
Utilities.Write(writer, Entries[i].collision_composite);
81+
82+
writer.Write(Entries[i].unk1);
83+
writer.Write(Entries[i].unk2);
84+
writer.Write(Entries[i].unk3);
85+
writer.Write(Entries[i].unk4);
86+
writer.Write(Entries[i].unk5);
87+
writer.Write(Entries[i].unk6);
88+
writer.Write((Int32)Entries[i].decal);
89+
writer.Write(Entries[i].unk8);
90+
writer.Write(Entries[i].unk9);
91+
writer.Write(Entries[i].unk10);
92+
writer.Write(Entries[i].unk11);
93+
94+
writer.Write(new byte[260]);
95+
writer.BaseStream.Position -= 260;
96+
Utilities.WriteString(Entries[i].face_skeleton, writer, false);
97+
writer.BaseStream.Position += 260 - Entries[i].face_skeleton.Length;
98+
writer.Write(new byte[260]);
99+
writer.BaseStream.Position -= 260;
100+
Utilities.WriteString(Entries[i].body_skeleton, writer, false);
101+
writer.BaseStream.Position += 260 - Entries[i].body_skeleton.Length;
102+
103+
writer.Write(Entries[i].unk12);
104+
writer.Write(Entries[i].unk13);
105+
writer.Write(Entries[i].unk14);
106+
}
107+
}
108+
return true;
109+
}
110+
#endregion
111+
112+
#region STRUCTURES
113+
public class Entry
114+
{
115+
public CommandsEntityReference character = new CommandsEntityReference();
116+
117+
public ShortGuid shirt_composite = ShortGuid.Invalid;
118+
public ShortGuid trousers_composite = ShortGuid.Invalid;
119+
public ShortGuid shoes_composite = ShortGuid.Invalid;
120+
public ShortGuid head_composite = ShortGuid.Invalid;
121+
public ShortGuid arms_composite = ShortGuid.Invalid;
122+
public ShortGuid collision_composite = ShortGuid.Invalid;
123+
124+
public int unk1 = 0;
125+
public int unk2 = 1;
126+
public int unk3 = 2;
127+
public int unk4 = 3; //This is often odd values
128+
public int unk5 = 4;
129+
public int unk6 = 5;
130+
131+
public Decal decal = Decal.MEDICAL; //TODO: Is this decal texture defined by CUSTOMCHARACTERASSETDATA.BIN?
132+
133+
public int unk8 = 0;
134+
public int unk9 = 0;
135+
public int unk10 = 1;
136+
public int unk11 = 0;
137+
138+
public string face_skeleton = "AL";
139+
public string body_skeleton = "MALE";
140+
141+
public int unk12 = 3;
142+
public int unk13 = 6;
143+
public int unk14 = 9;
144+
145+
public enum Decal
146+
{
147+
MEDICAL,
148+
ENGINEERING,
149+
GENERIC,
150+
TECHNICAL,
151+
}
152+
};
153+
#endregion
154+
}
155+
}

CathodeLib/Scripts/CATHODE/CollisionMaps.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace CATHODE
99
{
10+
//This file defines additional info for entities with COLLISION_MAPPING resources.
11+
1012
/* DATA/ENV/PRODUCTION/x/WORLD/COLLISION.MAP */
1113
public class CollisionMaps : CathodeFile
1214
{
@@ -25,8 +27,7 @@ override protected bool LoadInternal()
2527
{
2628
Entry entry = new Entry();
2729
entry.Unknown1_ = reader.ReadInt32();
28-
entry.NodeResourceID = Utilities.Consume<ShortGuid>(reader);
29-
entry.NodeID = Utilities.Consume<ShortGuid>(reader);
30+
entry.entity = Utilities.Consume<CommandsEntityReference>(reader);
3031
entry.ResourcesBINID = reader.ReadInt32();
3132
entry.Unknown2_ = reader.ReadInt32();
3233
entry.CollisionHKXEntryIndex = reader.ReadInt16();
@@ -52,8 +53,7 @@ override protected bool SaveInternal()
5253
for (int i = 0; i < Entries.Count; i++)
5354
{
5455
writer.Write(Entries[i].Unknown1_);
55-
Utilities.Write<ShortGuid>(writer, Entries[i].NodeResourceID);
56-
Utilities.Write<ShortGuid>(writer, Entries[i].NodeID);
56+
Utilities.Write<CommandsEntityReference>(writer, Entries[i].entity);
5757
writer.Write(Entries[i].ResourcesBINID);
5858
writer.Write(Entries[i].CollisionHKXEntryIndex);
5959
writer.Write(Entries[i].Unknown3_);
@@ -72,8 +72,9 @@ override protected bool SaveInternal()
7272
public class Entry
7373
{
7474
public int Unknown1_; // Is this tree node id?
75-
public ShortGuid NodeResourceID; // NOTE: This might not be the correct name. It seems to correspond to the similarly named variable at alien_resources_bin_entry.
76-
public ShortGuid NodeID; // NOTE: This is a wild guess based on the matching items from Commands PAK.
75+
76+
public CommandsEntityReference entity;
77+
7778
public int ResourcesBINID; // NOTE: This might not be the correct name. It seems to correspond to the similarly named variable at alien_resources_bin_entry.
7879
public int Unknown2_; // NOTE: Is sometimes -1 and other times a small positive integer. Is this tree node parent?
7980

0 commit comments

Comments
 (0)