mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
- Temporarily commented out joint limit setting code in RubeDoll.flip() - RubeDoll joints now have no angular constraints - Should make ragdoll more floppy and less glitchy - Collision prevention between held RubeDoll and holding player is working - All Planck.js migration issues resolved
91 lines
No EOL
2.6 KiB
JavaScript
91 lines
No EOL
2.6 KiB
JavaScript
define([
|
|
"Game/Core/GameObjects/Items/RubeDoll",
|
|
"Game/Config/Settings",
|
|
"Lib/Utilities/NotificationCenter"
|
|
],
|
|
|
|
function (Parent, Settings, nc) {
|
|
|
|
"use strict";
|
|
|
|
function RubeDoll(physicsEngine, uid, options) {
|
|
this.scheduledForDestruction = false;
|
|
this.destructionTimeout = null;
|
|
|
|
Parent.call(this, physicsEngine, uid, options);
|
|
}
|
|
|
|
RubeDoll.prototype = Object.create(Parent.prototype);
|
|
|
|
RubeDoll.prototype.beingGrabbed = function(player) {
|
|
Parent.prototype.beingGrabbed.call(this, player);
|
|
|
|
// Prevent collision with the player holding this RubeDoll
|
|
this.preventCollisionWithPlayer(player);
|
|
|
|
if(this.scheduledForDestruction) {
|
|
clearTimeout(this.destructionTimeout);
|
|
}
|
|
};
|
|
|
|
RubeDoll.prototype.beingReleased = function(player) {
|
|
Parent.prototype.beingReleased.call(this, player);
|
|
|
|
// Restore collision with the player
|
|
this.restoreCollisionWithPlayer();
|
|
|
|
if(this.scheduledForDestruction) {
|
|
this.delayedDestroy();
|
|
}
|
|
};
|
|
|
|
RubeDoll.prototype.delayedDestroy = function() {
|
|
var self = this;
|
|
this.scheduledForDestruction = true;
|
|
this.destructionTimeout = setTimeout(function() {
|
|
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, 'removeGameObject', {
|
|
type: 'animated',
|
|
uid: self.uid
|
|
});
|
|
self.destroy();
|
|
}, Settings.RAGDOLL_DESTRUCTION_TIME * 1000);
|
|
};
|
|
|
|
RubeDoll.prototype.getUpdateData = function(getSleeping) {
|
|
var updateData = Parent.prototype.getUpdateData.call(this, getSleeping);
|
|
|
|
// if parent is asleep it sends null, to do no update
|
|
if(!updateData) {
|
|
return updateData;
|
|
}
|
|
|
|
// adding limb update data
|
|
var limbUpdateData = {};
|
|
|
|
for(var name in this.limbs) {
|
|
limbUpdateData[name] = {
|
|
p: this.limbs[name].getPosition(),
|
|
a: this.limbs[name].getAngle(),
|
|
lv: this.limbs[name].getLinearVelocity(),
|
|
av: this.limbs[name].getAngularVelocity()
|
|
};
|
|
}
|
|
updateData['limbs'] = limbUpdateData;
|
|
|
|
return updateData;
|
|
}
|
|
|
|
RubeDoll.prototype.destroy = function() {
|
|
if(this.scheduledForDestruction) {
|
|
clearTimeout(this.destructionTimeout);
|
|
}
|
|
|
|
// Restore collision before destroying
|
|
this.restoreCollisionWithPlayer();
|
|
|
|
Parent.prototype.destroy.call(this);
|
|
};
|
|
|
|
return RubeDoll;
|
|
|
|
}); |