This commit is contained in:
aozhiwei 2021-04-13 21:29:23 +08:00
parent 6227779af0
commit 5226e77257
3 changed files with 16 additions and 8 deletions

View File

@ -3460,7 +3460,8 @@ void Human::UpdateViewObjects()
if (view_objects_.size() >= 2) {
std::vector<Human*> deleted_humans;
for (Human* hum : view_objects_) {
if (hum->dead || hum->GetPos().ManhattanDistance(GetPos()) > 1000) {
if (hum->dead || hum->GetPos().ManhattanDistance(GetPos()) >
MetaMgr::Instance()->view_objects_out_distance) {
deleted_humans.push_back(hum);
}
}
@ -3474,7 +3475,8 @@ void Human::UpdateViewObjects()
[this] (Human* hum, bool& stop)
{
if (hum->IsAndroid() && !hum->dead && view_objects_.find(hum) == view_objects_.end()) {
if (hum->GetPos().ManhattanDistance(GetPos()) < 1000) {
if (hum->GetPos().ManhattanDistance(GetPos()) <
MetaMgr::Instance()->view_objects_in_distance) {
view_objects_.insert(hum);
}
if (view_objects_.size() >= 2) {

View File

@ -3,9 +3,7 @@
#include "incubator.h"
#include "room.h"
#include "human.h"
const int ALLOC_BASE_LENGTH = 500;
const int ALLOC_RAND_LENGTH = 100;
#include "metamgr.h"
void Incubator::Init()
{
@ -23,10 +21,10 @@ void Incubator::AllocAndroid(Human* target, int num)
a8::Vec2 dir = a8::Vec2::UP;
while (num > 0 && try_count < 20 && !hold_humans_.empty()) {
dir.Rotate(a8::RandAngle());
int rand_len = rand() % ALLOC_RAND_LENGTH;
int rand_len = rand() % MetaMgr::Instance()->incubator_rand_length;
Human* hum = hold_humans_[0];
a8::Vec2 old_pos = hum->GetPos();
hum->SetPos(target->GetPos() + dir + ALLOC_BASE_LENGTH + rand_len);
hum->SetPos(target->GetPos() + dir + MetaMgr::Instance()->incubator_base_length + rand_len);
if (!hum->CollisonDetection() && CanSet(hum, target)) {
hum->SetPos(old_pos);
} else {
@ -81,7 +79,8 @@ bool Incubator::CanSet(Human* hum, Human* exclude_hum)
[target, exclude_hum, &can_set] (Human* hum, a8::XParams& param) -> bool
{
if (hum != exclude_hum) {
if (target->GetPos().ManhattanDistance(hum->GetPos()) < 100) {
if (target->GetPos().ManhattanDistance(hum->GetPos()) <
MetaMgr::Instance()->incubator_canset_distance) {
can_set = false;
return false;
}

View File

@ -144,6 +144,13 @@ class MetaMgr : public a8::Singleton<MetaMgr>
int refresh_ai_downed_nearby_teammate_num = 1;
int refresh_ai_downed_nearby_range = 580;
int view_objects_out_distance = 580;
int view_objects_in_distance = 580;
int incubator_base_length = 580;
int incubator_rand_length = 100;
int incubator_canset_distance = 100;
#if 0
int refresh_robot_min_num = 0;
int refresh_robot_max_num = 0;