1
This commit is contained in:
parent
60d1291e43
commit
3affeba4ea
@ -33,6 +33,7 @@ class CustomMember
|
||||
void _CMBattlePreSetReady(f8::MsgHdr* hdr, const cs::CMBattlePreSetReady& msg);
|
||||
bool IsAndroid();
|
||||
bool IsReady() { return is_ready_; }
|
||||
int GetRobotId() { return robot_id_; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<cs::CMJoin> join_msg_;
|
||||
@ -48,6 +49,7 @@ private:
|
||||
int head_frame_ = 0;
|
||||
int sex_ = 0;
|
||||
int is_ready_ = 0;
|
||||
int robot_id_ = 0;
|
||||
std::shared_ptr<BattleDataContext> battle_context_;
|
||||
friend class CustomBattle;
|
||||
};
|
||||
|
@ -536,7 +536,58 @@ void Room::CreateAndroid(int robot_num, std::shared_ptr<Team> team)
|
||||
Human* Room::CreateAndroidWithCustomMember(std::shared_ptr<CustomMember> custom_member,
|
||||
std::shared_ptr<Team> team)
|
||||
{
|
||||
if (GetHumanNum() >= GetRoomMaxPlayerNum()) {
|
||||
return nullptr;
|
||||
}
|
||||
const mt::Robot* robot_meta = mt::Robot::GetById(custom_member->GetRobotId());
|
||||
if (!robot_meta) {
|
||||
A8_ABORT();
|
||||
}
|
||||
|
||||
Android* hum = EntityFactory::Instance()->MakeAndroid(AllocUniid());
|
||||
hum->name = robot_meta->name();
|
||||
hum->meta = mt::Hero::GetById(custom_member->GetNetData()->GetHeroId());
|
||||
hum->robot_meta = robot_meta;
|
||||
hum->SetBornPoint(AllocBornPoint(hum));
|
||||
App::Instance()->verify_set_pos = 1;
|
||||
if (!hum->GetBornPoint()) {
|
||||
abort();
|
||||
} else {
|
||||
hum->SetPos(hum->GetBornPoint()->RandPoint(this));
|
||||
}
|
||||
App::Instance()->verify_set_pos = 0;
|
||||
glm::vec3 attack_dir = hum->GetPos().ToGlmVec3();
|
||||
GlmHelper::Normalize(attack_dir);
|
||||
GlmHelper::RotateY(attack_dir, a8::RandAngle());
|
||||
hum->SetAttackDir(attack_dir);
|
||||
hum->SetMoveDir(attack_dir);
|
||||
hum->room = this;
|
||||
hum->join_frameno = GetFrameNo();
|
||||
hum->Initialize();
|
||||
AddToEntityHash(hum);
|
||||
AddToHumanHash(hum);
|
||||
if (team) {
|
||||
team->AddMember(hum);
|
||||
} else {
|
||||
MatchTeam(hum);
|
||||
}
|
||||
if (!hum->IsOb()) {
|
||||
IncAliveCount();
|
||||
}
|
||||
refreshed_robot_set_.insert(robot_meta->id());
|
||||
if (!CanAddToScene(hum)) {
|
||||
a8::SetBitFlag(hum->status, CS_Disable);
|
||||
} else {
|
||||
AddToAliveHumanHash(hum);
|
||||
AddToMoveableHash(hum);
|
||||
grid_service->AddCreature(hum);
|
||||
hum->FindLocation();
|
||||
hum->RefreshView();
|
||||
}
|
||||
OnAddHuman(hum);
|
||||
frame_event.AddEnterGame(hum->GetWeakPtrRef());
|
||||
NotifyUiUpdate();
|
||||
return hum;
|
||||
}
|
||||
|
||||
void Room::FillSMJoinedNotify(Human* self_hum, cs::SMJoinedNotify& msg)
|
||||
|
Loading…
x
Reference in New Issue
Block a user