Code cleanup

This commit is contained in:
Jarrod Doyle 2024-10-27 09:48:21 +00:00
parent c162a5028d
commit a9d2d2e193
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 13 additions and 21 deletions

View File

@ -95,10 +95,10 @@ class Program
// We can't do this in parallel which is why it's being done afterwards rather than // We can't do this in parallel which is why it's being done afterwards rather than
// as we go // as we go
var map = new Dictionary<ushort, List<WorldRep.LightTable.AnimCellMap>>(); var map = new Dictionary<ushort, List<WorldRep.LightTable.AnimCellMap>>();
for (var i = 0; i < worldRep.Cells.Length; i++) for (ushort i = 0; i < worldRep.Cells.Length; i++)
{ {
var cell = worldRep.Cells[i]; var cell = worldRep.Cells[i];
for (var j = 0; j < cell.AnimLightCount; j++) for (ushort j = 0; j < cell.AnimLightCount; j++)
{ {
var animLightIdx = cell.AnimLights[j]; var animLightIdx = cell.AnimLights[j];
if (!map.TryGetValue(animLightIdx, out var value)) if (!map.TryGetValue(animLightIdx, out var value))
@ -108,8 +108,8 @@ class Program
} }
value.Add(new WorldRep.LightTable.AnimCellMap value.Add(new WorldRep.LightTable.AnimCellMap
{ {
CellIndex = (ushort)i, CellIndex = i,
LightIndex = (ushort)j, LightIndex = j,
}); });
} }
} }
@ -120,24 +120,16 @@ class Program
} }
foreach (var (lightIdx, animCellMaps) in map) foreach (var (lightIdx, animCellMaps) in map)
{ {
// Get the appropriate property!! // We need to update the object property so it knows its mapping range
var light = lights.Find((l) => l.anim && l.lightTableIndex == lightIdx); // TODO: Handle nulls
foreach (var prop in animLightChunk.properties) var light = lights.Find(l => l.anim && l.lightTableIndex == lightIdx);
{ var prop = animLightChunk.properties.Find(p => p.objectId == light.objId);
if (prop.objectId == light.objId)
{
prop.LightTableLightIndex = lightIdx; prop.LightTableLightIndex = lightIdx;
prop.LightTableMapIndex = (ushort)worldRep.LightingTable.AnimMapCount; prop.LightTableMapIndex = (ushort)worldRep.LightingTable.AnimMapCount;
prop.CellsReached = (ushort)animCellMaps.Count; prop.CellsReached = (ushort)animCellMaps.Count;
break;
}
}
foreach (var animCellMap in animCellMaps) worldRep.LightingTable.AnimCellMaps.AddRange(animCellMaps);
{ worldRep.LightingTable.AnimMapCount += animCellMaps.Count;
worldRep.LightingTable.AnimCellMaps.Add(animCellMap);
worldRep.LightingTable.AnimMapCount++;
}
} }
} }