1
0
Fork 0
mirror of https://github.com/demostf/demo.js synced 2026-06-04 00:54:14 +02:00

use map for weapons

This commit is contained in:
Robin Appelman 2017-09-02 15:57:41 +02:00
commit 6eebb18251
3 changed files with 22 additions and 22 deletions

View file

@ -34,7 +34,7 @@ export class Match {
public entityClasses: Map<EntityId, ServerClass> = new Map();
public sendTables: Map<string, SendTable> = new Map();
public baseLineCache: Map<ServerClass, PacketEntity> = new Map();
public weaponMap: {[entityId: string]: Weapon};
public weaponMap: Map<EntityId, Weapon> = new Map();
public outerMap: {[outer: number]: number};
public teams: Map<TeamNumber, Team> = new Map();
public teamEntityMap: Map<EntityId, Team>;
@ -61,7 +61,6 @@ export class Match {
boundaryMin: {x: 0, y: 0, z: 0},
boundaryMax: {x: 0, y: 0, z: 0},
};
this.weaponMap = {};
this.outerMap = {};
this.teamEntityMap = new Map();
this.version = 0;

View file

@ -31,6 +31,8 @@ export class Player {
}
get weapons(): Weapon[] {
return this.weaponIds.map((id) => this.match.weaponMap[this.match.outerMap[id]]);
return this.weaponIds
.map((id) => this.match.weaponMap.get(this.match.outerMap[id]) as Weapon)
.filter((weapon: Weapon | undefined) => (typeof weapon !== 'undefined'));
}
}