In general, the first approach was such
public entities: Entities.GameEntity[] = []; public players: Entities.PlayerEntity[] = []; When I need to find an entity I do it like this.
public findPlayer(playerId: string) { let playerFounded: Entities.PlayerEntity = null; this.players.forEach((player: Entities.PlayerEntity)=> { if (player.client.socketId == playerId) { playerFounded = player; } }); return playerFounded; } The second approach was
public entities: any = {}; public ids: number[] = []; Adding
entityParams[0] - id of number this.entities[entityParams[0]] = entity; this.ids.push(Number(entityParams[0])); Bypass all
this.ids.forEach((entityId)=> { this.entities[entityId] }); well, if you need to quickly get that this.entities[entityId]
Doing such things as best you can, and which of these approaches is better.