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

extract activeWeapon

This commit is contained in:
Robin Appelman 2017-02-22 23:50:30 +01:00
commit eebc2e15cd
2 changed files with 33 additions and 24 deletions

View file

@ -1,6 +1,8 @@
import {UserInfo} from "./UserInfo";
import {Vector} from "./Vector";
import {PlayerCondition} from "./PlayerCondition";
import {Weapon} from "./Weapon";
import {Match} from "./Match";
export enum LifeState {
ALIVE = 0,
@ -9,15 +11,26 @@ export enum LifeState {
RESPAWNABLE = 3
}
export interface Player {
export class Player {
match: Match;
user: UserInfo;
position: Vector;
health: number;
maxHealth: number;
classId: number;
team: number;
viewAngle: number;
weapons: number[];
ammo: number[];
lifeState: LifeState
position: Vector = new Vector(0, 0, 0);
health: number = 0;
maxHealth: number = 0;
classId: number = 0;
team: number = 0;
viewAngle: number = 0;
weaponIds: number[] = [];
ammo: number[] = [];
lifeState: LifeState = LifeState.DEATH;
activeWeapon: number = 0;
constructor(match: Match, userInfo: UserInfo) {
this.match = match;
this.user = userInfo;
}
get weapons(): Weapon[] {
return this.weaponIds.map(id => this.match.weaponMap[this.match.outerMap[id]]);
}
}