mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
replaced killed doll with ragdoll - fixes #50
This commit is contained in:
parent
aa6fdaa2df
commit
413254bfa4
19 changed files with 330 additions and 88 deletions
|
|
@ -1,9 +1,47 @@
|
|||
define([
|
||||
"Game/Core/GameObjects/Items/RagDoll"
|
||||
"Game/Core/GameObjects/Items/RagDoll",
|
||||
"Game/Config/Settings",
|
||||
"Lib/Utilities/NotificationCenter"
|
||||
],
|
||||
|
||||
function (Parent) {
|
||||
function (Parent, Settings, NotificationCenter) {
|
||||
|
||||
function RagDoll(physicsEngine, uid, options) {
|
||||
this.scheduledForDestruction = false;
|
||||
this.destructionTimeout = null;
|
||||
|
||||
return Parent;
|
||||
Parent.call(this, physicsEngine, uid, options);
|
||||
}
|
||||
|
||||
RagDoll.prototype = Object.create(Parent.prototype);
|
||||
|
||||
RagDoll.prototype.beingGrabbed = function(player) {
|
||||
Parent.prototype.beingGrabbed.call(this, player);
|
||||
if(this.scheduledForDestruction) {
|
||||
clearTimeout(this.destructionTimeout);
|
||||
}
|
||||
};
|
||||
|
||||
RagDoll.prototype.beingReleased = function(player) {
|
||||
Parent.prototype.beingReleased.call(this, player);
|
||||
if(this.scheduledForDestruction) {
|
||||
this.delayedDestroy();
|
||||
}
|
||||
};
|
||||
|
||||
RagDoll.prototype.delayedDestroy = function() {
|
||||
this.scheduledForDestruction = true;
|
||||
this.destructionTimeout = setTimeout(this.destroy.bind(this), Settings.RAGDOLL_DESTRUCTION_TIME * 1000);
|
||||
};
|
||||
|
||||
RagDoll.prototype.destroy = function() {
|
||||
NotificationCenter.trigger("broadcastGameCommand", 'removeGameObject', {
|
||||
type: 'animated',
|
||||
uid: this.uid
|
||||
});
|
||||
Parent.prototype.destroy.call(this);
|
||||
};
|
||||
|
||||
return RagDoll;
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue