Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/entity_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { CanvasKit } from './canvas_kit';
import { Entity, EntityType, EntityColor, TeamColors } from './entity';
import { arenaScaling } from './arena_scaling';
import { game } from './game';
import { playerMovement } from './player_movement';

/**
* Entity Manager is used to access the information about the entities, that are currently drawn on the screen.
Expand Down Expand Up @@ -34,6 +35,19 @@ class EntityManager {
return this.#entities;
}

/**
*
* @returns The own player entity
*/
getPlayer(): Entity {
const player = this.#entities.filter(
(entity) =>
entity.type == EntityType.Player && Vector.distance(entity.position, playerMovement.position) < 28
);

return player[0];
}

/**
* Adds the entity to `#entitiesUpdated`.
*
Expand Down