33 lines
747 B
TypeScript
33 lines
747 B
TypeScript
import { World, WorldEntity } from "../engine.ts";
|
|
import { v2, Vec2 } from "../../common/utils.ts";
|
|
import { wait } from "../../common/utils.ts";
|
|
|
|
export class Enemy {
|
|
entity;
|
|
alive;
|
|
|
|
constructor(entity: WorldEntity) {
|
|
this.entity = entity;
|
|
this.alive = true;
|
|
}
|
|
|
|
static spawn(world: World, pos: Vec2) {
|
|
const entity = world.spawn_entity("èé", pos);
|
|
}
|
|
|
|
async spin() {
|
|
while (this.alive) {
|
|
await wait(500);
|
|
const target = this.find_target();
|
|
}
|
|
}
|
|
|
|
find_target() {
|
|
const world = this.entity.world;
|
|
const local_origin = this.entity.position;
|
|
const found = world.get_entities_in_range(local_origin.sub(v2(3, 3)), local_origin.add(v2(3, 3)));
|
|
for (const entity of found) {
|
|
// if (entity.compontents.get())
|
|
}
|
|
}
|
|
}
|