Skip to content

Commit 569eca5

Browse files
speedup AI slightly
1 parent f3eb97e commit 569eca5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Entity/AI.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class AI {
8888
/** The current game. */
8989
public game: GameServer;
9090
/** The AI's target. */
91-
public target: Entity & { positionData: PositionGroup, physicsData: PhysicsGroup, relationsData: RelationsGroup, velocity: Vector } | null = null;
91+
public target: ObjectEntity | null = null;
9292
/** The speed at which the ai's owner can move. */
9393
public movementSpeed = 1;
9494
/** The speed at which the ai can reach the target. */
@@ -168,9 +168,9 @@ export class AI {
168168
chunk ^= bitValue;
169169
const id = 32 * i + bitIdx;
170170

171-
const entity = this.game.entities.inner[id] as ObjectEntity;
171+
const entity = this.game.entities.inner[id];
172172
if (!entity || entity.hash === 0) continue;
173-
if (!entity.positionData || !entity.relationsData || !entity.physicsData) continue;
173+
if (!ObjectEntity.isObject(entity)) continue;
174174

175175
if (!entity.isPhysical) continue;
176176
// Check if the target is living
@@ -197,7 +197,7 @@ export class AI {
197197
}
198198
}
199199

200-
return this.target = closestEntity as Entity & { positionData: PositionGroup, physicsData: PhysicsGroup, relationsData: RelationsGroup, velocity: Vector };
200+
return this.target = closestEntity;
201201
}
202202

203203
/** Aims and predicts at the target. */

0 commit comments

Comments
 (0)