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

add viewAngles vector to Player class

This commit is contained in:
Bryan C 2020-07-03 15:28:18 +08:00
commit 4a6d5d24ad
7 changed files with 27 additions and 2 deletions

View file

@ -12,6 +12,7 @@ export declare class Player {
match: Match; match: Match;
user: UserInfo; user: UserInfo;
position: Vector; position: Vector;
viewAngles: Vector;
health: number; health: number;
maxHealth: number; maxHealth: number;
classId: number; classId: number;

View file

@ -11,6 +11,7 @@ var LifeState;
class Player { class Player {
constructor(match, userInfo) { constructor(match, userInfo) {
this.position = new Vector_1.Vector(0, 0, 0); this.position = new Vector_1.Vector(0, 0, 0);
this.viewAngles = new Vector_1.Vector(0, 0, 0);
this.health = 0; this.health = 0;
this.maxHealth = 0; this.maxHealth = 0;
this.classId = 0; this.classId = 0;

View file

@ -1 +1 @@
{"version":3,"file":"Player.js","sourceRoot":"","sources":["../../src/Data/Player.ts"],"names":[],"mappings":";;AAIA,qCAAgC;AAGhC,IAAY,SAKX;AALD,WAAY,SAAS;IACpB,2CAAS,CAAA;IACT,2CAAS,CAAA;IACT,2CAAS,CAAA;IACT,uDAAe,CAAA;AAChB,CAAC,EALW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAKpB;AAED,MAAa,MAAM;IAclB,YAAY,KAAY,EAAE,QAAkB;QAXrC,aAAQ,GAAW,IAAI,eAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACvC,WAAM,GAAW,CAAC,CAAC;QACnB,cAAS,GAAW,CAAC,CAAC;QACtB,YAAO,GAAW,CAAC,CAAC;QACpB,SAAI,GAAW,CAAC,CAAC;QACjB,cAAS,GAAW,CAAC,CAAC;QACtB,cAAS,GAAa,EAAE,CAAC;QACzB,SAAI,GAAa,EAAE,CAAC;QACpB,cAAS,GAAc,SAAS,CAAC,KAAK,CAAC;QACvC,iBAAY,GAAW,CAAC,CAAC;QAG/B,IAAI,CAAC,KAAK,GAAG,KAAK,C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QACnB,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;IACtB,CAAC;IAED,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,SAAS;aACnB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAa,CAAC;aACpD,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC;aAClC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAW,CAAC,CAAC;IACnE,CAAC;CACD;AA1BD,wBA0BC"}

View file

@ -66,6 +66,9 @@ function handleTFEntity(entity, match, message) {
player.position.y = prop.value.y; player.position.y = prop.value.y;
// set the view angles for the local player since that prop isn't send // set the view angles for the local player since that prop isn't send
player.viewAngle = message.localViewAngles[0].y; player.viewAngle = message.localViewAngles[0].y;
player.viewAngles.x = message.localViewAngles[0].x;
player.viewAngles.y = message.localViewAngles[0].y;
player.viewAngles.z = message.localViewAngles[0].z;
break; break;
case 'DT_TFNonLocalPlayerExclusive.m_vecOrigin': case 'DT_TFNonLocalPlayerExclusive.m_vecOrigin':
player.position.x = prop.value.x; player.position.x = prop.value.x;
@ -77,11 +80,19 @@ function handleTFEntity(entity, match, message) {
case 'DT_TFNonLocalPlayerExclusive.m_vecOrigin[2]': case 'DT_TFNonLocalPlayerExclusive.m_vecOrigin[2]':
player.position.z = prop.value; player.position.z = prop.value;
break; break;
case 'DT_TFNonLocalPlayerExclusive.m_angEyeAngles[0]':
player.viewAngles.y = prop.value;
break;
case 'DT_TFNonLocalPlayerExclusive.m_angEyeAngles[1]': case 'DT_TFNonLocalPlayerExclusive.m_angEyeAngles[1]':
player.viewAngle = prop.value; player.viewAngle = prop.value;
player.viewAngles.x = prop.value;
break;
case 'DT_TFLocalPlayerExclusive.m_angEyeAngles[0]':
player.viewAngles.y = prop.value;
break; break;
case 'DT_TFLocalPlayerExclusive.m_angEyeAngles[1]': case 'DT_TFLocalPlayerExclusive.m_angEyeAngles[1]':
player.viewAngle = prop.value; player.viewAngle = prop.value;
player.viewAngles.x = prop.value;
break; break;
case 'DT_BasePlayer.m_lifeState': case 'DT_BasePlayer.m_lifeState':
player.lifeState = prop.value; player.lifeState = prop.value;

File diff suppressed because one or more lines are too long

View file

@ -16,6 +16,7 @@ export class Player {
public match: Match; public match: Match;
public user: UserInfo; public user: UserInfo;
public position: Vector = new Vector(0, 0, 0); public position: Vector = new Vector(0, 0, 0);
public viewAngles: Vector = new Vector(0, 0, 0);
public health: number = 0; public health: number = 0;
public maxHealth: number = 0; public maxHealth: number = 0;
public classId: number = 0; public classId: number = 0;

View file

@ -74,6 +74,9 @@ export function handleTFEntity(entity: PacketEntity, match: Match, message: Pack
// set the view angles for the local player since that prop isn't send // set the view angles for the local player since that prop isn't send
player.viewAngle = message.localViewAngles[0].y; player.viewAngle = message.localViewAngles[0].y;
player.viewAngles.x = message.localViewAngles[0].x;
player.viewAngles.y = message.localViewAngles[0].y;
player.viewAngles.z = message.localViewAngles[0].z;
break; break;
case 'DT_TFNonLocalPlayerExclusive.m_vecOrigin': case 'DT_TFNonLocalPlayerExclusive.m_vecOrigin':
player.position.x = (prop.value as Vector).x; player.position.x = (prop.value as Vector).x;
@ -85,11 +88,19 @@ export function handleTFEntity(entity: PacketEntity, match: Match, message: Pack
case 'DT_TFNonLocalPlayerExclusive.m_vecOrigin[2]': case 'DT_TFNonLocalPlayerExclusive.m_vecOrigin[2]':
player.position.z = prop.value as number; player.position.z = prop.value as number;
break; break;
case 'DT_TFNonLocalPlayerExclusive.m_angEyeAngles[0]':
player.viewAngles.y = prop.value as number;
break;
case 'DT_TFNonLocalPlayerExclusive.m_angEyeAngles[1]': case 'DT_TFNonLocalPlayerExclusive.m_angEyeAngles[1]':
player.viewAngle = prop.value as number; player.viewAngle = prop.value as number;
player.viewAngles.x = prop.value as number;
break;
case 'DT_TFLocalPlayerExclusive.m_angEyeAngles[0]':
player.viewAngles.y = prop.value as number;
break; break;
case 'DT_TFLocalPlayerExclusive.m_angEyeAngles[1]': case 'DT_TFLocalPlayerExclusive.m_angEyeAngles[1]':
player.viewAngle = prop.value as number; player.viewAngle = prop.value as number;
player.viewAngles.x = prop.value as number;
break; break;
case 'DT_BasePlayer.m_lifeState': case 'DT_BasePlayer.m_lifeState':
player.lifeState = prop.value as number; player.lifeState = prop.value as number;