Player remove fixes and entity remove progress

This commit is contained in:
Jeremiah Billmann
2013-07-14 16:10:51 -04:00
parent 29d78b9d95
commit b8b9869522
2 changed files with 16 additions and 0 deletions
+15
View File
@@ -6,6 +6,7 @@ options = {
onPlayerUpdate: function (state),
onEntityUpdate: function (state),
onPlayerRemove: function (id),
onEntityRemove: function (id),
onWorldState: function (state),
onPing: function (pingDelay),
onUpdatePlayerPhysics: function (state, inputs, deltaTime),
@@ -149,6 +150,7 @@ var GarageServerIO = (function (socketio) {
function PlayerController() {
EntityController.call(this);
}
PlayerController.prototype = Object.create(EntityController.prototype);
PlayerController.prototype.add = function (id) {
var player = new Player(id);
this.entities.push(player);
@@ -232,6 +234,15 @@ var GarageServerIO = (function (socketio) {
console.log('garageserver.io:: socket removePlayer ' + id);
}
});
_socket.on('removeEntity', function (id) {
removeEntity(id);
if (_options.onEntityRemove) {
_options.onEntityRemove(id);
}
if (_options.logging) {
console.log('garageserver.io:: socket removeEntity ' + id);
}
});
},
getId = function () {
@@ -266,6 +277,10 @@ var GarageServerIO = (function (socketio) {
_playerController.remove(id);
},
removeEntity = function (id) {
_entityController.remove(id);
},
update = function (data) {
_stateController.setTime(data.time);
+1
View File
@@ -122,6 +122,7 @@ GarageServer.prototype.addEntity = function (id) {
};
GarageServer.prototype.removeEntity = function (id) {
this.io.sockets.emit('removeEntity', id);
this.game.removeEntity(id);
};