mirror of
https://github.com/overte-org/overte.git
synced 2025-04-18 14:57:00 +02:00
update toybox toys to use changed grab entityMethod calls
This commit is contained in:
parent
3e71efcdbb
commit
ecf22cd8b8
8 changed files with 55 additions and 111 deletions
|
@ -334,9 +334,8 @@ function MyController(hand) {
|
|||
};
|
||||
|
||||
this.callEntityMethodOnGrabbed = function(entityMethodName) {
|
||||
// print("Entity Method: " + entityMethodName + ", hand: " + this.hand);
|
||||
Entities.callEntityMethod(this.grabbedEntity, entityMethodName, [JSON.stringify(this.hand),
|
||||
JSON.stringify(MyAvatar.SessionUUID)]);
|
||||
var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
|
||||
Entities.callEntityMethod(this.grabbedEntity, entityMethodName, args);
|
||||
}
|
||||
|
||||
this.setState = function(newState) {
|
||||
|
@ -1089,9 +1088,7 @@ function MyController(hand) {
|
|||
this.continueDistanceHolding = function() {
|
||||
if (this.triggerSmoothedReleased()) {
|
||||
this.setState(STATE_RELEASE);
|
||||
if (this.isInitialGrab) {
|
||||
this.callEntityMethodOnGrabbed("releaseGrab");
|
||||
}
|
||||
this.callEntityMethodOnGrabbed("releaseGrab");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1325,9 +1322,7 @@ function MyController(hand) {
|
|||
|
||||
if (this.state == STATE_NEAR_GRABBING && this.triggerSmoothedReleased()) {
|
||||
this.setState(STATE_RELEASE);
|
||||
if (this.isInitialGrab) {
|
||||
this.callEntityMethodOnGrabbed("releaseGrab");
|
||||
}
|
||||
this.callEntityMethodOnGrabbed("releaseGrab");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1413,9 +1408,7 @@ function MyController(hand) {
|
|||
this.continueNearGrabbing = function() {
|
||||
if (this.state == STATE_CONTINUE_NEAR_GRABBING && this.triggerSmoothedReleased()) {
|
||||
this.setState(STATE_RELEASE);
|
||||
if (this.isInitialGrab) {
|
||||
this.callEntityMethodOnGrabbed("releaseGrab");
|
||||
}
|
||||
this.callEntityMethodOnGrabbed("releaseGrab");
|
||||
return;
|
||||
}
|
||||
if (this.state == STATE_CONTINUE_EQUIP_BD && this.bumperReleased()) {
|
||||
|
@ -1429,9 +1422,7 @@ function MyController(hand) {
|
|||
}
|
||||
if (this.state == STATE_CONTINUE_NEAR_GRABBING && this.bumperSqueezed()) {
|
||||
this.setState(STATE_CONTINUE_EQUIP_BD);
|
||||
if (this.isInitialGrab) {
|
||||
this.callEntityMethodOnGrabbed("releaseGrab");
|
||||
}
|
||||
this.callEntityMethodOnGrabbed("releaseGrab");
|
||||
this.callEntityMethodOnGrabbed("startEquip");
|
||||
return;
|
||||
}
|
||||
|
@ -1467,10 +1458,8 @@ function MyController(hand) {
|
|||
if (this.state === STATE_CONTINUE_EQUIP) {
|
||||
this.callEntityMethodOnGrabbed("continueEquip");
|
||||
}
|
||||
if (this.isInitialGrab) {
|
||||
if (this.state == STATE_CONTINUE_NEAR_GRABBING) {
|
||||
this.callEntityMethodOnGrabbed("continueNearGrab");
|
||||
}
|
||||
if (this.state == STATE_CONTINUE_NEAR_GRABBING) {
|
||||
this.callEntityMethodOnGrabbed("continueNearGrab");
|
||||
}
|
||||
|
||||
if (this.actionID && this.actionTimeout - now < ACTION_TTL_REFRESH * MSEC_PER_SEC) {
|
||||
|
@ -1654,19 +1643,11 @@ function MyController(hand) {
|
|||
this.actionID = null;
|
||||
this.setState(STATE_OFF);
|
||||
|
||||
if (this.isInitialGrab) {
|
||||
Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({
|
||||
action: 'release',
|
||||
grabbedEntity: this.grabbedEntity,
|
||||
joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"
|
||||
}));
|
||||
} else {
|
||||
Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({
|
||||
action: 'shared-release',
|
||||
grabbedEntity: this.grabbedEntity,
|
||||
joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"
|
||||
}));
|
||||
}
|
||||
Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({
|
||||
action: 'release',
|
||||
grabbedEntity: this.grabbedEntity,
|
||||
joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"
|
||||
}));
|
||||
|
||||
this.grabbedEntity = null;
|
||||
};
|
||||
|
|
|
@ -125,13 +125,13 @@
|
|||
Entities.deleteEntity(this.arrow);
|
||||
},
|
||||
|
||||
startEquip: function(hand, avatarID) {
|
||||
this.hand = hand;
|
||||
|
||||
print('START BOW GRAB')
|
||||
startEquip: function(entityID, args) {
|
||||
this.hand = args[0];
|
||||
avatarID = args[1];
|
||||
|
||||
//disable the opposite hand in handControllerGrab.js by message
|
||||
var handToDisable = this.hand === 'right' ? 'left' : 'right';
|
||||
print("disabling hand: " + handToDisable);
|
||||
Messages.sendMessage('Hifi-Hand-Disabler', handToDisable);
|
||||
|
||||
var data = getEntityCustomData('grabbableKey', this.entityID, {});
|
||||
|
@ -139,7 +139,7 @@
|
|||
setEntityCustomData('grabbableKey', this.entityID, data);
|
||||
|
||||
},
|
||||
continueEquip: function(hand, avatarID) {
|
||||
continueEquip: function(entityID, args) {
|
||||
this.deltaTime = checkInterval();
|
||||
|
||||
//debounce during debugging -- maybe we're updating too fast?
|
||||
|
@ -168,7 +168,7 @@
|
|||
this.checkStringHand();
|
||||
|
||||
},
|
||||
releaseEquip: function(hand, avatarID) {
|
||||
releaseEquip: function(entityID, args) {
|
||||
// print('RELEASE GRAB EVENT')
|
||||
Messages.sendMessage('Hifi-Hand-Disabler', "none")
|
||||
|
||||
|
|
|
@ -119,7 +119,8 @@
|
|||
//wait to make the bubbles collidable, so that they dont hit each other and the wand
|
||||
Script.setTimeout(this.addCollisionsToBubbleAfterCreation(this.currentBubble), lifetime / 2);
|
||||
|
||||
//release the bubble -- when we create a new bubble, it will carry on and this update loop will affect the new bubble
|
||||
//release the bubble -- when we create a new bubble, it will carry on and this update loop will
|
||||
// affect the new bubble
|
||||
this.createBubbleAtTipOfWand();
|
||||
return;
|
||||
} else {
|
||||
|
|
|
@ -24,15 +24,11 @@
|
|||
Doll.prototype = {
|
||||
audioInjector: null,
|
||||
isGrabbed: false,
|
||||
setLeftHand: function() {
|
||||
this.hand = 'left';
|
||||
},
|
||||
|
||||
setRightHand: function() {
|
||||
this.hand = 'right';
|
||||
},
|
||||
startNearGrab: function(entityID, args) {
|
||||
this.hand = args[0];
|
||||
avatarID = args[1];
|
||||
|
||||
startNearGrab: function() {
|
||||
Entities.editEntity(this.entityID, {
|
||||
animation: {
|
||||
url: "https://hifi-public.s3.amazonaws.com/models/Bboys/zombie_scream.fbx",
|
||||
|
@ -53,18 +49,18 @@
|
|||
this.startNearGrab(id, params);
|
||||
},
|
||||
|
||||
continueNearGrab: function() {
|
||||
continueNearGrab: function(entityID, args) {
|
||||
var props = Entities.getEntityProperties(this.entityID, ["position"]);
|
||||
var audioOptions = {
|
||||
position: props.position
|
||||
};
|
||||
this.audioInjector.options = audioOptions;
|
||||
},
|
||||
continueEquip: function() {
|
||||
this.continueNearGrab();
|
||||
continueEquip: function(entityID, args) {
|
||||
this.continueNearGrab(entityID, args);
|
||||
},
|
||||
|
||||
releaseGrab: function() {
|
||||
releaseGrab: function(entityID, args) {
|
||||
if (this.isGrabbed === true && this.hand === this.initialHand) {
|
||||
this.audioInjector.stop();
|
||||
Entities.editEntity(this.entityID, {
|
||||
|
@ -79,8 +75,8 @@
|
|||
this.isGrabbed = false;
|
||||
}
|
||||
},
|
||||
releaseEquip: function() {
|
||||
this.releaseGrab();
|
||||
releaseEquip: function(entityID, args) {
|
||||
this.releaseGrab(entityID, args);
|
||||
},
|
||||
|
||||
preload: function(entityID) {
|
||||
|
|
|
@ -77,15 +77,10 @@
|
|||
whichHand: null,
|
||||
hasSpotlight: false,
|
||||
spotlight: null,
|
||||
setRightHand: function() {
|
||||
this.hand = 'RIGHT';
|
||||
},
|
||||
|
||||
setLeftHand: function() {
|
||||
this.hand = 'LEFT';
|
||||
},
|
||||
startNearGrab: function(entityID, args) {
|
||||
this.hand = args[0];
|
||||
|
||||
startNearGrab: function(entityID) {
|
||||
print("FLASHLIGHT startNearGrab");
|
||||
if (!this.hasSpotlight) {
|
||||
|
||||
|
@ -161,11 +156,11 @@
|
|||
this.changeLightWithTriggerPressure(this.whichHand);
|
||||
}
|
||||
},
|
||||
continueEquip: function() {
|
||||
this.continueNearGrab();
|
||||
continueEquip: function(entityID, args) {
|
||||
this.continueNearGrab(entityID, args);
|
||||
},
|
||||
|
||||
releaseGrab: function() {
|
||||
releaseGrab: function(entityID, args) {
|
||||
//delete the lights and reset state
|
||||
if (this.hasSpotlight) {
|
||||
Entities.deleteEntity(this.spotlight);
|
||||
|
@ -177,8 +172,8 @@
|
|||
this.lightOn = false;
|
||||
}
|
||||
},
|
||||
releaseEquip: function() {
|
||||
this.releaseGrab();
|
||||
releaseEquip: function(entityID, args) {
|
||||
this.releaseGrab(entityID, args);
|
||||
},
|
||||
|
||||
changeLightWithTriggerPressure: function(flashLightHand) {
|
||||
|
|
|
@ -54,47 +54,26 @@
|
|||
|
||||
PingPongGun.prototype = {
|
||||
hand: null,
|
||||
whichHand: null,
|
||||
gunTipPosition: null,
|
||||
canShoot: false,
|
||||
canShootTimeout: null,
|
||||
setRightHand: function() {
|
||||
this.hand = 1;
|
||||
|
||||
startEquip: function(entityID, args) {
|
||||
this.hand = args[0] == "left" ? 0 : 1;
|
||||
},
|
||||
|
||||
setLeftHand: function() {
|
||||
this.hand = 0;
|
||||
},
|
||||
|
||||
startEquip: function() {
|
||||
this.setWhichHand();
|
||||
},
|
||||
|
||||
setWhichHand: function() {
|
||||
this.whichHand = this.hand;
|
||||
},
|
||||
|
||||
continueEquip: function() {
|
||||
if (this.whichHand === null) {
|
||||
//only set the active hand once -- if we always read the current hand, our 'holding' hand will get overwritten
|
||||
this.setWhichHand();
|
||||
} else {
|
||||
if (this.canShootTimeout !== null) {
|
||||
Script.clearTimeout(this.canShootTimeout);
|
||||
}
|
||||
this.checkTriggerPressure(this.whichHand);
|
||||
continueEquip: function(entityID, args) {
|
||||
if (this.canShootTimeout !== null) {
|
||||
Script.clearTimeout(this.canShootTimeout);
|
||||
}
|
||||
this.checkTriggerPressure(this.hand);
|
||||
},
|
||||
|
||||
releaseEquip: function() {
|
||||
releaseEquip: function(entityID, args) {
|
||||
var _this = this;
|
||||
|
||||
if (this.whichHand === this.hand) {
|
||||
this.whichHand = null;
|
||||
this.canShootTimeout = Script.setTimeout(function() {
|
||||
_this.canShoot = false;
|
||||
}, 250);
|
||||
}
|
||||
this.canShootTimeout = Script.setTimeout(function() {
|
||||
_this.canShoot = false;
|
||||
}, 250);
|
||||
},
|
||||
|
||||
checkTriggerPressure: function(gunHand) {
|
||||
|
@ -102,7 +81,7 @@
|
|||
if (this.triggerValue < RELOAD_THRESHOLD) {
|
||||
// print('RELOAD');
|
||||
this.canShoot = true;
|
||||
} else if (this.triggerValue >= RELOAD_THRESHOLD && this.canShoot === true && this.hand === this.whichHand) {
|
||||
} else if (this.triggerValue >= RELOAD_THRESHOLD && this.canShoot === true) {
|
||||
var gunProperties = Entities.getEntityProperties(this.entityID, ["position", "rotation"]);
|
||||
this.shootBall(gunProperties);
|
||||
this.canShoot = false;
|
||||
|
|
|
@ -49,10 +49,10 @@
|
|||
|
||||
startEquip: function(id, params) {
|
||||
this.equipped = true;
|
||||
this.hand = JSON.parse(params[0]);
|
||||
this.hand = params[0] == "left" ? 0 : 1;
|
||||
},
|
||||
|
||||
continueEquip: function() {
|
||||
continueEquip: function(id, params) {
|
||||
if (!this.equipped) {
|
||||
return;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@
|
|||
});
|
||||
},
|
||||
|
||||
unequip: function() {
|
||||
releaseEquip: function(id, params) {
|
||||
this.hand = null;
|
||||
this.equipped = false;
|
||||
Overlays.editOverlay(this.laser, {
|
||||
|
|
|
@ -38,20 +38,12 @@
|
|||
Controller.Standard.RT,
|
||||
];
|
||||
|
||||
this.setRightHand = function () {
|
||||
this.hand = 1;
|
||||
}
|
||||
|
||||
this.setLeftHand = function () {
|
||||
this.hand = 0;
|
||||
}
|
||||
|
||||
this.startNearGrab = function () {
|
||||
this.whichHand = this.hand;
|
||||
this.startNearGrab = function (entityID, args) {
|
||||
this.hand = args[0] == "left" ? 0 : 1;
|
||||
}
|
||||
|
||||
this.toggleWithTriggerPressure = function () {
|
||||
this.triggerValue = Controller.getValue(TRIGGER_CONTROLS[this.whichHand]);
|
||||
this.triggerValue = Controller.getValue(TRIGGER_CONTROLS[this.hand]);
|
||||
if (this.triggerValue < DISABLE_SPRAY_THRESHOLD && this.spraying === true) {
|
||||
this.spraying = false;
|
||||
this.disableStream();
|
||||
|
|
Loading…
Reference in a new issue