content/hifi-content/caitlyn/production/bowlingAlley/BowlingResettert.js
2022-02-13 22:19:19 +01:00

54 lines
1.8 KiB
JavaScript

// EntityJSONResetter.js
//
// Script Type: Entity
// Created by Eric Levin on 1/20/16.
// Copyright 2016 High Fidelity, Inc.
//
// This entity script resets the EntityJSON when triggered
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
(function() {
Script.include("../libraries/utils.js");
var _this;
var IMPORT_URL = "http://hifi-content.s3.amazonaws.com/caitlyn/production/bowlingAlley/bowlingPins.svo.json";
var PASTE_ENTITIES_LOCATION = {x: 7.2104, y: 2.4495, z: -40.6917};
var EntityJSONResetter = function() {
_this = this;
};
EntityJSONResetter.prototype = {
clickReleaseOnEntity: function(entityId, mouseEvent) {
if (!mouseEvent.isLeftButton) {
return;
}
this.reset();
},
reset: function() {
// Delete everything and re-import the EntityJSON arf
var e = Entities.findEntities(MyAvatar.position, 1000);
for (i = 0; i < e.length; i++) {
// Don't delete our reset entity
if (JSON.stringify(this.entityID) !== JSON.stringify(e[i])) {
// Entities.deleteEntity(e[i]);
// Make it get a list of all the items it rezzed and just delete those instead.
}
}
this.importAssetResourceFile();
},
importAssetResourceFile: function() {
Clipboard.importEntities(IMPORT_URL);
Clipboard.pasteEntities(PASTE_ENTITIES_LOCATION);
},
preload: function(entityID) {
this.entityID = entityID;
},
};
return new EntityJSONResetter();
});