content/hifi-content/james/grandcentral/gametable-dev/newSeatButton.js
2022-02-13 23:57:50 +01:00

40 lines
No EOL
1.4 KiB
JavaScript

(function() {
var _this
function NewSeatButton() {
_this = this;
};
NewSeatButton.prototype = {
preload: function(id) {
_this.entityID = id
},
getEntityFromGroup: function(groupName, entityName) {
var props = Entities.getEntityProperties(_this.entityID);
var results = Entities.findEntities(props.position, 7.5);
var found;
results.forEach(function(item) {
var itemProps = Entities.getEntityProperties(item);
var descriptionSplit = itemProps.description.split(":");
if (descriptionSplit[1] === groupName && descriptionSplit[2] === entityName) {
found = item
}
});
return found;
},
clickDownOnEntity: function() {
_this.spawnNewSeat();
},
startNearTrigger: function() {
_this.spawnNewSeat();
},
startFarTrigger: function() {},
spawnNewSeat: function() {
print('seatSpawner calling spawn new seat')
var seatSpawner = _this.getEntityFromGroup('gameTable', 'seatSpawner');
print('seatSpawner found: ' + seatSpawner);
Entities.callEntityMethod(seatSpawner, 'createSeat');
},
};
return new NewSeatButton();
});