feat(vfx): decode retail hooks and typed tables

Replace the incomplete package path with one DatCollection-backed compatibility seam for PhysicsScripts and Animations. Preserve CreateBlockingParticle's inherited payload and following cursor, route every production and audit consumer through the corrected loaders, and apply retail's post-UnPack StartTime ordering.

Add exact stored-order PhysicsScriptTable upper-threshold resolution, high-byte DID and embedded-ID validation, plus live effect profiles with Setup-to-PhysicsDesc precedence across top-level and attached entity lifetimes. Keep blocking execution deferred and narrow TS-11 accordingly.

Pin synthetic malformed/cursor/order fixtures, installed-DAT blocking and recall audits, high-index IDs, IEEE boundaries, profile teardown, and ordinary decoder parity; synchronize architecture, inventory, milestones, roadmap, research, and memory.

Co-Authored-By: Codex <noreply@openai.com>
This commit is contained in:
Erik 2026-07-14 08:17:44 +02:00
parent 8dd996053d
commit 363e046112
31 changed files with 1102 additions and 73 deletions

View file

@ -0,0 +1,64 @@
using DatReaderWriter.DBObjs;
using DatReaderWriter.Enums;
using DatReaderWriter.Types;
namespace AcDream.Core.Vfx;
/// <summary>
/// Exact retail PhysicsScriptTable lookup: hash by raw script type, then scan
/// that type's entries in stored DAT order for the first upper threshold.
/// </summary>
/// <remarks>
/// Port of <c>PhysicsScriptTable::GetScript</c> at <c>0x00521E40</c> and
/// <c>PhysicsScriptTableData::GetScript</c> at <c>0x00521A20</c>.
/// </remarks>
public sealed class PhysicsScriptTableResolver
{
private readonly Func<uint, PhysicsScriptTable?> _loadTable;
public PhysicsScriptTableResolver(Func<uint, PhysicsScriptTable?> loadTable)
=> _loadTable = loadTable ?? throw new ArgumentNullException(nameof(loadTable));
/// <summary>
/// Returns the selected PhysicsScript DID, or null for a missing table or
/// type, an unordered/above-range intensity, or an invalid script DID.
/// </summary>
public uint? Resolve(uint tableDid, uint rawScriptType, float intensity)
{
if (!IsPhysicsScriptTableDid(tableDid))
return null;
PhysicsScriptTable? table = _loadTable(tableDid);
if (table is null
|| table.Id != tableDid
|| !table.ScriptTable.TryGetValue(
unchecked((PlayScript)rawScriptType),
out PhysicsScriptTableData? data))
{
return null;
}
// Retail compares intensity <= Mod. Do not sort: equal and duplicate
// thresholds resolve to the first stored entry. IEEE comparisons make
// NaN fall through all entries, +infinity fall through finite entries,
// and -infinity select the first finite threshold.
foreach (ScriptAndModData entry in data.Scripts)
{
if (intensity <= entry.Mod)
{
uint scriptDid = entry.ScriptId.DataId;
return IsPhysicsScriptDid(scriptDid) ? scriptDid : null;
}
}
return null;
}
public static bool IsPhysicsScriptDid(uint did) =>
// AC data IDs encode the DBObj type in the high byte; the remaining
// 24 bits are the file index and must not be truncated to 16 bits.
(did & 0xFF000000u) == 0x33000000u;
public static bool IsPhysicsScriptTableDid(uint did) =>
(did & 0xFF000000u) == 0x34000000u;
}