Skip to content

Commit

Permalink
feat(tracker-emulation): add removeSensor and clearSensors (#35)
Browse files Browse the repository at this point in the history
feat(tracker-emulation): add `removeSensor` and `clearSensors`

---------

Co-authored-by: DevMiner <devminer@devminer.xyz>
  • Loading branch information
JovannMC and TheDevMinerTV authored Jun 9, 2024
1 parent 6bf18f7 commit abebffd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/popular-socks-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@slimevr/tracker-emulation": patch
---

added the ability to remove all sensors or individually
15 changes: 11 additions & 4 deletions packages/tracker-emulation/src/EmulatedTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ export class EmulatedTracker extends (EventEmitter as {
return sensor;
}

removeSensor(sensor: EmulatedSensor) {
const index = this.sensors.indexOf(sensor);
if (index === -1) return;

this.sensors.splice(index, 1);
}

async clearSensors() {
this.sensors = [];
}

async init() {
if (this.state.status !== 'initializing') return;

Expand Down Expand Up @@ -171,10 +182,6 @@ export class EmulatedTracker extends (EventEmitter as {
this.emit('stopped-searching-for-server', 'manual');
}

private log(msg: string) {
console.log(`[Tracker:${this.mac}] ${msg}`);
}

async changeBatteryLevel(batteryVoltage: number, batteryPercentage: number) {
this.batteryVoltage = batteryVoltage;
this.batteryPercentage = batteryPercentage;
Expand Down

0 comments on commit abebffd

Please sign in to comment.