diff --git a/src/extensions/entity_manager.ts b/src/extensions/entity_manager.ts index 820bed0..d329e18 100644 --- a/src/extensions/entity_manager.ts +++ b/src/extensions/entity_manager.ts @@ -26,6 +26,8 @@ class EntityManager extends Extension { this.#pentagonHook(); + this.#hexagonHook(); + //when is a bullet being drawn? //when is a player being drawn? @@ -208,6 +210,25 @@ class EntityManager extends Extension { }); } + #hexagonHook(): void { + CanvasKit.hookPolygon(6, (vertices, ctx) => { + vertices = vertices.map((x) => scaling.toArenaPos(x)); + + const position = Vector.centroid(...vertices); + const radius = Math.round(Vector.radius(...vertices)); + const color = ctx.fillStyle as EntityColor; + + let type = EntityType.UNKNOWN; + switch (radius) { + case 100: + if (EntityColor.Hexagon === color) type = EntityType.Hexagon; + break; + } + + this.#add(type, position, { color, radius }); + }); + } + #playerHook(): void { let index = 0; diff --git a/src/types/entity.ts b/src/types/entity.ts index c77cf59..7c97e7e 100644 --- a/src/types/entity.ts +++ b/src/types/entity.ts @@ -9,6 +9,7 @@ export enum EntityType { Square, Triangle, Pentagon, + Hexagon, AlphaPentagon, Crasher, UNKNOWN, @@ -22,6 +23,7 @@ export enum EntityColor { Square = '#ffe869', Triangle = '#fc7677', Pentagon = '#768dfc', + Hexagon = '#35c5db', // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values AlphaPentagon = '#768dfc', Crasher = '#f177dd',