using System.Collections.Generic;
using System.Numerics;
using DatReaderWriter.Enums;
namespace AcDream.Core.Physics;
///
/// Indoor walking Phase 2 (2026-05-19). Cached building portal data
/// for outdoor→indoor cell entry. One per outdoor landcell that contains
/// a building stab. Mirrors retail's BuildingObj.Portals array
/// (per the pseudocode doc §"LandCell.find_transit_cells").
///
public sealed class BuildingPhysics
{
public required Matrix4x4 WorldTransform { get; init; }
public required Matrix4x4 InverseWorldTransform { get; init; }
public required IReadOnlyList Portals { get; init; }
}
///
/// One building portal: the connection from a SortCell's BuildingObj to
/// an interior EnvCell. ExactMatch is decoded from
/// bit 0 (PortalFlags.ExactMatch = 0x0001).
///
public readonly struct BldPortalInfo
{
public BldPortalInfo(uint otherCellId, ushort otherPortalId, ushort flags)
{
OtherCellId = otherCellId;
OtherPortalId = otherPortalId;
Flags = flags;
}
/// Full id of the interior EnvCell this portal connects to.
public uint OtherCellId { get; }
/// The portal id within the destination EnvCell.
public ushort OtherPortalId { get; }
public ushort Flags { get; }
///
/// Bit 0 of (DatReaderWriter.Enums.PortalFlags.ExactMatch).
///
///
/// Reserved per retail's CBldPortal::exact_match. NOT currently
/// consumed by — every
/// portal overlap is treated as a valid entry trigger. If a future
/// regression surfaces (e.g., a building entered by overlapping a
/// non-exact-match portal), wire this into the entry test.
///
///
public bool ExactMatch => (Flags & (ushort)PortalFlags.ExactMatch) != 0;
}