1
This commit is contained in:
parent
714e755a96
commit
b3fb8beff5
@ -103,6 +103,15 @@ void Bullet::OnHit(std::set<Entity*>& objects)
|
|||||||
}
|
}
|
||||||
obstacle->ClearColliders();
|
obstacle->ClearColliders();
|
||||||
room->ScatterDrop(obstacle->pos, obstacle->meta->i->drop());
|
room->ScatterDrop(obstacle->pos, obstacle->meta->i->drop());
|
||||||
|
#ifdef RAY_DETECTION
|
||||||
|
if (!obstacle->observer_set.empty()) {
|
||||||
|
for (Bullet* bullet : obstacle->observer_set) {
|
||||||
|
bullet->touch_object = nullptr;
|
||||||
|
bullet->RayDetection();
|
||||||
|
}
|
||||||
|
obstacle->observer_set.clear();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
obstacle->BroadcastFullState();
|
obstacle->BroadcastFullState();
|
||||||
}
|
}
|
||||||
@ -174,6 +183,7 @@ void Bullet::ProcBomb()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
ClearRayData();
|
||||||
room->RemoveObjectLater(this);
|
room->RemoveObjectLater(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,6 +204,7 @@ void Bullet::RayDetectionUpdate()
|
|||||||
if (IsBomb()) {
|
if (IsBomb()) {
|
||||||
ProcBomb();
|
ProcBomb();
|
||||||
} else {
|
} else {
|
||||||
|
ClearRayData();
|
||||||
room->RemoveObjectLater(this);
|
room->RemoveObjectLater(this);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -223,6 +234,7 @@ void Bullet::RayDetectionUpdate()
|
|||||||
if (!objects.empty()) {
|
if (!objects.empty()) {
|
||||||
OnHit(objects);
|
OnHit(objects);
|
||||||
}
|
}
|
||||||
|
ClearRayData();
|
||||||
room->RemoveObjectLater(this);
|
room->RemoveObjectLater(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,6 +242,16 @@ void Bullet::RayDetectionUpdate()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void Bullet::ClearRayData()
|
||||||
|
{
|
||||||
|
#ifdef RAY_DETECTION
|
||||||
|
if (touch_object) {
|
||||||
|
touch_object->observer_set.erae(this);
|
||||||
|
touch_object = nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void Bullet::FrameDetectionUpdate()
|
void Bullet::FrameDetectionUpdate()
|
||||||
{
|
{
|
||||||
pos = pos + dir * gun_meta->i->bullet_speed() / (float)SERVER_FRAME_RATE;
|
pos = pos + dir * gun_meta->i->bullet_speed() / (float)SERVER_FRAME_RATE;
|
||||||
@ -238,6 +260,7 @@ void Bullet::FrameDetectionUpdate()
|
|||||||
if (IsBomb()) {
|
if (IsBomb()) {
|
||||||
ProcBomb();
|
ProcBomb();
|
||||||
} else {
|
} else {
|
||||||
|
ClearRayData();
|
||||||
room->RemoveObjectLater(this);
|
room->RemoveObjectLater(this);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -287,6 +310,7 @@ void Bullet::FrameDetectionUpdate()
|
|||||||
if (!objects.empty()) {
|
if (!objects.empty()) {
|
||||||
OnHit(objects);
|
OnHit(objects);
|
||||||
}
|
}
|
||||||
|
ClearRayData();
|
||||||
room->RemoveObjectLater(this);
|
room->RemoveObjectLater(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ namespace MetaData
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Human;
|
class Human;
|
||||||
|
class Obstacle;
|
||||||
class CircleCollider;
|
class CircleCollider;
|
||||||
class Bullet : public Entity
|
class Bullet : public Entity
|
||||||
{
|
{
|
||||||
@ -25,6 +26,7 @@ class Bullet : public Entity
|
|||||||
#ifdef RAY_DETECTION
|
#ifdef RAY_DETECTION
|
||||||
float target_distance = 0.0f;
|
float target_distance = 0.0f;
|
||||||
Vector2D target_point;
|
Vector2D target_point;
|
||||||
|
Obstacle* touch_object = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Bullet();
|
Bullet();
|
||||||
@ -35,6 +37,7 @@ class Bullet : public Entity
|
|||||||
#ifdef RAY_DETECTION
|
#ifdef RAY_DETECTION
|
||||||
void RayDetection();
|
void RayDetection();
|
||||||
#endif
|
#endif
|
||||||
|
void ClearRayData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -36,6 +36,9 @@ class Obstacle : public Entity
|
|||||||
int door_house_uniid = 0;
|
int door_house_uniid = 0;
|
||||||
const metatable::DoorObjJson* door_state0 = nullptr;
|
const metatable::DoorObjJson* door_state0 = nullptr;
|
||||||
const metatable::DoorObjJson* door_state1 = nullptr;
|
const metatable::DoorObjJson* door_state1 = nullptr;
|
||||||
|
#ifdef RAY_DETECTION
|
||||||
|
std::set<Bullet*> observer_set;
|
||||||
|
#endif
|
||||||
|
|
||||||
Obstacle();
|
Obstacle();
|
||||||
virtual ~Obstacle() override;
|
virtual ~Obstacle() override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user