Skip to content

Commit 4d53561

Browse files
committed
Merge branch 'staging'
2 parents e0794f1 + 3b49dec commit 4d53561

27 files changed

+1881
-583
lines changed

AlienBML

CathodeLib/CathodeLib.csproj

Lines changed: 3 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.1</Version>
13+
<Version>0.6.0</Version>
1414
<OutputType>Library</OutputType>
15-
<AssemblyVersion>0.5.1.0</AssemblyVersion>
16-
<FileVersion>0.5.1.0</FileVersion>
15+
<AssemblyVersion>0.6.0.0</AssemblyVersion>
16+
<FileVersion>0.6.0.0</FileVersion>
1717
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
1818
</PropertyGroup>
1919

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using CathodeLib;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Runtime.InteropServices;
6+
7+
namespace CATHODE.EXPERIMENTAL
8+
{
9+
/* DATA/ENV/PRODUCTION/x/WORLD/ALPHALIGHT_LEVEL.BIN */
10+
public class AlphaLightLevel : CathodeFile
11+
{
12+
public List<Entry> Entries = new List<Entry>();
13+
public static new Implementation Implementation = Implementation.NONE;
14+
public AlphaLightLevel(string path) : base(path) { }
15+
16+
// Lighting information for objects with alpha (e.g. glass). Levels can load without this file, but look worse.
17+
18+
#region FILE_IO
19+
override protected bool LoadInternal()
20+
{
21+
using (BinaryReader reader = new BinaryReader(File.OpenRead(_filepath)))
22+
{
23+
//todo
24+
}
25+
return true;
26+
}
27+
28+
override protected bool SaveInternal()
29+
{
30+
using (BinaryWriter writer = new BinaryWriter(File.OpenWrite(_filepath)))
31+
{
32+
writer.BaseStream.SetLength(0);
33+
Utilities.WriteString("alph", writer);
34+
35+
//todo
36+
}
37+
return true;
38+
}
39+
#endregion
40+
41+
#region STRUCTURES
42+
public class Entry
43+
{
44+
//todo
45+
};
46+
#endregion
47+
}
48+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Numerics;
6+
using System.Runtime.InteropServices;
7+
using System.Runtime.InteropServices.ComTypes;
8+
using System.Text;
9+
using CATHODE.Scripting;
10+
using CathodeLib;
11+
12+
namespace CATHODE
13+
{
14+
/* DATA/GLOBAL/ANIMATION.PAK -> ANIM_CLIP_DB.BIN */
15+
public class AnimClipDB : CathodeFile
16+
{
17+
public Dictionary<uint, string> Entries = new Dictionary<uint, string>();
18+
public static new Implementation Implementation = Implementation.LOAD;
19+
public AnimClipDB(string path) : base(path) { }
20+
21+
#region FILE_IO
22+
override protected bool LoadInternal()
23+
{
24+
using (BinaryReader reader = new BinaryReader(File.OpenRead(_filepath)))
25+
{
26+
int EntryCount1 = reader.ReadInt32();
27+
int EntryCount2 = reader.ReadInt32();
28+
IndexPair[] Entries1 = Utilities.ConsumeArray<IndexPair>(reader, EntryCount1);
29+
IndexPair[] Entries2 = Utilities.ConsumeArray<IndexPair>(reader, EntryCount2);
30+
31+
int Count0 = reader.ReadInt32();
32+
int Count1 = reader.ReadInt32();
33+
IndexPair[] Stuff0 = Utilities.ConsumeArray<IndexPair>(reader, Count0);
34+
OffsetPair[] Stuff1 = Utilities.ConsumeArray<OffsetPair>(reader, Count1);
35+
36+
int Count2 = reader.ReadInt32();
37+
int[] Stuff2 = Utilities.ConsumeArray<int>(reader, Count2);
38+
39+
int Count4 = reader.ReadInt32();
40+
int Count5 = reader.ReadInt32();
41+
int Count6 = reader.ReadInt32();
42+
IndexPair[] Stuff5 = Utilities.ConsumeArray<IndexPair>(reader, Count5);
43+
int[] Stuff6 = Utilities.ConsumeArray<int>(reader, Count6);
44+
45+
int Count7 = reader.ReadInt32();
46+
int[] Stuff7 = Utilities.ConsumeArray<int>(reader, Count7);
47+
48+
byte[] HeaderCounts0 = Utilities.ConsumeArray<byte>(reader, 5);
49+
float[] HeaderFloats0 = Utilities.ConsumeArray<float>(reader, 6); // TODO: Is this HKX min/max floats for compression?
50+
int[] HeaderStuff0 = Utilities.ConsumeArray<int>(reader, 4);
51+
52+
int[] ContentStuff0 = Utilities.ConsumeArray<int>(reader, HeaderCounts0[1] * 4);
53+
Vector2[] ContentStuff1 = Utilities.ConsumeArray<Vector2>(reader, HeaderCounts0[2]);
54+
55+
bone_entry[] BoneEntries = Utilities.ConsumeArray<bone_entry>(reader, HeaderCounts0[3]);
56+
57+
// NOTE: Following content seems to be 4 unknown u8s followed by 4 u8s of which the 0th is ff and 1, 2 and 3 seem to
58+
// sum to 255. I would guess those are bone weights? Bone weights tend to sum to 1.
59+
}
60+
return true;
61+
}
62+
63+
override protected bool SaveInternal()
64+
{
65+
using (BinaryWriter writer = new BinaryWriter(File.OpenWrite(_filepath)))
66+
{
67+
writer.BaseStream.SetLength(0);
68+
}
69+
return true;
70+
}
71+
#endregion
72+
73+
#region STRUCTURES
74+
[StructLayout(LayoutKind.Sequential, Pack = 1)]
75+
private struct IndexPair
76+
{
77+
public uint id;
78+
public int index;
79+
}
80+
[StructLayout(LayoutKind.Sequential, Pack = 1)]
81+
private struct bone_entry
82+
{
83+
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
84+
byte[] Joints;
85+
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
86+
byte[] Weights;
87+
};
88+
#endregion
89+
}
90+
}

CathodeLib/Scripts/CATHODE/AnimationStrings.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ public AnimationStrings(string path) : base(path) { }
1919
#region FILE_IO
2020
override protected bool LoadInternal()
2121
{
22-
using (BinaryReader stream = new BinaryReader(File.OpenRead(_filepath)))
22+
using (BinaryReader reader = new BinaryReader(File.OpenRead(_filepath)))
2323
{
2424
//Read all data in
25-
int EntryCount = stream.ReadInt32();
26-
int StringCount = stream.ReadInt32();
27-
Entry[] entries = Utilities.ConsumeArray<Entry>(stream, EntryCount);
28-
int[] stringOffsets = Utilities.ConsumeArray<int>(stream, StringCount);
25+
int EntryCount = reader.ReadInt32();
26+
int StringCount = reader.ReadInt32();
27+
Entry[] entries = Utilities.ConsumeArray<Entry>(reader, EntryCount);
28+
int[] stringOffsets = Utilities.ConsumeArray<int>(reader, StringCount);
2929
List<string> strings = new List<string>();
30-
for (int i = 0; i < StringCount; i++) strings.Add(Utilities.ReadString(stream));
30+
for (int i = 0; i < StringCount; i++) strings.Add(Utilities.ReadString(reader));
3131

3232
//Parse
3333
for (int i = 0; i < entries.Length; i++) Entries.Add(entries[i].StringID, strings[entries[i].StringIndex]);
@@ -40,6 +40,7 @@ override protected bool SaveInternal()
4040
{
4141
using (BinaryWriter writer = new BinaryWriter(File.OpenWrite(_filepath)))
4242
{
43+
writer.BaseStream.SetLength(0);
4344
writer.Write(Entries.Count);
4445
writer.Write(Entries.Count);
4546
int count = 0;

CathodeLib/Scripts/CATHODE/CollisionMaps.cs

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ override protected bool LoadInternal()
2121
{
2222
using (BinaryReader reader = new BinaryReader(File.OpenRead(_filepath)))
2323
{
24+
//It seems typically in this file at the start there are a bunch of empty entries, and then there are a bunch of unresolvable ones, and then a bunch that can be resolved.
25+
2426
reader.BaseStream.Position = 4;
2527
int entryCount = reader.ReadInt32();
2628
for (int i = 0; i < entryCount; i++)
2729
{
2830
Entry entry = new Entry();
29-
entry.Unknown1_ = reader.ReadInt32();
31+
entry.unk0 = reader.ReadInt32(); //flag?
32+
entry.Unknown1_ = reader.ReadInt32(); //some sort of index ?
33+
entry.ID = Utilities.Consume<ShortGuid>(reader);
3034
entry.entity = Utilities.Consume<CommandsEntityReference>(reader);
31-
entry.ResourcesBINID = reader.ReadInt32();
32-
entry.Unknown2_ = reader.ReadInt32();
35+
entry.Unknown2_ = reader.ReadInt32(); //Is sometimes -1 and other times a small positive integer. Is this tree node parent?
3336
entry.CollisionHKXEntryIndex = reader.ReadInt16();
34-
entry.Unknown3_ = reader.ReadInt16();
37+
entry.Unknown3_ = reader.ReadInt16(); //Most of the time it is -1.
3538
entry.MVRZoneIDThing = reader.ReadInt32();
36-
entry.Unknown4_ = reader.ReadInt32();
37-
entry.Unknown5_ = reader.ReadInt32();
38-
entry.Unknown6_ = reader.ReadInt32();
39-
entry.Unknown7_ = reader.ReadInt32();
39+
reader.BaseStream.Position += 16;
4040
Entries.Add(entry);
4141
}
4242
}
@@ -53,15 +53,12 @@ override protected bool SaveInternal()
5353
for (int i = 0; i < Entries.Count; i++)
5454
{
5555
writer.Write(Entries[i].Unknown1_);
56+
Utilities.Write<ShortGuid>(writer, Entries[i].ID);
5657
Utilities.Write<CommandsEntityReference>(writer, Entries[i].entity);
57-
writer.Write(Entries[i].ResourcesBINID);
5858
writer.Write(Entries[i].CollisionHKXEntryIndex);
5959
writer.Write(Entries[i].Unknown3_);
6060
writer.Write(Entries[i].MVRZoneIDThing);
61-
writer.Write(Entries[i].Unknown4_);
62-
writer.Write(Entries[i].Unknown5_);
63-
writer.Write(Entries[i].Unknown6_);
64-
writer.Write(Entries[i].Unknown7_);
61+
writer.Write(new byte[16]);
6562
}
6663
}
6764
return true;
@@ -71,22 +68,19 @@ override protected bool SaveInternal()
7168
#region STRUCTURES
7269
public class Entry
7370
{
74-
public int Unknown1_; // Is this tree node id?
71+
public int unk0 = 0; //flags?
72+
public int Unknown1_ = -1; // Is this tree node id?
7573

76-
public CommandsEntityReference entity;
74+
public ShortGuid ID = ShortGuid.Invalid; //This is the name of the entity hashed via ShortGuid, as a result, we can't resolve a lot of them. Does the game care about the value? I doubt it. We definitely don't.
7775

78-
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.
79-
public int Unknown2_; // NOTE: Is sometimes -1 and other times a small positive integer. Is this tree node parent?
76+
public CommandsEntityReference entity = new CommandsEntityReference();
8077

81-
public Int16 CollisionHKXEntryIndex; // NOTE: Most of the time is a positive integer, sometimes -1.
78+
public int Unknown2_= -1; // NOTE: Is sometimes -1 and other times a small positive integer. Is this tree node parent?
8279

83-
public Int16 Unknown3_; // NOTE: Most of the time it is -1.
84-
public int MVRZoneIDThing; // NOTE: This is CollisionMapThingIDs[0] from alien_mvr_entry
80+
public Int16 CollisionHKXEntryIndex = -1; // NOTE: Most of the time is a positive integer, sometimes -1.
8581

86-
public int Unknown4_;
87-
public int Unknown5_;
88-
public int Unknown6_;
89-
public int Unknown7_;
82+
public Int16 Unknown3_ = -1; // NOTE: Most of the time it is -1.
83+
public int MVRZoneIDThing = 0; // NOTE: This is CollisionMapThingIDs[0] from alien_mvr_entry
9084
};
9185
#endregion
9286
}

0 commit comments

Comments
 (0)