2023-10-15 16:23:43 -04:00
|
|
|
#include "remoteplayer.h"
|
|
|
|
#include <iostream>
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
|
2023-10-27 14:37:53 -04:00
|
|
|
RemotePlayer::RemotePlayer(netprot::PlayerInfo pinfo) : Player(Vector3f(0, 0, 0), 0, 0), m_pinfo(pinfo), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous() {
|
2023-10-15 16:23:43 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void RemotePlayer::Init() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void RemotePlayer::Feed(const netprot::Output out) {
|
|
|
|
|
2023-10-23 15:35:31 -04:00
|
|
|
current.position = out.position;
|
|
|
|
current.direction = out.direction;
|
|
|
|
current.states = out.states;
|
|
|
|
current.id = out.id;
|
2023-10-15 16:23:43 -04:00
|
|
|
|
|
|
|
//a revoir pour le jump et le shoot en meme temps lorsque les test seront possible
|
|
|
|
|
2023-10-23 15:35:31 -04:00
|
|
|
if (current.position != previous.position)
|
2023-10-15 16:23:43 -04:00
|
|
|
{
|
2023-10-23 15:35:31 -04:00
|
|
|
Vector3f positionDelta = current.position - previous.position;
|
|
|
|
m_position = current.position + positionDelta;
|
2023-10-27 13:56:48 -04:00
|
|
|
m_direction = current.direction;
|
2023-10-15 16:23:43 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-10-23 15:35:31 -04:00
|
|
|
if(current.direction != previous.direction)
|
2023-10-15 16:23:43 -04:00
|
|
|
{
|
2023-10-23 15:35:31 -04:00
|
|
|
m_direction = current.direction;
|
|
|
|
current.direction = current.direction;
|
2023-10-15 16:23:43 -04:00
|
|
|
}
|
|
|
|
|
2023-10-23 15:35:31 -04:00
|
|
|
if (current.states.shooting) {
|
2023-10-27 13:54:37 -04:00
|
|
|
//true;
|
2023-10-15 16:23:43 -04:00
|
|
|
m_animstate = Anim::SHOOTING;
|
|
|
|
}
|
2023-10-23 15:35:31 -04:00
|
|
|
else if (current.states.jumping) {
|
2023-10-27 13:54:37 -04:00
|
|
|
//true;
|
2023-10-15 16:23:43 -04:00
|
|
|
m_animstate = Anim::JUMPING;
|
|
|
|
}
|
2023-10-23 15:35:31 -04:00
|
|
|
else if (current.states.dead) {
|
2023-10-27 13:54:37 -04:00
|
|
|
//true;
|
2023-10-15 16:23:43 -04:00
|
|
|
m_animstate = Anim::DEAD;
|
|
|
|
}
|
2023-10-23 15:35:31 -04:00
|
|
|
else if(current.states.powerup){
|
2023-10-27 13:54:37 -04:00
|
|
|
//true;
|
2023-10-23 15:35:31 -04:00
|
|
|
m_animstate = Anim::POWERUP;
|
2023-10-15 16:23:43 -04:00
|
|
|
}
|
2023-10-23 15:35:31 -04:00
|
|
|
else if (current.states.still) {
|
2023-10-27 13:54:37 -04:00
|
|
|
//true;
|
2023-10-15 16:23:43 -04:00
|
|
|
m_animstate = Anim::STILL;
|
|
|
|
}
|
2023-10-23 15:35:31 -04:00
|
|
|
else if (current.states.running) {
|
2023-10-27 13:54:37 -04:00
|
|
|
//true;
|
2023-10-15 16:23:43 -04:00
|
|
|
m_animstate = Anim::RUNNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-23 15:35:31 -04:00
|
|
|
previous.direction = current.direction;
|
|
|
|
previous.position = current.position;
|
|
|
|
previous.states = current.states;
|
|
|
|
previous.id = current.id;
|
2023-10-15 16:23:43 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|