mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 06:49:41 +02:00
make pistol shoot differently and not alter controller mappings
This commit is contained in:
parent
1eca1540c6
commit
e67f372bcf
1 changed files with 16 additions and 16 deletions
|
@ -22,6 +22,8 @@
|
||||||
Controller.Standard.LT,
|
Controller.Standard.LT,
|
||||||
Controller.Standard.RT,
|
Controller.Standard.RT,
|
||||||
];
|
];
|
||||||
|
var RELOAD_THRESHOLD = 0.95;
|
||||||
|
|
||||||
Pistol = function() {
|
Pistol = function() {
|
||||||
_this = this;
|
_this = this;
|
||||||
this.equipped = false;
|
this.equipped = false;
|
||||||
|
@ -45,6 +47,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
Pistol.prototype = {
|
Pistol.prototype = {
|
||||||
|
canShoot: false,
|
||||||
|
|
||||||
startEquip: function(id, params) {
|
startEquip: function(id, params) {
|
||||||
this.equipped = true;
|
this.equipped = true;
|
||||||
|
@ -62,6 +65,17 @@
|
||||||
},
|
},
|
||||||
toggleWithTriggerPressure: function() {
|
toggleWithTriggerPressure: function() {
|
||||||
this.triggerValue = Controller.getValue(TRIGGER_CONTROLS[this.hand]);
|
this.triggerValue = Controller.getValue(TRIGGER_CONTROLS[this.hand]);
|
||||||
|
|
||||||
|
if (this.triggerValue < RELOAD_THRESHOLD) {
|
||||||
|
// print('RELOAD');
|
||||||
|
this.canShoot = true;
|
||||||
|
}
|
||||||
|
if (this.canShoot === true && this.triggerValue === 1) {
|
||||||
|
// print('SHOOT');
|
||||||
|
this.fire();
|
||||||
|
this.canShoot = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.triggerValue < DISABLE_LASER_THRESHOLD && this.showLaser === true) {
|
if (this.triggerValue < DISABLE_LASER_THRESHOLD && this.showLaser === true) {
|
||||||
this.showLaser = false;
|
this.showLaser = false;
|
||||||
Overlays.editOverlay(this.laser, {
|
Overlays.editOverlay(this.laser, {
|
||||||
|
@ -74,6 +88,7 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
updateLaser: function() {
|
updateLaser: function() {
|
||||||
var gunProps = Entities.getEntityProperties(this.entityID, ['position', 'rotation']);
|
var gunProps = Entities.getEntityProperties(this.entityID, ['position', 'rotation']);
|
||||||
|
@ -101,7 +116,7 @@
|
||||||
|
|
||||||
preload: function(entityID) {
|
preload: function(entityID) {
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
this.initControllerMapping();
|
// this.initControllerMapping();
|
||||||
this.laser = Overlays.addOverlay("line3d", {
|
this.laser = Overlays.addOverlay("line3d", {
|
||||||
start: ZERO_VECTOR,
|
start: ZERO_VECTOR,
|
||||||
end: ZERO_VECTOR,
|
end: ZERO_VECTOR,
|
||||||
|
@ -150,22 +165,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
initControllerMapping: function() {
|
|
||||||
this.mapping = Controller.newMapping();
|
|
||||||
this.mapping.from(Controller.Standard.LT).hysteresis(0.0, 0.75).to(function(value) {
|
|
||||||
_this.triggerPress(0, value);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
this.mapping.from(Controller.Standard.RT).hysteresis(0.0, 0.75).to(function(value) {
|
|
||||||
_this.triggerPress(1, value);
|
|
||||||
});
|
|
||||||
this.mapping.enable();
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
unload: function() {
|
unload: function() {
|
||||||
this.mapping.disable();
|
|
||||||
Overlays.deleteOverlay(this.laser);
|
Overlays.deleteOverlay(this.laser);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue