make equipping of clonables more reliable

This commit is contained in:
Seth Alves 2019-03-15 11:42:10 -07:00
parent de5b5301d6
commit 195472bd43
2 changed files with 39 additions and 7 deletions

View file

@ -12,7 +12,7 @@
LEFT_HAND, RIGHT_HAND, NEAR_GRAB_PICK_RADIUS, DEFAULT_SEARCH_SPHERE_DISTANCE, DISPATCHER_PROPERTIES,
getGrabPointSphereOffset, HMD, MyAvatar, Messages, findHandChildEntities, Picks, PickType, Pointers,
PointerManager, getGrabPointSphereOffset, HMD, MyAvatar, Messages, findHandChildEntities, Picks, PickType, Pointers,
PointerManager, print, Selection, DISPATCHER_HOVERING_LIST, DISPATCHER_HOVERING_STYLE, Keyboard
PointerManager, print, Keyboard
*/
controllerDispatcherPlugins = {};
@ -53,6 +53,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
this.blacklist = [];
this.pointerManager = new PointerManager();
this.grabSphereOverlays = [null, null];
this.targetIDs = {};
// a module can occupy one or more "activity" slots while it's running. If all the required slots for a module are
// not set to false (not in use), a module cannot start. When a module is using a slot, that module's name
@ -225,8 +226,8 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
if (tabletIndex !== -1 && closebyOverlays.indexOf(HMD.tabletID) === -1) {
nearbyOverlays.splice(tabletIndex, 1);
}
if (miniTabletIndex !== -1
&& ((closebyOverlays.indexOf(HMD.miniTabletID) === -1) || h !== HMD.miniTabletHand)) {
if (miniTabletIndex !== -1 &&
((closebyOverlays.indexOf(HMD.miniTabletID) === -1) || h !== HMD.miniTabletHand)) {
nearbyOverlays.splice(miniTabletIndex, 1);
}
}
@ -336,6 +337,23 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
});
}
// also make sure we have the properties from the current module's target
for (var tIDRunningPluginName in _this.runningPluginNames) {
if (_this.runningPluginNames.hasOwnProperty(tIDRunningPluginName)) {
var targetIDs = _this.targetIDs[tIDRunningPluginName];
if (targetIDs) {
for (var k = 0; k < targetIDs.length; k++) {
var targetID = targetIDs[k];
if (!nearbyEntityPropertiesByID[targetID]) {
var targetProps = Entities.getEntityProperties(targetID, DISPATCHER_PROPERTIES);
targetProps.id = targetID;
nearbyEntityPropertiesByID[targetID] = targetProps;
}
}
}
}
}
// bundle up all the data about the current situation
var controllerData = {
triggerValues: [_this.leftTriggerValue, _this.rightTriggerValue],
@ -402,10 +420,23 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
Script.beginProfileRange("dispatch.run." + runningPluginName);
}
var runningness = plugin.run(controllerData, deltaTime);
if (DEBUG) {
if (JSON.stringify(_this.targetIDs[runningPluginName]) != JSON.stringify(runningness.targets)) {
print("controllerDispatcher targetIDs[" + runningPluginName + "] = " +
JSON.stringify(runningness.targets));
}
}
_this.targetIDs[runningPluginName] = runningness.targets;
if (!runningness.active) {
// plugin is finished running, for now. remove it from the list
// of running plugins and mark its activity-slots as "not in use"
delete _this.runningPluginNames[runningPluginName];
delete _this.targetIDs[runningPluginName];
if (DEBUG) {
print("controllerDispatcher deleted targetIDs[" + runningPluginName + "]");
}
_this.markSlots(plugin, false);
_this.pointerManager.makePointerInvisible(plugin.parameters.handLaser);
if (DEBUG) {
@ -527,8 +558,9 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
}
if (action === "tablet") {
var tabletIDs = message.blacklist
? [HMD.tabletID, HMD.tabletScreenID, HMD.homeButtonID, HMD.homeButtonHighlightID] : [];
var tabletIDs = message.blacklist ?
[HMD.tabletID, HMD.tabletScreenID, HMD.homeButtonID, HMD.homeButtonHighlightID] :
[];
if (message.hand === LEFT_HAND) {
_this.leftBlacklistTabletIDs = tabletIDs;
_this.setLeftBlacklist();

View file

@ -595,7 +595,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
equipHotspotBuddy.update(deltaTime, timestamp, controllerData);
// if the potentialHotspot is cloneable, clone it and return it
// if the potentialHotspot os not cloneable and locked return null
// if the potentialHotspot is not cloneable and locked return null
if (potentialEquipHotspot &&
(((this.triggerSmoothedSqueezed() || this.secondarySmoothedSqueezed()) && !this.waitForTriggerRelease) ||
this.messageGrabEntity)) {
@ -603,7 +603,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
this.targetEntityID = this.grabbedHotspot.entityID;
this.startEquipEntity(controllerData);
this.equipedWithSecondary = this.secondarySmoothedSqueezed();
return makeRunningValues(true, [potentialEquipHotspot.entityID], []);
return makeRunningValues(true, [this.targetEntityID], []);
} else {
return makeRunningValues(false, [], []);
}