nc refuckulating

This commit is contained in:
logsol 2014-03-17 21:46:19 +01:00
parent 28f71f49e1
commit 4f4bbf73e8
16 changed files with 142 additions and 58 deletions

View file

@ -31,7 +31,7 @@
Nc.on('broadcastControlCommand', this.broadcastControlCommand, this);
Nc.on('broadcastControlCommandExcept', this.broadcastControlCommandExcept, this);
Nc.on('broadcastGameCommand', this.broadcastGameCommand, this);
Nc.on(Nc.ns.channel.to.client.gameCommand.broadcast, this.broadcastGameCommand, this);
Nc.on('broadcastGameCommandExcept', this.broadcastGameCommandExcept, this);
console.checkpoint('channel ' + this.name + ' created');

View file

@ -22,8 +22,8 @@ function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, N
Nc.on('user/joined', this.onUserJoined, this);
Nc.on('user/left', this.onUserLeft, this);
Nc.on('user/resetLevel', this.onResetLevel, this);
Nc.on('user/clientReady', this.onClientReady, this);
Nc.on(Nc.ns.channel.events.user.level.reset, this.onResetLevel, this);
Nc.on(Nc.ns.channel.events.user.client.ready, this.onClientReady, this);
Nc.on('player/killed', this.onPlayerKilled, this);
console.checkpoint('starting game controller for channel ' + channel.name);
@ -84,7 +84,7 @@ function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, N
y: spawnPoint.y
};
Nc.trigger("broadcastGameCommand", "spawnPlayer", options);
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "spawnPlayer", options);
}, respawnTime * 1000);
};
@ -93,7 +93,7 @@ function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, N
var update = this.getWorldUpdateObject(false);
if(Object.getOwnPropertyNames(update).length > 0) {
Nc.trigger("broadcastGameCommand", 'worldUpdate', update);
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, 'worldUpdate', update);
}
setTimeout(this.updateWorld.bind(this), Settings.WORLD_UPDATE_BROADCAST_INTERVAL);
@ -184,12 +184,12 @@ function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, N
userId: userId
}
Nc.trigger('user/' + userId + "/gameCommand", "clientReadyResponse", options);
Nc.trigger(Nc.ns.channel.to.client.user.gameCommand.send + userId, "clientReadyResponse", options);
};
GameController.prototype.onResetLevel = function(userId) {
Parent.prototype.onResetLevel.call(this);
Nc.trigger("broadcastGameCommand", "resetLevel", true);
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "resetLevel", true);
for (var key in this.players) {
this.spawnPlayer(this.players[key]);
}

View file

@ -63,7 +63,7 @@ function (Parent, Item, Box2D, Nc) {
self.player.addDamage(damage.Length() * 2, player);
}
Nc.trigger("engine/addToWorldQueue", callback)
Nc.trigger(Nc.ns.channel.engine.worldQueue.add, callback)
}
}

View file

@ -35,7 +35,7 @@ function (Parent, Settings, Nc) {
};
RagDoll.prototype.destroy = function() {
Nc.trigger("broadcastGameCommand", 'removeGameObject', {
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, 'removeGameObject', {
type: 'animated',
uid: this.uid
});

View file

@ -12,7 +12,7 @@ function (Nc, Channel) {
this.channel = null;
this.process = process;
Nc.on('process/message', this.send, this);
Nc.on(Nc.ns.channel.to.server.controlCommand.send, this.send, this);
process.on('message', function (message, handle) {

View file

@ -43,7 +43,7 @@ function (Parent, Nc) {
options.action = "throw";
options.x = x;
options.y = y;
Nc.trigger("broadcastGameCommand", "handActionResponse", options);
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "handActionResponse", options);
}
} else {
// grab
@ -51,7 +51,7 @@ function (Parent, Nc) {
this.grab(item);
options.action = "grab";
Nc.trigger("broadcastGameCommand", "handActionResponse", options);
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "handActionResponse", options);
}
}
};
@ -85,7 +85,7 @@ function (Parent, Nc) {
Parent.prototype.kill.call(this, killedByPlayer, ragDollId);
this.broadcastStats();
Nc.trigger("broadcastGameCommand", "playerKill", {
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "playerKill", {
playerId: this.id,
killedByPlayerId: killedByPlayer.id,
ragDollId: ragDollId
@ -102,7 +102,7 @@ function (Parent, Nc) {
};
Player.prototype.broadcastStats = function() {
Nc.trigger("broadcastGameCommand", "updateStats", {
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "updateStats", {
playerId: this.id,
stats: this.stats
});

View file

@ -14,7 +14,7 @@ function(Parent, Nc, ProtocolHelper, ProtocolParser) {
this.isReady = false;
var self = this;
Nc.on('user/' + this.id + "/joinSuccess", function(options) {
Nc.on(Nc.ns.channel.to.client.user.controlCommand.joinSuccess + this.id, function(options) {
self.sendControlCommand("joinSuccess", options);
});
@ -22,9 +22,12 @@ function(Parent, Nc, ProtocolHelper, ProtocolParser) {
ProtocolHelper.applyCommand(message.data, self);
});
/*
couldnt find trigger for this while refactoring
Nc.on('user/' + this.id + "/gameCommand", function(command, options) {
self.sendGameCommand(command, options);
});
*/
}
User.prototype = Object.create(Parent.prototype);
@ -43,10 +46,10 @@ function(Parent, Nc, ProtocolHelper, ProtocolParser) {
} // FIXME: move this to Protocol helper as a function
if(command.hasOwnProperty("resetLevel")) {
Nc.trigger("user/resetLevel", this.id);
Nc.trigger(Nc.ns.channel.events.user.level.reset, this.id);
} else if(command.hasOwnProperty("clientReady")) {
this.isReady = true;
Nc.trigger("user/clientReady", this.id);
Nc.trigger(Nc.ns.channel.events.user.client.ready, this.id);
} else {
this.player.playerController.applyCommand(command);
}
@ -60,7 +63,7 @@ function(Parent, Nc, ProtocolHelper, ProtocolParser) {
var recipient = "user/" + this.id;
var data = ProtocolHelper.encodeCommand(command, options);
Nc.trigger("process/message", recipient, data);
Nc.trigger(Nc.ns.channel.to.server.controlCommand.send, recipient, data);
};
User.prototype.sendGameCommand = function(command, options) {