1
This commit is contained in:
parent
a20e81bed1
commit
d145ffaa65
@ -1033,6 +1033,9 @@ void Bullet::ProcRequestBulletDmg(int shield_hit, int strength_wall_uniid, int t
|
||||
float distance = GlmHelper::Norm(GetPos().ToGlmVec3() - born_pos.ToGlmVec3());
|
||||
BulletCheckResult result;
|
||||
result.flyed_distance = distance;
|
||||
if (result.flyed_distance > gun_meta->range() * 5) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (trace_target_id) {
|
||||
if (trace_target_id == target_uniid) {
|
||||
|
@ -60,6 +60,18 @@ void GridCell::TraverseCreatures(std::function<void (Creature*, bool&)>& func,
|
||||
--Global::Instance()->traversing_cell_creature_count;
|
||||
}
|
||||
|
||||
void GridCell::TraverseObstacles(std::function<void (Obstacle*, bool&)>& func,
|
||||
int room_idx,
|
||||
bool& stop)
|
||||
{
|
||||
for (Obstacle* ob : obstacles_[room_idx]) {
|
||||
func(ob, stop);
|
||||
if (stop) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GridCell::AddPermanentEntity(Entity* entity)
|
||||
{
|
||||
entitys_[0].insert(entity);
|
||||
@ -68,11 +80,17 @@ void GridCell::AddPermanentEntity(Entity* entity)
|
||||
void GridCell::AddRoomEntity(Room* room, Entity* entity)
|
||||
{
|
||||
entitys_[room->GetRoomIdx()].insert(entity);
|
||||
if (entity->IsEntityType(ET_Obstacle)) {
|
||||
obstacles_[room->GetRoomIdx()].insert((Obstacle*)entity);
|
||||
}
|
||||
}
|
||||
|
||||
void GridCell::RemoveRoomEntity(Room* room, Entity* entity)
|
||||
{
|
||||
entitys_[room->GetRoomIdx()].erase(entity);
|
||||
if (entity->IsEntityType(ET_Obstacle)) {
|
||||
obstacles_[room->GetRoomIdx()].erase((Obstacle*)entity);
|
||||
}
|
||||
}
|
||||
|
||||
bool GridCell::EntityExists(Room* room, Entity* entity)
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
class Entity;
|
||||
class Obstacle;
|
||||
class Human;
|
||||
class Room;
|
||||
class Creature;
|
||||
@ -18,6 +19,9 @@ public:
|
||||
void TraverseCreatures(std::function<void (Creature*, bool&)>& func,
|
||||
int room_idx,
|
||||
bool& stop);
|
||||
void TraverseObstacles(std::function<void (Obstacle*, bool&)>& func,
|
||||
int room_idx,
|
||||
bool& stop);
|
||||
|
||||
void AddCreature(Creature* c);
|
||||
void RemoveCreature(Creature* c);
|
||||
@ -37,5 +41,6 @@ public:
|
||||
|
||||
private:
|
||||
std::vector<std::set<Entity*>> entitys_;
|
||||
std::vector<std::set<Obstacle*>> obstacles_;
|
||||
std::vector<std::set<Creature*>> creatures_;
|
||||
};
|
||||
|
@ -361,6 +361,19 @@ void GridService::TraverseCreatures(int room_idx,
|
||||
}
|
||||
}
|
||||
|
||||
void GridService::TraverseObstacles(int room_idx,
|
||||
std::set<GridCell*>& grid_list,
|
||||
std::function<void (Obstacle*, bool&)> func)
|
||||
{
|
||||
bool stop = false;
|
||||
for (auto& cell : grid_list) {
|
||||
cell->TraverseObstacles(func, room_idx, stop);
|
||||
if (stop) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GridService::DeatchHuman(Human* target)
|
||||
{
|
||||
for (auto& cell : target->GetGridList()) {
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
class Human;
|
||||
class Entity;
|
||||
class Obstacle;
|
||||
class Room;
|
||||
class Creature;
|
||||
class GridCell;
|
||||
@ -50,6 +51,9 @@ class GridService
|
||||
void TraverseCreatures(int room_idx,
|
||||
std::set<GridCell*>& grid_list,
|
||||
std::function<void (Creature*, bool&)> func);
|
||||
void TraverseObstacles(int room_idx,
|
||||
std::set<GridCell*>& grid_list,
|
||||
std::function<void (Obstacle*, bool&)> func);
|
||||
void DeatchHuman(Human* hum);
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user