Needs a lot of cleanup. Data has been de-duplicated, and where identical copies existed, one of them has been replaced with a symlink. Some files have been excluded, such as binaries, installers and debug dumps. Some of that may still be present.
84 lines
2.5 KiB
JavaScript
84 lines
2.5 KiB
JavaScript
(function() {
|
|
var self = this;
|
|
|
|
var DEFAULT_ACCELERATION = { x: 0, y: -10, z: 0 };
|
|
var BOOST_ACCELERATION = { x: 0, y: 1, z: 0 };
|
|
var STATE_IDLE = 0;
|
|
var STATE_BOOSTING = 1;
|
|
var STATE_LAUNCHING = 2;
|
|
|
|
self.state = STATE_IDLE;
|
|
|
|
self.entityID = null;
|
|
self.launching = false;
|
|
|
|
self.preload = function(entityID) {
|
|
self.entityID = entityID;
|
|
}
|
|
|
|
self.startBoost = function() {
|
|
if (self.state === STATE_IDLE) {
|
|
self.state = STATE_BOOSTING;
|
|
self.setParticlesOn(true);
|
|
Entities.editEntity(self.entityID, { gravity: BOOST_ACCELERATION });
|
|
}
|
|
}
|
|
self.stopBoost = function() {
|
|
if (self.state === STATE_BOOSTING) {
|
|
self.state = STATE_IDLE;
|
|
self.setParticlesOn(false);
|
|
Entities.editEntity(self.entityID, { gravity: DEFAULT_ACCELERATION });
|
|
}
|
|
}
|
|
|
|
self.launch = function() {
|
|
print("here");
|
|
if (self.state === STATE_LAUNCHING) {
|
|
return;
|
|
}
|
|
|
|
print("here2");
|
|
|
|
self.state = STATE_LAUNCHING;
|
|
self.setParticlesOn(true);
|
|
|
|
Entities.editEntity(self.entityID, { gravity: { x: 0, y: 10.0, z: 0 } });
|
|
Script.setTimeout(function() {
|
|
//Entities.editEntity(self.entityID, { accele: { x: 0, y: 1.0, z: 0 } });
|
|
}, 2000);
|
|
Script.setTimeout(function() {
|
|
print("Done");
|
|
Entities.editEntity(self.entityID, { gravity: DEFAULT_ACCELERATION });
|
|
self.setParticlesOn(false);
|
|
self.state = STATE_IDLE;
|
|
}, 3000);
|
|
}
|
|
|
|
self.setParticlesOn = function(on) {
|
|
var childrenIDs = Entities.getChildrenIDs(self.entityID);
|
|
var particleIDs = [];
|
|
for (var i = 0; i < childrenIDs.length; ++i) {
|
|
var entityID = childrenIDs[i];
|
|
if (Entities.getEntityProperties(entityID, 'type').type === 'ParticleEffect') {
|
|
Entities.editEntity(entityID, { emitRate: (on ? 200 : 0) });
|
|
particleIDs.push(entityID);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//self.clickDownOnEntity = self.launch;
|
|
Messages.messageReceived.connect(function(channel, message, sender) {
|
|
if (channel === 'RocketChair') {
|
|
if (message === 'startBoost') {
|
|
self.startBoost();
|
|
} else if (message === 'stopBoost') {
|
|
self.stopBoost();
|
|
} else if (message === 'launch') {
|
|
self.launch();
|
|
}
|
|
}
|
|
});
|
|
|
|
return self;
|
|
})
|