mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-09-12 12:06:39 +08:00
Refactored "add state" for entities and players
This commit is contained in:
@@ -64,21 +64,22 @@ GarageServerGame.prototype.getPlayer = function (id) {
|
||||
};
|
||||
|
||||
GarageServerGame.prototype.updatePlayerState = function (id, state) {
|
||||
this.updateState(this.playerController, 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;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
controller.entities.some(function (player) {
|
||||
if (player.id === id) {
|
||||
player.addState(state, currentTime);
|
||||
player.sequence += player.inputs.length;
|
||||
player.inputs = [];
|
||||
this.entityController.entities.some(function (entity) {
|
||||
if (entity.id === id) {
|
||||
entity.addState(state, currentTime);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user