equip improvements

Allow the user to equip an object while near or far grabbing it from the other hand.
This commit is contained in:
Anthony J. Thibault 2016-06-30 13:58:44 -07:00
parent 6072487c9c
commit 82b1cba81d

View file

@ -1144,10 +1144,11 @@ function MyController(hand) {
var grabProps = this.entityPropertyCache.getGrabProps(hotspot.entityID);
var debug = (WANT_DEBUG_SEARCH_NAME && props.name === WANT_DEBUG_SEARCH_NAME);
// Controller.Standard.LeftHand
var refCount = ("refCount" in grabProps) ? grabProps.refCount : 0;
if (refCount > 0) {
if (refCount > 0 && this.getOtherHandController().grabbedEntity != hotspot.entityID) {
if (debug) {
print("equip is skipping '" + props.name + "': it is already grabbed");
print("equip is skipping '" + props.name + "': grabbed by someone else");
}
return false;
}
@ -1698,6 +1699,12 @@ function MyController(hand) {
this.grabbedEntity = saveGrabbedID;
}
var otherHandController = this.getOtherHandController();
if (otherHandController.grabbedEntity == this.grabbedEntity &&
(otherHandController.state == STATE_NEAR_GRABBING || otherHandController.state == STATE_DISTANCE_HOLDING)) {
otherHandController.setState(STATE_OFF, "other hand grabbed this entity");
}
var grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, GRABBABLE_PROPERTIES);
this.activateEntity(this.grabbedEntity, grabbedProperties, false);
@ -1818,7 +1825,6 @@ function MyController(hand) {
return;
}
var now = Date.now();
if (now - this.lastUnequipCheckTime > MSECS_PER_SEC * CHECK_TOO_FAR_UNEQUIP_TIME) {
this.lastUnequipCheckTime = now;
@ -2176,6 +2182,10 @@ function MyController(hand) {
}
setEntityCustomData(GRAB_USER_DATA_KEY, entityID, data);
};
this.getOtherHandController = function() {
return (this.hand === RIGHT_HAND) ? leftController : rightController;
};
}
var rightController = new MyController(RIGHT_HAND);