Merge pull request #11041 from amvmoody/wl_21472

WL 21472: restore snails ability to eat sprouts
This commit is contained in:
Zach Fox 2017-07-25 13:07:58 -07:00 committed by GitHub
commit 30a571cc48

View file

@ -0,0 +1,36 @@
//
// eatable.js
//
// Created by Alan-Michael Moody on 7/24/2017
// Copyright 2017 High Fidelity, Inc.
//
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
(function () {
var NOMNOM_SOUND = SoundCache.getSound('http://hifi-content.s3.amazonaws.com/DomainContent/production/audio/vegcrunch.wav');
var _entityID;
this.preload = function (entityID) {
_entityID = entityID;
};
this.collisionWithEntity = function(entityUuid, collisionEntityID, collisionInfo) {
var entity = Entities.getEntityProperties(collisionEntityID, ['userData', 'name']);
var isClone = (entity.name.substring(1).split('-')[0] === 'clone');
var isEatable = (JSON.parse(entity.userData).eatable);
if (isEatable && isClone) {
Audio.playSound(NOMNOM_SOUND, {
position: Entities.getEntityProperties(_entityID, ['position']).position,
volume: 0.2,
localOnly: false
});
Entities.deleteEntity(collisionEntityID);
}
};
});