mirror of
https://github.com/JulianGro/overte.git
synced 2025-05-04 14:04:01 +02:00
Merge pull request #11041 from amvmoody/wl_21472
WL 21472: restore snails ability to eat sprouts
This commit is contained in:
commit
30a571cc48
1 changed files with 36 additions and 0 deletions
36
unpublishedScripts/DomainContent/Cupcake/eatable.js
Normal file
36
unpublishedScripts/DomainContent/Cupcake/eatable.js
Normal 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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
Loading…
Reference in a new issue