Skip to content

Commit 6a4aad0

Browse files
committed
Merge branch 'staging'
2 parents a837615 + 5863f9d commit 6a4aad0

35 files changed

Lines changed: 604 additions & 183 deletions

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 2026</Copyright>
13-
<Version>0.11.1</Version>
13+
<Version>0.11.2</Version>
1414
<OutputType>Library</OutputType>
15-
<AssemblyVersion>0.11.1.0</AssemblyVersion>
16-
<FileVersion>0.11.1.0</FileVersion>
15+
<AssemblyVersion>0.11.2.0</AssemblyVersion>
16+
<FileVersion>0.11.2.0</FileVersion>
1717
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
1818
<PackageReadmeFile>README.md</PackageReadmeFile>
1919
<PackageTags>alien, modding, alien isolation, mod tool, file utility</PackageTags>

CathodeLib/Scripts/CATHODE/AlphaLightLevel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ public AlphaLightLevel(byte[] data, string path = "") : base(data, path) { }
2525
public Vector2 Resolution;
2626
public byte[] ImageData; // this is in A16B16G16R16F format
2727

28+
~AlphaLightLevel()
29+
{
30+
ImageData = null;
31+
}
32+
2833
#region FILE_IO
2934
override protected bool LoadInternal(MemoryStream stream)
3035
{

CathodeLib/Scripts/CATHODE/AnimationStrings.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ public AnimationStrings(string path) : base(path) { }
2121
public AnimationStrings(MemoryStream stream, string path = "") : base(stream, path) { }
2222
public AnimationStrings(byte[] data, string path = "") : base(data, path) { }
2323

24+
~AnimationStrings()
25+
{
26+
Entries.Clear();
27+
}
28+
2429
#region FILE_IO
2530
override protected bool LoadInternal(MemoryStream stream)
2631
{
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using CathodeLib;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Runtime.InteropServices;
6+
using System.Linq;
7+
8+
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
9+
using UnityEngine;
10+
#else
11+
using System.Numerics;
12+
#endif
13+
14+
namespace CATHODE
15+
{
16+
/// <summary>
17+
/// DATA/ENV/x/WORLD/BEHAVIOR_TREE.DB
18+
/// </summary>
19+
public class BehaviorTreeDB : CathodeFile
20+
{
21+
public List<string> Entries = new List<string>();
22+
public static new Implementation Implementation = Implementation.LOAD | Implementation.SAVE | Implementation.CREATE;
23+
24+
public BehaviorTreeDB(string path) : base(path) { }
25+
public BehaviorTreeDB(MemoryStream stream, string path = "") : base(stream, path) { }
26+
public BehaviorTreeDB(byte[] data, string path = "") : base(data, path) { }
27+
28+
~BehaviorTreeDB()
29+
{
30+
Entries.Clear();
31+
}
32+
33+
#region FILE_IO
34+
override protected bool LoadInternal(MemoryStream stream)
35+
{
36+
using (BinaryReader reader = new BinaryReader(stream))
37+
{
38+
int count = reader.ReadInt32();
39+
reader.BaseStream.Position += (count * 8) + 4;
40+
for (int i = 0; i < count; i++)
41+
{
42+
Entries.Add(Utilities.ReadString(reader));
43+
}
44+
}
45+
return true;
46+
}
47+
48+
override protected bool SaveInternal()
49+
{
50+
using (BinaryWriter writer = new BinaryWriter(File.OpenWrite(_filepath)))
51+
{
52+
writer.BaseStream.SetLength(0);
53+
writer.Write((Int64)Entries.Count);
54+
writer.Write(new byte[8 * Entries.Count]);
55+
List<int> offsets = new List<int>(Entries.Count);
56+
for (int i = 0; i < Entries.Count; i++)
57+
{
58+
offsets.Add((int)writer.BaseStream.Position);
59+
Utilities.WriteString(Entries[i], writer, true);
60+
}
61+
writer.BaseStream.Position = 8;
62+
for (int i = 0; i < Entries.Count; i++)
63+
{
64+
writer.Write((Int64)offsets[i]);
65+
}
66+
}
67+
return true;
68+
}
69+
#endregion
70+
}
71+
}

CathodeLib/Scripts/CATHODE/CharacterAccessorySets.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ public CharacterAccessorySets(string path) : base(path) { }
2020
public CharacterAccessorySets(MemoryStream stream, string path = "") : base(stream, path) { }
2121
public CharacterAccessorySets(byte[] data, string path = "") : base(data, path) { }
2222

23+
~CharacterAccessorySets()
24+
{
25+
Entries.Clear();
26+
}
27+
2328
#region FILE_IO
2429
override protected bool LoadInternal(MemoryStream stream)
2530
{

CathodeLib/Scripts/CATHODE/CollisionMaps.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using CATHODE.Scripting;
1+
using CATHODE.Scripting;
22
using CathodeLib;
33
using CathodeLib.ObjectExtensions;
44
using System;
@@ -35,6 +35,19 @@ public CollisionMaps(string path, Materials materials, MaterialMappings material
3535
_loaded = Load();
3636
}
3737

38+
public void ClearReferences()
39+
{
40+
_materials = null;
41+
_materialMaps = null;
42+
}
43+
44+
~CollisionMaps()
45+
{
46+
ClearReferences();
47+
Entries.Clear();
48+
_writeList.Clear();
49+
}
50+
3851
#region FILE_IO
3952
override protected bool LoadInternal(MemoryStream stream)
4053
{

CathodeLib/Scripts/CATHODE/Collisions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ public Collisions(byte[] data, string path = "") : base(data, path) { }
3434

3535
private List<WeightedCollision> _writeList = new List<WeightedCollision>();
3636

37+
~Collisions()
38+
{
39+
Entries.Clear();
40+
_writeList.Clear();
41+
}
42+
3743
#region FILE_IO
3844
override protected bool LoadInternal(MemoryStream stream)
3945
{

CathodeLib/Scripts/CATHODE/Commands.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,16 @@ public Commands(string path, EnvironmentAnimations envAnims, CollisionMaps colMa
4343
_loaded = Load();
4444
}
4545

46+
public void ClearReferences()
47+
{
48+
_envAnims = null;
49+
_colMaps = null;
50+
_reds = null;
51+
}
52+
4653
~Commands()
4754
{
55+
ClearReferences();
4856
Entries.Clear();
4957
}
5058

CathodeLib/Scripts/CATHODE/EnvironmentAnimations.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public class EnvironmentAnimations : CathodeFile
2525
public List<EnvironmentAnimation> Entries = new List<EnvironmentAnimation>();
2626
public static new Implementation Implementation = Implementation.LOAD | Implementation.CREATE | Implementation.SAVE;
2727

28+
private AnimationStrings _strings;
29+
private List<EnvironmentAnimation> _writeList = new List<EnvironmentAnimation>();
30+
2831
public EnvironmentAnimations(string path, AnimationStrings strings) : base(path)
2932
{
3033
_strings = strings;
@@ -44,9 +47,17 @@ public EnvironmentAnimations(byte[] data, AnimationStrings strings, string path
4447
}
4548
}
4649

47-
private List<EnvironmentAnimation> _writeList = new List<EnvironmentAnimation>();
50+
public void ClearReferences()
51+
{
52+
_strings = null;
53+
}
4854

49-
private AnimationStrings _strings;
55+
~EnvironmentAnimations()
56+
{
57+
ClearReferences();
58+
_writeList.Clear();
59+
Entries.Clear();
60+
}
5061

5162
#region FILE_IO
5263
override protected bool LoadInternal(MemoryStream stream)

CathodeLib/Scripts/CATHODE/EnvironmentMaps.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,28 @@ public class EnvironmentMaps : CathodeFile
1919
protected override bool HandlesLoadingManually => true;
2020
private Movers _movers;
2121

22+
/// <summary>
23+
/// This is the number of environment maps in the level. We should never reference an index higher than this.
24+
/// </summary>
25+
public int EnvironmentMapCount = 0;
26+
2227
public EnvironmentMaps(string path, Movers movers) : base(path)
2328
{
2429
_movers = movers;
2530

2631
_loaded = Load();
2732
}
2833

29-
/// <summary>
30-
/// This is the number of environment maps in the level. We should never reference an index higher than this.
31-
/// </summary>
32-
public int EnvironmentMapCount = 0;
34+
public void ClearReferences()
35+
{
36+
_movers = null;
37+
}
38+
39+
~EnvironmentMaps()
40+
{
41+
ClearReferences();
42+
Entries.Clear();
43+
}
3344

3445
#region FILE_IO
3546
override protected bool LoadInternal(MemoryStream stream)

0 commit comments

Comments
 (0)