1
This commit is contained in:
parent
dc557b32ae
commit
5e2122d2a9
@ -9,10 +9,10 @@ else()
|
||||
endif()
|
||||
|
||||
set(CMAKE_BUILD_TYPE "Debug")
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
#set(CMAKE_BUILD_TYPE "Release")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DA8_TCP_SESSION2=1")
|
||||
#set(CMAKE_CXX_FLAGS_RELEASE "-O2 -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DA8_TCP_SESSION2=1 -fsanitize=address -fno-omit-frame-pointer")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DA8_TCP_SESSION2=1")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DA8_TCP_SESSION2=1 -DRAY_DETECTION=1")
|
||||
#set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DA8_TCP_SESSION2=1 -fsanitize=address -fno-omit-frame-pointer")
|
||||
|
||||
include_directories(
|
||||
|
@ -101,14 +101,6 @@ void Bullet::OnHit(std::set<Entity*>& objects)
|
||||
}
|
||||
obstacle->ClearColliders();
|
||||
room->ScatterDrop(obstacle->pos, obstacle->meta->i->drop());
|
||||
#ifdef RAY_DETECTION
|
||||
if (!obstacle->observer_set.empty()) {
|
||||
for (Bullet* bullet : obstacle->observer_set) {
|
||||
bullet->RayDetection();
|
||||
}
|
||||
obstacle->observer_set.clear();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
obstacle->BroadcastFullState();
|
||||
}
|
||||
@ -180,7 +172,6 @@ void Bullet::ProcBomb()
|
||||
}
|
||||
break;
|
||||
}
|
||||
ClearRayData();
|
||||
room->RemoveObjectLater(this);
|
||||
}
|
||||
|
||||
@ -200,7 +191,6 @@ void Bullet::RayDetectionUpdate()
|
||||
if (IsBomb()) {
|
||||
ProcBomb();
|
||||
} else {
|
||||
ClearRayData();
|
||||
room->RemoveObjectLater(this);
|
||||
}
|
||||
} else {
|
||||
@ -231,19 +221,12 @@ void Bullet::RayDetectionUpdate()
|
||||
if (!objects.empty()) {
|
||||
OnHit(objects);
|
||||
}
|
||||
ClearRayData();
|
||||
room->RemoveObjectLater(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Bullet::ClearRayData()
|
||||
{
|
||||
#ifdef RAY_DETECTION
|
||||
#endif
|
||||
}
|
||||
|
||||
void Bullet::FrameDetectionUpdate()
|
||||
{
|
||||
pos = pos + dir * gun_meta->i->bullet_speed() / (float)SERVER_FRAME_RATE;
|
||||
@ -252,7 +235,6 @@ void Bullet::FrameDetectionUpdate()
|
||||
if (IsBomb()) {
|
||||
ProcBomb();
|
||||
} else {
|
||||
ClearRayData();
|
||||
room->RemoveObjectLater(this);
|
||||
}
|
||||
} else {
|
||||
@ -298,7 +280,6 @@ void Bullet::FrameDetectionUpdate()
|
||||
if (!objects.empty()) {
|
||||
OnHit(objects);
|
||||
}
|
||||
ClearRayData();
|
||||
room->RemoveObjectLater(this);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ class Bullet : public Entity
|
||||
virtual void Initialize() override;
|
||||
virtual void Update(int delta_time) override;
|
||||
void RecalcSelfCollider();
|
||||
void ClearRayData();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -7,6 +7,11 @@ void MovementComponent::RayDetection()
|
||||
|
||||
}
|
||||
|
||||
void MovementComponent::Clear()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MovementComponent::GetCollisionObjects(std::set<Entity*>& objects)
|
||||
{
|
||||
|
||||
|
@ -5,11 +5,14 @@ class MovementComponent
|
||||
{
|
||||
public:
|
||||
Entity* owner = nullptr;
|
||||
float passed_distance = 0.0f;
|
||||
float target_distance = 0.0f;
|
||||
Vector2D start_point;
|
||||
Vector2D target_point;
|
||||
std::set<Entity*> detection_objects;
|
||||
|
||||
void RayDetection();
|
||||
void Clear();
|
||||
void GetCollisionObjects(std::set<Entity*>& objects);
|
||||
bool TestCollision();
|
||||
};
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "building.h"
|
||||
#include "loot.h"
|
||||
#include "app.h"
|
||||
#include "movement.h"
|
||||
|
||||
Player::Player():Human()
|
||||
{
|
||||
@ -106,15 +107,41 @@ void Player::UpdateMove()
|
||||
moving = false;
|
||||
moved_frames = 0;
|
||||
last_collision_door = nullptr;
|
||||
#ifdef RAY_DETECTION
|
||||
movement->Clear();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
++moved_frames;
|
||||
if (moved_frames > 4) {
|
||||
moving = false;
|
||||
moved_frames = 0;
|
||||
#ifdef RAY_DETECTION
|
||||
movement->Clear();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
int speed = std::max(1, (int)GetSpeed());
|
||||
#ifdef RAY_DETECTION
|
||||
for (int i = 0; i < speed; ++i) {
|
||||
Vector2D old_pos = pos;
|
||||
pos = pos + move_dir;
|
||||
if (movement->TestCollision()) {
|
||||
pos = old_pos;
|
||||
FindPath();
|
||||
movement->RayDetection();
|
||||
if (rand() % 3 == 0) {
|
||||
i += 1;
|
||||
}
|
||||
} else {
|
||||
movement->passed_distance += 1;
|
||||
if (movement->passed_distance + 10 > movement->target_distance) {
|
||||
movement->RayDetection();
|
||||
}
|
||||
}
|
||||
room->grid_service.MoveHuman(this);
|
||||
}
|
||||
#else
|
||||
for (int i = 0; i < speed; ++i) {
|
||||
Vector2D old_pos = pos;
|
||||
pos = pos + move_dir;
|
||||
@ -134,6 +161,7 @@ void Player::UpdateMove()
|
||||
}
|
||||
room->grid_service.MoveHuman(this);
|
||||
}
|
||||
#endif
|
||||
if (last_collision_door && !TestCollision(last_collision_door)) {
|
||||
last_collision_door = nullptr;
|
||||
}
|
||||
@ -702,6 +730,9 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
|
||||
move_dir.FromPB(&msg.move_dir());
|
||||
move_dir.Normalize();
|
||||
moving = true;
|
||||
#ifdef RAY_DETECTION
|
||||
movement->RayDetection();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
assert(!isnan(move_dir.x) && !isnan(move_dir.y));
|
||||
|
Loading…
x
Reference in New Issue
Block a user