factor player direction as component property

This commit is contained in:
JOLIMAITRE Matthieu 2024-10-20 22:43:16 +02:00
parent e502ca00de
commit fb85af7c40
2 changed files with 15 additions and 10 deletions

View file

@ -1,4 +1,3 @@
import { assert } from "https://deno.land/std@0.221.0/assert/assert.ts";
import { v2 } from "../../common/utils.ts";
import { Vec2 } from "../../common/utils.ts";
import { CompDisplay } from "../components/display.ts";
@ -19,7 +18,9 @@ export class CompEnemy {
find_target_from(engine: Engine, pos: Vec2, range: number) {
const radius = v2(range, range);
const found = engine.one(Query.with(CompPlayer).with(CompId).and(query_in_rect(pos.sub(radius), pos.add(radius))));
const found = engine.one(
Query.with(CompPlayer).with(CompId).and(query_in_rect(pos.sub(radius), pos.add(radius))),
);
if (found === null) {
this.target = null;
return;