mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-06-27 16:10:34 +08:00
Player remove fixes and entity remove progress
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ GarageServer.prototype.addEntity = function (id) {
|
||||
};
|
||||
|
||||
GarageServer.prototype.removeEntity = function (id) {
|
||||
this.io.sockets.emit('removeEntity', id);
|
||||
this.game.removeEntity(id);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user