-
Notifications
You must be signed in to change notification settings - Fork 1
Labels
scope:insimInSimInSim
Description
Some packet properties require manual bitwise comparison in order to get the desired information, resulting in worse developer experience.
The idea is to use JavaScript class getters to expose dynamic class instance properties based on other packet values.
Example solution: IS_NPL packet
Implementation
class IS_NPL extends Packet {
// ...
@byte() PType: PlayerType | 0 = 0;
// ... new code below
public get isFemale() {
return (this.PType & PlayerType.FEMALE) !== 0;
}
}Usage
inSim.on(PacketType.IS_NPL, (packet) => {
console.log((packet.PType & PlayerType.FEMALE) !== 0); // raw
console.log(packet.isFemale); // computed property
});Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
scope:insimInSimInSim