Skip to content

Commit

Permalink
fix(core): onDeath, onTakeDamage enum type generic inference, getKeys…
Browse files Browse the repository at this point in the history
… return hump
  • Loading branch information
dockfries committed Dec 2, 2023
1 parent 4ff710f commit 258667b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/controllers/player/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ export class Player {
return { x, y, z };
}
getKeys() {
const [keys, updown, leftright] = f.GetPlayerKeys(this.id);
return { keys, updown, leftright };
const [keys, upDown, leftRight] = f.GetPlayerKeys(this.id);
return { keys, upDown, leftRight };
}
getIp(): string {
return f.GetPlayerIp(this.id);
Expand Down
14 changes: 12 additions & 2 deletions packages/core/src/controllers/player/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ export const [onClickPlayer] = defineEvent({
},
});

export const [onDeath] = defineEvent({
export const [onDeath] = defineEvent<{
player: Player;
killer: Player | InvalidEnum.PLAYER_ID;
reason: number;
}>({
name: "OnPlayerDeath",
beforeEach(id: number, killer: number, reason: number) {
return {
Expand Down Expand Up @@ -173,7 +177,13 @@ export const [onStreamOut] = defineEvent({
},
});

export const [onTakeDamage] = defineEvent({
export const [onTakeDamage] = defineEvent<{
player: Player;
damage: Player | InvalidEnum.PLAYER_ID;
amount: number;
weapon: WeaponEnum;
bodyPart: BodyPartsEnum;
}>({
name: "OnPlayerTakeDamage",
beforeEach(
id: number,
Expand Down

0 comments on commit 258667b

Please sign in to comment.