Skip to content

Commit 02b7bf2

Browse files
committed
Merge branch 'resource-continued' into staging
2 parents 7c7c085 + 95bb6b3 commit 02b7bf2

11 files changed

Lines changed: 209 additions & 141 deletions

File tree

CathodeLib/Scripts/CATHODE/CollisionMaps.cs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,15 @@ override protected bool LoadInternal()
2929

3030
using (BinaryReader reader = new BinaryReader(File.OpenRead(_filepath)))
3131
{
32-
//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.
32+
//The way this works:
33+
// - First 18 entries are empty
34+
// - Next set of entries are all the COLLISION_MAPPING resources referenced by COMMANDS.PAK (hence they have no composite_instance_id, as the composites aren't instanced - but they do have entity_ids)
35+
// - There are then a few entries that have composite_instance_ids set but I can't resolve them - perhaps these are things from GLOBAL?
36+
// - Then there's all the instanced entities with resolvable composite_instance_ids
3337

34-
//first 18 are always null
35-
36-
//always first 247 are the same? 18 null and the rest in required assets?
37-
38-
//note: some of the things we skip here actually contain useful info, but the game doesn't read it so there's no point us bothering with it
39-
40-
41-
42-
//NOTE: skipping first 18 as they're always empty, at least, for what we parse
4338
reader.BaseStream.Position = 4;
4439
int entryCount = reader.ReadInt32();
45-
reader.BaseStream.Position += (48 * 18);
46-
for (int i = 0; i < entryCount - 18; i++)
40+
for (int i = 0; i < entryCount; i++)
4741
{
4842
Entry entry = new Entry();
4943

@@ -106,15 +100,16 @@ override protected bool LoadInternal()
106100

107101
override protected bool SaveInternal()
108102
{
103+
//composite_instance_id defo has something to do with the ordering as all the zeros are first
104+
105+
109106
//Entries = Entries.OrderBy(o => o.entity.entity_id.ToUInt32() + o.id.ToUInt32()).ThenBy(o => o.entity.composite_instance_id.ToUInt32()).ThenBy(o => o.zone_id.ToUInt32()).ToList();
110107

111108
using (BinaryWriter writer = new BinaryWriter(File.OpenWrite(_filepath)))
112109
{
113110
writer.BaseStream.SetLength(0);
114-
writer.Write((Entries.Count + 18) * 48);
115-
writer.Write(Entries.Count + 18);
116-
117-
writer.Write(new byte[18 * 48]);
111+
writer.Write((Entries.Count) * 48);
112+
writer.Write(Entries.Count);
118113

119114
for (int i = 0; i < Entries.Count; i++)
120115
{

CathodeLib/Scripts/CATHODE/Commands.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ override protected bool LoadInternal()
189189
reader_parallel.BaseStream.Position = (offsetPairs[x].GlobalOffset * 4) + (y * 12);
190190
AliasEntity overrider = new AliasEntity(new ShortGuid(reader_parallel));
191191
int NumberOfParams = JumpToOffset(reader_parallel);
192-
overrider.alias.path.AddRange(Utilities.ConsumeArray<ShortGuid>(reader_parallel, NumberOfParams));
192+
overrider.alias.path = Utilities.ConsumeArray<ShortGuid>(reader_parallel, NumberOfParams);
193193
composite.aliases.Add(overrider);
194194
break;
195195
}
@@ -214,7 +214,7 @@ override protected bool LoadInternal()
214214
ProxyEntity thisProxy = new ProxyEntity(new ShortGuid(reader_parallel));
215215
int resetPos = (int)reader_parallel.BaseStream.Position + 8; //TODO: This is a HACK - I need to rework JumpToOffset to make a temp stream
216216
int NumberOfParams = JumpToOffset(reader_parallel);
217-
thisProxy.proxy.path.AddRange(Utilities.ConsumeArray<ShortGuid>(reader_parallel, NumberOfParams)); //Last is always 0x00, 0x00, 0x00, 0x00
217+
thisProxy.proxy.path = Utilities.ConsumeArray<ShortGuid>(reader_parallel, NumberOfParams); //Last is always 0x00, 0x00, 0x00, 0x00
218218
reader_parallel.BaseStream.Position = resetPos;
219219
ShortGuid idCheck = new ShortGuid(reader_parallel);
220220
if (idCheck != thisProxy.shortGUID) throw new Exception("Proxy ID mismatch!");
@@ -315,7 +315,7 @@ override protected bool LoadInternal()
315315
header.parameterSubID = new ShortGuid(reader_parallel);
316316

317317
int hierarchyCount = JumpToOffset(reader_parallel);
318-
header.connectedEntity.path = Utilities.ConsumeArray<ShortGuid>(reader_parallel, hierarchyCount).ToList<ShortGuid>();
318+
header.connectedEntity.path = Utilities.ConsumeArray<ShortGuid>(reader_parallel, hierarchyCount);
319319
animEntity.connections.Add(header);
320320
}
321321

@@ -397,7 +397,7 @@ override protected bool LoadInternal()
397397
TriggerSequence.Entity thisTrigger = new TriggerSequence.Entity();
398398
thisTrigger.timing = reader_parallel.ReadSingle();
399399
reader_parallel.BaseStream.Position = hierarchyOffset;
400-
thisTrigger.connectedEntity.path = Utilities.ConsumeArray<ShortGuid>(reader_parallel, hierarchyCount).ToList<ShortGuid>();
400+
thisTrigger.connectedEntity.path = Utilities.ConsumeArray<ShortGuid>(reader_parallel, hierarchyCount);
401401
trigEntity.entities.Add(thisTrigger);
402402
}
403403

@@ -849,7 +849,7 @@ override protected bool SaveInternal()
849849
List<OffsetPair> offsetPairs = new List<OffsetPair>(reshuffledAliases[i].Count);
850850
for (int p = 0; p < reshuffledAliases[i].Count; p++)
851851
{
852-
offsetPairs.Add(new OffsetPair(writer.BaseStream.Position, reshuffledAliases[i][p].alias.path.Count));
852+
offsetPairs.Add(new OffsetPair(writer.BaseStream.Position, reshuffledAliases[i][p].alias.path.Length));
853853
Utilities.Write<ShortGuid>(writer, reshuffledAliases[i][p].alias.path);
854854
}
855855

@@ -888,7 +888,7 @@ override protected bool SaveInternal()
888888
List<OffsetPair> offsetPairs = new List<OffsetPair>();
889889
for (int p = 0; p < Entries[i].proxies.Count; p++)
890890
{
891-
offsetPairs.Add(new OffsetPair(writer.BaseStream.Position, Entries[i].proxies[p].proxy.path.Count));
891+
offsetPairs.Add(new OffsetPair(writer.BaseStream.Position, Entries[i].proxies[p].proxy.path.Length));
892892
Utilities.Write<ShortGuid>(writer, Entries[i].proxies[p].proxy.path);
893893
}
894894

@@ -983,7 +983,7 @@ override protected bool SaveInternal()
983983
Utilities.Write(writer, CommandsUtils.GetDataTypeGUID(header.parameterDataType));
984984
Utilities.Write(writer, header.parameterSubID);
985985
writer.Write(hierarchyOffsets[pp] / 4);
986-
writer.Write(header.connectedEntity.path.Count);
986+
writer.Write(header.connectedEntity.path.Length);
987987
}
988988

989989
List<int> internalOffsets = new List<int>(cageAnimationEntities[i][p].animations.Count);
@@ -1094,7 +1094,7 @@ override protected bool SaveInternal()
10941094
for (int pp = 0; pp < triggerSequenceEntities[i][p].entities.Count; pp++)
10951095
{
10961096
writer.Write(hierarchyOffsets[pp] / 4);
1097-
writer.Write(triggerSequenceEntities[i][p].entities[pp].connectedEntity.path.Count);
1097+
writer.Write(triggerSequenceEntities[i][p].entities[pp].connectedEntity.path.Length);
10981098
writer.Write(triggerSequenceEntities[i][p].entities[pp].timing);
10991099
}
11001100

CathodeLib/Scripts/CATHODE/CommandsPAK/Components/Composite.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ public VariableEntity AddVariable(string parameter, DataType type, bool addDefau
105105
}
106106

107107
/* Add a new proxy entity */
108-
public ProxyEntity AddProxy(Commands commands, List<ShortGuid> hierarchy, bool addDefaultParam = false)
108+
public ProxyEntity AddProxy(Commands commands, ShortGuid[] hierarchy, bool addDefaultParam = false)
109109
{
110110
CommandsUtils.ResolveHierarchy(commands, this, hierarchy, out Composite targetComposite, out string str);
111-
Entity ent = targetComposite.GetEntityByID(hierarchy[hierarchy.Count - 2]);
111+
Entity ent = targetComposite.GetEntityByID(hierarchy[hierarchy.Length - 2]);
112112
if (ent.variant != EntityVariant.FUNCTION) return null;
113113

114114
ProxyEntity proxy = new ProxyEntity(hierarchy, ((FunctionEntity)ent).function, addDefaultParam);
@@ -117,7 +117,7 @@ public ProxyEntity AddProxy(Commands commands, List<ShortGuid> hierarchy, bool a
117117
}
118118

119119
/* Add a new alias entity */
120-
public AliasEntity AddAlias(List<ShortGuid> hierarchy)
120+
public AliasEntity AddAlias(ShortGuid[] hierarchy)
121121
{
122122
AliasEntity alias = new AliasEntity(hierarchy);
123123
aliases.Add(alias);

0 commit comments

Comments
 (0)