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) {

View file

@ -41,7 +41,7 @@ function (Parent, Nc, Settings) {
var callback = function(playerInfoView) {
self.playerInfoView = playerInfoView;
}
Nc.trigger("view/createAndAddPlayerInfo", callback, options);
Nc.trigger(Nc.ns.client.view.playerInfo.createAndAdd, callback, options);
};
Player.prototype.onHealthChange = function() {
@ -69,15 +69,15 @@ function (Parent, Nc, Settings) {
healthFactor: this.stats.health / 100,
visible: this.playerInfoViewVisible
};
Nc.trigger("view/updatePlayerInfo", this.playerInfoView, options);
Nc.trigger(Nc.ns.client.view.playerInfo.update, this.playerInfoView, options);
this.playerInfoViewVisibleTimeout = setTimeout(function() {
self.playerInfoViewVisible = false;
Nc.trigger("view/updatePlayerInfo", self.playerInfoView, {visible: self.playerInfoViewVisible});
Nc.trigger(Nc.ns.client.view.playerInfo.update, self.playerInfoView, {visible: self.playerInfoViewVisible});
}, Settings.HEALTH_DISPLAY_TIME * 1000);
} else {
Nc.trigger("view/updatePlayerInfo", this.playerInfoView, {visible: this.playerInfoViewVisible});
Nc.trigger(Nc.ns.client.view.playerInfo.update, this.playerInfoView, {visible: this.playerInfoViewVisible});
}
};
@ -96,7 +96,7 @@ function (Parent, Nc, Settings) {
x: position.x * Settings.RATIO,
y: position.y * Settings.RATIO,
}
Nc.trigger("view/updatePlayerInfo", this.playerInfoView, options);
Nc.trigger(Nc.ns.client.view.playerInfo.update, this.playerInfoView, options);
}
};

View file

@ -13,7 +13,7 @@ function (Settings, Nc, Stats, Screenfull) {
this.stats = null;
this.ping = null;
Nc.on("view/ready", this.initDevTools, this);
Nc.on(Nc.ns.client.view.events.ready, this.initDevTools, this);
}
DomController.prototype.initDevTools = function() {

View file

@ -36,7 +36,7 @@ function (Settings, Exception, AbstractView, PixiView, Nc) {
throw new Exception("In the view", Settings.VIEW_CONTROLLER + 'View', "this.setCanvas(canvas) has not been called with a valid HTMLCanvasElement!");
}
Nc.trigger("view/ready", view);
Nc.trigger(Nc.ns.client.view.events.ready, view);
return view;
}

View file

@ -23,8 +23,8 @@ function (DomController, Settings, Exception, Nc) {
Nc.on("view/toggleInfo", this.onToggleInfo, this);
Nc.on("view/createAndAddPlayerInfo", this.onCreateAndAddPlayerInfo, this);
Nc.on("view/updatePlayerInfo", this.onUpdatePlayerInfo, this);
Nc.on(Nc.ns.client.view.playerInfo.createAndAdd, this.onCreateAndAddPlayerInfo, this);
Nc.on(Nc.ns.client.view.playerInfo.update, this.onUpdatePlayerInfo, this);
Nc.on("view/removePlayerInfo", this.onRemovePlayerInfo, this);
Nc.on("view/updateLoader", this.onUpdateLoader, this);

View file

@ -17,7 +17,7 @@ function (Settings, Box2D, CollisionDetector, Nc) {
this.lastStep = Date.now();
this.worldQueue = [];
Nc.on("engine/addToWorldQueue", this.addToWorldQueue, this);
Nc.on(Nc.ns.channel.engine.worldQueue.add, this.addToWorldQueue, this);
}
Engine.prototype.getWorld = function () {