Skip to content

Commit

Permalink
Refactor input classes to handle null values for enabled property
Browse files Browse the repository at this point in the history
  • Loading branch information
marklundin committed Jan 17, 2025
1 parent 7f37af6 commit c976870
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions scripts/esm/first-person-controller.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ class KeyboardMouseInput {
if (value === this._enabled) {
return;
}
this._enabled = value;
this._enabled = value ?? this._enabled;

if (value) {
if (this._enabled) {
this._bind();
} else {
this._unbind();
Expand Down Expand Up @@ -300,9 +300,9 @@ class MobileInput {
if (value === this._enabled) {
return;
}
this._enabled = value;
this._enabled = value ?? this._enabled;

if (value) {
if (this._enabled) {
this._bind();
} else {
this._unbind();
Expand Down Expand Up @@ -575,7 +575,7 @@ class GamePadInput {
if (value === this._enabled) {
return;
}
this._enabled = value;
this._enabled = value ?? this._enabled;
}

get enabled() {
Expand Down Expand Up @@ -894,7 +894,7 @@ class FirstPersonController extends Script {
set mobileDeadZone(value) {
this._mobileDeadZone = value ?? this._mobileDeadZone;
if (this._mobileInput) {
this._mobileInput.deadZone = value;
this._mobileInput.deadZone = this._mobileDeadZone;
}
}

Expand All @@ -911,7 +911,7 @@ class FirstPersonController extends Script {
set mobileTurnSpeed(value) {
this._mobileTurnSpeed = value ?? this._mobileTurnSpeed;
if (this._mobileInput) {
this._mobileInput.turnSpeed = value;
this._mobileInput.turnSpeed = this._mobileTurnSpeed;
}
}

Expand Down Expand Up @@ -957,7 +957,7 @@ class FirstPersonController extends Script {
set gamePadDeadZoneLow(value) {
this._gamePadDeadZoneLow = value ?? this._gamePadDeadZoneLow;
if (this._gamePadInput) {
this._gamePadInput.deadZoneLow = value;
this._gamePadInput.deadZoneLow = this._gamePadDeadZoneLow;
}
}

Expand All @@ -975,7 +975,7 @@ class FirstPersonController extends Script {
set gamePadDeadZoneHigh(value) {
this._gamePadDeadZoneHigh = value ?? this._gamePadDeadZoneHigh;
if (this._gamePadInput) {
this._gamePadInput.deadZoneHigh = value;
this._gamePadInput.deadZoneHigh = this._gamePadDeadZoneHigh;
}
}

Expand All @@ -992,7 +992,7 @@ class FirstPersonController extends Script {
set gamePadTurnSpeed(value) {
this._gamePadTurnSpeed = value ?? this._gamePadTurnSpeed;
if (this._gamePadInput) {
this._gamePadInput.turnSpeed = value;
this._gamePadInput.turnSpeed = this._gamePadTurnSpeed;
}
}

Expand Down

0 comments on commit c976870

Please sign in to comment.