Skip to content

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
MattFiler committed Aug 3, 2023
2 parents b677520 + dd3bafe commit e0794f1
Show file tree
Hide file tree
Showing 23 changed files with 927 additions and 162 deletions.
7 changes: 4 additions & 3 deletions CathodeLib/CathodeLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<Authors>Matt Filer</Authors>
<Description>Provides support for parsing and writing common Alien: Isolation formats from the Cathode engine.</Description>
<Copyright>Matt Filer 2023</Copyright>
<Version>0.5.0</Version>
<Version>0.5.1</Version>
<OutputType>Library</OutputType>
<AssemblyVersion>0.5.0.0</AssemblyVersion>
<FileVersion>0.5.0.0</FileVersion>
<AssemblyVersion>0.5.1.0</AssemblyVersion>
<FileVersion>0.5.1.0</FileVersion>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
</PropertyGroup>

Expand Down Expand Up @@ -47,6 +47,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
Expand Down
155 changes: 155 additions & 0 deletions CathodeLib/Scripts/CATHODE/CharacterAccessorySets.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
using CATHODE.Scripting;
using CathodeLib;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;

namespace CATHODE
{
/* DATA/ENV/PRODUCTION/x/WORLD/CHARACTERACCESSORYSETS.BIN */
public class CharacterAccessorySets : CathodeFile
{
public List<Entry> Entries = new List<Entry>();
public static new Implementation Implementation = Implementation.CREATE | Implementation.LOAD | Implementation.SAVE;
public CharacterAccessorySets(string path) : base(path) { }

#region FILE_IO
override protected bool LoadInternal()
{
using (BinaryReader reader = new BinaryReader(File.OpenRead(_filepath)))
{
reader.BaseStream.Position = 4;
int entryCount = reader.ReadInt32();
for (int i = 0; i < entryCount; i++)
{
Entry entry = new Entry();
entry.character = Utilities.Consume<CommandsEntityReference>(reader);

entry.shirt_composite = Utilities.Consume<ShortGuid>(reader);
entry.trousers_composite = Utilities.Consume<ShortGuid>(reader);
entry.shoes_composite = Utilities.Consume<ShortGuid>(reader);
entry.head_composite = Utilities.Consume<ShortGuid>(reader);
entry.arms_composite = Utilities.Consume<ShortGuid>(reader);
entry.collision_composite = Utilities.Consume<ShortGuid>(reader);

entry.unk1 = reader.ReadInt32();

entry.unk2 = reader.ReadInt32();
entry.unk3 = reader.ReadInt32();
entry.unk4 = reader.ReadInt32();
entry.unk5 = reader.ReadInt32();
entry.unk6 = reader.ReadInt32();
entry.decal = (Entry.Decal)reader.ReadInt32();
entry.unk8 = reader.ReadInt32();
entry.unk9 = reader.ReadInt32();
entry.unk10 = reader.ReadInt32();
entry.unk11 = reader.ReadInt32();

byte[] stringBlock = reader.ReadBytes(260);
entry.face_skeleton = Utilities.ReadString(stringBlock);
stringBlock = reader.ReadBytes(260);
entry.body_skeleton = Utilities.ReadString(stringBlock);

entry.unk12 = reader.ReadInt32();
entry.unk13 = reader.ReadInt32();
entry.unk14 = reader.ReadInt32();
Entries.Add(entry);
}
}
return true;
}

override protected bool SaveInternal()
{
using (BinaryWriter writer = new BinaryWriter(File.OpenWrite(_filepath)))
{
writer.BaseStream.SetLength(0);
writer.Write(20);
writer.Write(Entries.Count);
for (int i = 0; i < Entries.Count; i++)
{
Utilities.Write(writer, Entries[i].character);

Utilities.Write(writer, Entries[i].shirt_composite);
Utilities.Write(writer, Entries[i].trousers_composite);
Utilities.Write(writer, Entries[i].shoes_composite);
Utilities.Write(writer, Entries[i].head_composite);
Utilities.Write(writer, Entries[i].arms_composite);
Utilities.Write(writer, Entries[i].collision_composite);

writer.Write(Entries[i].unk1);
writer.Write(Entries[i].unk2);
writer.Write(Entries[i].unk3);
writer.Write(Entries[i].unk4);
writer.Write(Entries[i].unk5);
writer.Write(Entries[i].unk6);
writer.Write((Int32)Entries[i].decal);
writer.Write(Entries[i].unk8);
writer.Write(Entries[i].unk9);
writer.Write(Entries[i].unk10);
writer.Write(Entries[i].unk11);

writer.Write(new byte[260]);
writer.BaseStream.Position -= 260;
Utilities.WriteString(Entries[i].face_skeleton, writer, false);
writer.BaseStream.Position += 260 - Entries[i].face_skeleton.Length;
writer.Write(new byte[260]);
writer.BaseStream.Position -= 260;
Utilities.WriteString(Entries[i].body_skeleton, writer, false);
writer.BaseStream.Position += 260 - Entries[i].body_skeleton.Length;

writer.Write(Entries[i].unk12);
writer.Write(Entries[i].unk13);
writer.Write(Entries[i].unk14);
}
}
return true;
}
#endregion

#region STRUCTURES
public class Entry
{
public CommandsEntityReference character = new CommandsEntityReference();

public ShortGuid shirt_composite = ShortGuid.Invalid;
public ShortGuid trousers_composite = ShortGuid.Invalid;
public ShortGuid shoes_composite = ShortGuid.Invalid;
public ShortGuid head_composite = ShortGuid.Invalid;
public ShortGuid arms_composite = ShortGuid.Invalid;
public ShortGuid collision_composite = ShortGuid.Invalid;

public int unk1 = 0;
public int unk2 = 1;
public int unk3 = 2;
public int unk4 = 3; //This is often odd values
public int unk5 = 4;
public int unk6 = 5;

public Decal decal = Decal.MEDICAL; //TODO: Is this decal texture defined by CUSTOMCHARACTERASSETDATA.BIN?

public int unk8 = 0;
public int unk9 = 0;
public int unk10 = 1;
public int unk11 = 0;

public string face_skeleton = "AL";
public string body_skeleton = "MALE";

public int unk12 = 3;
public int unk13 = 6;
public int unk14 = 9;

public enum Decal
{
MEDICAL,
ENGINEERING,
GENERIC,
TECHNICAL,
}
};
#endregion
}
}
13 changes: 7 additions & 6 deletions CathodeLib/Scripts/CATHODE/CollisionMaps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace CATHODE
{
//This file defines additional info for entities with COLLISION_MAPPING resources.

/* DATA/ENV/PRODUCTION/x/WORLD/COLLISION.MAP */
public class CollisionMaps : CathodeFile
{
Expand All @@ -25,8 +27,7 @@ override protected bool LoadInternal()
{
Entry entry = new Entry();
entry.Unknown1_ = reader.ReadInt32();
entry.NodeResourceID = Utilities.Consume<ShortGuid>(reader);
entry.NodeID = Utilities.Consume<ShortGuid>(reader);
entry.entity = Utilities.Consume<CommandsEntityReference>(reader);
entry.ResourcesBINID = reader.ReadInt32();
entry.Unknown2_ = reader.ReadInt32();
entry.CollisionHKXEntryIndex = reader.ReadInt16();
Expand All @@ -52,8 +53,7 @@ override protected bool SaveInternal()
for (int i = 0; i < Entries.Count; i++)
{
writer.Write(Entries[i].Unknown1_);
Utilities.Write<ShortGuid>(writer, Entries[i].NodeResourceID);
Utilities.Write<ShortGuid>(writer, Entries[i].NodeID);
Utilities.Write<CommandsEntityReference>(writer, Entries[i].entity);
writer.Write(Entries[i].ResourcesBINID);
writer.Write(Entries[i].CollisionHKXEntryIndex);
writer.Write(Entries[i].Unknown3_);
Expand All @@ -72,8 +72,9 @@ override protected bool SaveInternal()
public class Entry
{
public int Unknown1_; // Is this tree node id?
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.
public ShortGuid NodeID; // NOTE: This is a wild guess based on the matching items from Commands PAK.

public CommandsEntityReference entity;

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.
public int Unknown2_; // NOTE: Is sometimes -1 and other times a small positive integer. Is this tree node parent?

Expand Down
Loading

0 comments on commit e0794f1

Please sign in to comment.