fix timing on startNearGrab entity-method call for cloned entities. Don't allow grabbing of other's equipped or worn entities

This commit is contained in:
Seth Alves 2018-12-18 12:03:21 -08:00
parent 3c0243419b
commit bf46960dc3
2 changed files with 22 additions and 0 deletions

View file

@ -185,6 +185,7 @@ Script.include("/~/system/libraries/controllers.js");
var cloneID = cloneEntity(targetProps);
if (cloneID !== null) {
var cloneProps = Entities.getEntityProperties(cloneID, DISPATCHER_PROPERTIES);
cloneProps.id = cloneID;
this.grabbing = true;
this.targetEntityID = cloneID;
this.startNearGrabEntity(cloneProps);

View file

@ -32,6 +32,7 @@
getEnabledModuleByName:true,
getGrabbableData:true,
isAnothersAvatarEntity:true,
isAnothersChildEntity:true,
entityIsGrabbable:true,
entityIsDistanceGrabbable:true,
getControllerJointIndexCacheTime:true,
@ -302,11 +303,31 @@ isAnothersAvatarEntity = function (iaaeProps) {
return true;
};
isAnothersChildEntity = function (iaceProps) {
while (iaceProps.parentID && iaceProps.parentID !== Uuid.NULL) {
if (Entities.getNestableType(iaceProps.parentID) == "avatar") {
if (iaceProps.parentID == MyAvatar.SELF_ID || iaceProps.parentID == MyAvatar.sessionUUID) {
return false; // not another's, it's mine.
}
return true;
}
// Entities.getNestableType(iaceProps.parentID) == "entity") {
var parentProps = Entities.getEntityProperties(iaceProps.parentID, DISPATCHER_PROPERTIES);
if (!parentProps) {
break;
}
parentProps.id = iaceProps.parentID;
iaceProps = parentProps;
}
return false;
};
entityIsGrabbable = function (eigProps) {
var grabbable = getGrabbableData(eigProps).grabbable;
if (!grabbable ||
eigProps.locked ||
isAnothersAvatarEntity(eigProps) ||
isAnothersChildEntity(eigProps) ||
FORBIDDEN_GRAB_TYPES.indexOf(eigProps.type) >= 0) {
return false;
}