From eeb12b58c4124b193c073d6f28829ae12baa0f25 Mon Sep 17 00:00:00 2001 From: cha0s Date: Tue, 2 Jul 2024 16:17:07 -0500 Subject: [PATCH] chore: debug --- app/react-components/entity.jsx | 40 ++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/app/react-components/entity.jsx b/app/react-components/entity.jsx index c734055..0f7f8da 100644 --- a/app/react-components/entity.jsx +++ b/app/react-components/entity.jsx @@ -2,22 +2,23 @@ import {Container, Graphics} from '@pixi/react'; import {memo, useCallback} from 'react'; import {useDebug} from '@/context/debug.js'; +import {useMainEntity} from '@/context/main-entity.js'; import Emitter from './emitter.jsx'; import Sprite from './sprite.jsx'; -function VisibleAabb({x0, y0, x1, y1}) { +function Aabb({color, x0, y0, x1, y1}) { const draw = useCallback((g) => { g.clear(); - g.lineStyle(0.5, 0xff00ff); - g.moveTo(-0.25, -0.25); - g.lineTo(x1 - x0, 0); - g.lineTo(x1 - x0, y1 - y0); - g.lineTo(0, y1 - y0); - g.lineTo(0, 0); - }, [x0, x1, y0, y1]); + g.lineStyle(0.5, color); + g.moveTo(x0, y0); + g.lineTo(x1, y0); + g.lineTo(x1, y1); + g.lineTo(x0, y1); + g.lineTo(x0, y0); + }, [color, x0, x1, y0, y1]); return ( - + ); } @@ -46,6 +47,7 @@ function Crosshair({x, y}) { function Entity({entity, ...rest}) { const [debug] = useDebug(); + const [mainEntity] = useMainEntity(); if (!entity) { return false; } @@ -68,12 +70,28 @@ function Entity({entity, ...rest}) { )} {debug && ( - + /> + )} + {debug && entity.Collider && ( + + )} + {debug && mainEntity == entity.id && ( + )} );