<?phpnamespace App\Entities\Objects;/** * The original only runs the objects near the camera (_31e6, table _2ba2): object type => * [left margin, right limit, top margin, bottom limit], active when * cameraX - left < X <= cameraX + right and cameraY - top < Y <= cameraY + bottom * (camera = top-left of the 256x192 screen, X/Y = object position as loaded: block * 32). */final class ActivityWindow{ public const WINDOWS = [ 0x00 => [256, 512, 256, 512], 0x01 => [32, 288, 32, 224], 0x02 => [32, 288, 32, 224], 0x03 => [32, 288, 32, 224], 0x04 => [32, 288, 32, 224], 0x05 => [32, 288, 32, 224], 0x06 => [32, 288, 32, 224], 0x07 => [32, 288, 96, 224], 0x08 => [16, 272, 32, 224], 0x09 => [160, 416, 64, 256], 0x0A => [64, 320, 64, 256], 0x0B => [32, 288, 32, 224], 0x0C => [32, 288, 48, 240], 0x0D => [256, 512, 256, 448], 0x0E => [64, 320, 64, 256], 0x0F => [160, 416, 32, 224], 0x10 => [16, 272, 16, 208], 0x11 => [16, 272, 16, 208], 0x12 => [192, 448, 128, 320], 0x13 => [32, 288, 32, 224], 0x14 => [8, 320, 16, 208], 0x15 => [64, 264, 16, 208], 0x16 => [16, 272, 32, 224], 0x17 => [32, 288, 48, 204], 0x18 => [32, 288, 48, 204], 0x19 => [32, 288, 48, 204], 0x1A => [32, 288, 32, 218], 0x1B => [48, 304, 48, 240], 0x1C => [256, 384, 256, 448], 0x1D => [16, 272, 16, 208], 0x1E => [32, 288, 48, 200], 0x1F => [32, 288, 32, 224], 0x20 => [32, 288, 32, 224], 0x21 => [32, 288, 128, 320], 0x22 => [16, 272, 128, 240], 0x23 => [32, 288, 16, 208], 0x24 => [32, 288, 16, 208], 0x25 => [32, 288, 32, 224], 0x26 => [16, 272, 96, 256], 0x27 => [40, 296, 256, 448], 0x28 => [40, 296, 256, 448], 0x29 => [16, 272, 16, 208], 0x2A => [32, 288, 32, 224], 0x2B => [16, 272, 16, 208], 0x2C => [64, 320, 192, 384], 0x2D => [16, 272, 16, 208], 0x2E => [128, 384, 64, 448], 0x2F => [32, 288, 32, 224], 0x30 => [2048, 2048, 48, 240], 0x31 => [16, 272, 32, 224], 0x32 => [32, 288, 32, 224], 0x33 => [0, 256, 0, 192], 0x34 => [512, 768, 512, 704], 0x35 => [16, 272, 16, 208], 0x36 => [64, 320, 64, 256], 0x37 => [16, 272, 16, 208], 0x38 => [64, 320, 32, 224], 0x39 => [128, 384, 80, 208], 0x3A => [16, 272, 16, 208], 0x3B => [16, 272, 96, 288], 0x3C => [16, 272, 16, 208], 0x3D => [96, 352, 96, 288], 0x3E => [16, 272, 16, 208], 0x3F => [32, 288, 32, 224], 0x40 => [8192, 8448, 32, 224], 0x41 => [8, 264, 8, 200], 0x42 => [32, 288, 32, 224], 0x43 => [32, 288, 32, 224], 0x44 => [32, 288, 32, 224], 0x45 => [40, 296, 40, 232], 0x46 => [96, 352, 32, 224], 0x47 => [256, 512, 256, 448], 0x48 => [16, 272, 16, 208], 0x49 => [16, 272, 256, 448], 0x4A => [16, 272, 16, 208], 0x4B => [16, 272, 16, 208], 0x4C => [32, 288, 32, 224], 0x4D => [32, 288, 32, 224], 0x4E => [56, 296, 48, 240], 0x4F => [32, 288, 32, 224], 0x50 => [16, 272, 16, 208], 0x51 => [32, 288, 32, 224], 0x52 => [32, 288, 32, 224], 0x53 => [256, 480, 192, 384], 0x54 => [256, 512, 256, 448], 0x55 => [2048, 2304, 2048, 2240], ]; /** @param array{0: float, 1: float} $camera original camera (see Camera::getRomCamera) */ public static function contains(int $type, float $x, float $y, array $camera): bool { [$left, $right, $top, $bottom] = self::WINDOWS[$type] ?? [32, 288, 32, 224]; [$cx, $cy] = $camera; return $x > $cx - $left && $x <= $cx + $right && $y > $cy - $top && $y <= $cy + $bottom; } /** * Same window around our real view (top-left x, y, width, height), wider than 256x192 when zoomed out: * the margins of the type are kept on each side. With the 256x192 view this is the original window. */ public static function containsView(int $type, float $x, float $y, array $view): bool { [$left, $right, $top, $bottom] = self::WINDOWS[$type] ?? [32, 288, 32, 224]; [$vx, $vy, $vw, $vh] = $view; return $x > $vx - $left && $x <= $vx + $vw + $right - 256 && $y > $vy - $top && $y <= $vy + $vh + $bottom - 192; }}