This commit is contained in:
aozhiwei 2019-11-21 19:37:26 +08:00
parent 1e3f4023fa
commit 984d115404
4 changed files with 17 additions and 1 deletions

View File

@ -34,6 +34,7 @@ Human::~Human()
void Human::Initialize()
{
Entity::Initialize();
CreateSnake();
RecalcSelfCollider();
observers_.insert(this);
}
@ -819,3 +820,8 @@ void Human::Revive()
});
SyncAroundPlayers(__FILE__, __LINE__, __func__);
}
void Human::CreateSnake()
{
}

View File

@ -6,7 +6,7 @@
namespace MetaData
{
class Snake;
}
enum HumanStatus
@ -22,6 +22,7 @@ class Loot;
class Human : public Entity
{
public:
MetaData::Snake* meta = nullptr;
int socket_handle = 0;
long ip_saddr = 0;
int team_id = 0;
@ -113,8 +114,10 @@ private:
void SendBattleReport();
void OnDie();
void Revive();
void CreateSnake();
protected:
int node_id_ = 1;
SnakeBodyNode* head_ = nullptr;
SnakeBodyNode* tail_ = nullptr;
std::list<SnakeBodyNode> body_list;

View File

@ -4,6 +4,7 @@
#include "player.h"
#include "cs_proto.pb.h"
#include "room.h"
#include "metamgr.h"
#include "framework/cpp/utils.h"
@ -37,7 +38,12 @@ Player* PlayerMgr::GetPlayerBySocket(int socket)
Player* PlayerMgr::CreatePlayerByCMJoin(long ip_saddr, int socket, const cs::CMJoin& msg)
{
MetaData::Snake* meta = MetaMgr::Instance()->GetSnake(1);
if (!meta) {
return nullptr;
}
Player* hum = new Player();
hum->meta = meta;
hum->socket_handle = socket;
hum->ip_saddr = ip_saddr;
hum->account_id = msg.account_id();

View File

@ -61,6 +61,7 @@ struct SnakeBodyNode
{
int node_id = 0;
float speed = 0.0f;
a8::Vec2 pos;
a8::Vec2 dir;
a8::Vec2 last_move;
bool moved = false;