mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-07-27 11:18:04 +08:00
Code cleanup
This commit is contained in:
@@ -105,10 +105,18 @@ GarageServer.prototype.getPlayers = function () {
|
||||
return this.game.getPlayers();
|
||||
};
|
||||
|
||||
GarageServer.prototype.getEntities = function () {
|
||||
return this.game.getEntities();
|
||||
};
|
||||
|
||||
GarageServer.prototype.updatePlayerState = function (id, state) {
|
||||
this.game.updatePlayerState(id, state);
|
||||
};
|
||||
|
||||
GarageServer.prototype.updateEntityState = function (id, state) {
|
||||
this.game.updateEntityState(id, state);
|
||||
};
|
||||
|
||||
GarageServer.prototype.addEntity = function (id, state) {
|
||||
this.game.addEntity(id, state);
|
||||
};
|
||||
@@ -117,14 +125,6 @@ GarageServer.prototype.removeEntity = function (id) {
|
||||
this.game.removeEntity(id);
|
||||
};
|
||||
|
||||
GarageServer.prototype.updateEntityState = function (id, state) {
|
||||
this.game.updateEntityState(id, state);
|
||||
};
|
||||
|
||||
GarageServer.prototype.getEntities = function () {
|
||||
return this.game.getEntities();
|
||||
};
|
||||
|
||||
exports.createGarageServer = function (io, options) {
|
||||
return new GarageServer(io, options);
|
||||
};
|
||||
@@ -64,20 +64,17 @@ GarageServerGame.prototype.getPlayer = function (id) {
|
||||
};
|
||||
|
||||
GarageServerGame.prototype.updatePlayerState = function (id, state) {
|
||||
var currentTime = new Date().getTime() - this.startTime;
|
||||
|
||||
this.playerController.entities.some(function (player) {
|
||||
if (player.id === id) {
|
||||
player.addState(state, currentTime);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
this.updateState(this.playerController, id, state);
|
||||
};
|
||||
|
||||
GarageServerGame.prototype.updateEntityState = function (id, state) {
|
||||
this.updateState(this.entityController, id, state);
|
||||
};
|
||||
|
||||
GarageServerGame.prototype.updateState = function (controller, id, state) {
|
||||
var currentTime = new Date().getTime() - this.startTime;
|
||||
|
||||
this.entityController.entities.some(function (entity) {
|
||||
controller.entities.some(function (entity) {
|
||||
if (entity.id === id) {
|
||||
entity.addState(state, currentTime);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user