Implemented local positioning as master - included punkbuster instead of webrtc for now. #49

This commit is contained in:
logsol 2014-05-29 18:29:17 +02:00
parent efe4c76cc2
commit e7f4b6043d
7 changed files with 124 additions and 24 deletions

View file

@ -1,10 +1,11 @@
define([
"Game/Core/Control/PlayerController",
"Lib/Utilities/NotificationCenter",
"Lib/Utilities/Protocol/Parser"
"Lib/Utilities/Protocol/Parser",
"Game/Config/Settings"
],
function(Parent, Nc, Parser) {
function(Parent, Nc, Parser, Settings) {
function PlayerController(player) {
@ -39,6 +40,27 @@ function(Parent, Nc, Parser) {
this.player.suicide();
};
PlayerController.prototype.meStateUpdate = function(update) {
if(!this.player.doll) {
console.warn('me state update, even though doll does not exist');
return;
}
var difference = {
x: Math.abs(update.p.x - this.player.doll.body.GetPosition().x),
y: Math.abs(update.p.y - this.player.doll.body.GetPosition().y)
}
if(difference.x < Settings.PUNKBUSTER_DIFFERENCE_METERS
|| difference.y < Settings.PUNKBUSTER_DIFFERENCE_METERS) {
this.player.doll.body.SetAwake(true);
this.player.doll.body.SetPosition(update.p);
} else {
// HARD UPDATE FOR SELF
}
};
return PlayerController;
});