remove movement.*
This commit is contained in:
parent
4e793b075a
commit
49b3768b01
@ -10,8 +10,8 @@ endif()
|
||||
|
||||
set(CMAKE_BUILD_TYPE "Debug")
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DA8_TCP_SESSION2=1 -DMAP_SERVICE=1")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DA8_TCP_SESSION2=1 -DMAP_SERVICE=1")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -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")
|
||||
|
||||
include_directories(
|
||||
AFTER
|
||||
@ -58,8 +58,6 @@ set(EXECUTABLE_OUTPUT_PATH
|
||||
${PROJECT_BINARY_DIR}/../bin
|
||||
)
|
||||
|
||||
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_DEBUG "_DEBUG")
|
||||
|
||||
add_executable(
|
||||
gameserver ${SRC_LIST}
|
||||
)
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "obstacle.h"
|
||||
#include "player.h"
|
||||
#include "app.h"
|
||||
#include "movement.h"
|
||||
|
||||
Bullet::Bullet():Entity()
|
||||
{
|
||||
@ -17,8 +16,6 @@ Bullet::Bullet():Entity()
|
||||
|
||||
Bullet::~Bullet()
|
||||
{
|
||||
delete movement;
|
||||
movement = nullptr;
|
||||
--App::Instance()->perf.entity_num[ET_Bullet];
|
||||
}
|
||||
|
||||
@ -26,17 +23,11 @@ void Bullet::Initialize()
|
||||
{
|
||||
Entity::Initialize();
|
||||
RecalcSelfCollider();
|
||||
movement = new MovementComponent();
|
||||
movement->owner = this;
|
||||
}
|
||||
|
||||
void Bullet::Update(int delta_time)
|
||||
{
|
||||
#if MAP_SERVICE
|
||||
MapServiceUpdate();
|
||||
#else
|
||||
RayDetectionUpdate();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Bullet::RecalcSelfCollider()
|
||||
@ -182,50 +173,6 @@ bool Bullet::IsBomb()
|
||||
meta->i->_inventory_slot() == 6;
|
||||
}
|
||||
|
||||
void Bullet::RayDetectionUpdate()
|
||||
{
|
||||
pos = pos + dir * gun_meta->i->bullet_speed() / (float)SERVER_FRAME_RATE;
|
||||
float distance = (pos - born_pos).Norm();
|
||||
if (room->OverBorder(pos, gun_meta->i->bullet_rad())) {
|
||||
if (IsBomb()) {
|
||||
ProcBomb();
|
||||
} else {
|
||||
room->RemoveObjectLater(this);
|
||||
}
|
||||
} else {
|
||||
room->grid_service.MoveBullet(this);
|
||||
std::set<Entity*> objects;
|
||||
for (auto& grid : grid_list) {
|
||||
for (Human* hum: grid->human_list) {
|
||||
if (hum != player && !hum->dead &&
|
||||
(hum->team_id == 0 || player->team_id != hum->team_id)) {
|
||||
if (TestCollision(hum)) {
|
||||
objects.insert(hum);
|
||||
}
|
||||
}
|
||||
}
|
||||
}//end for
|
||||
movement->GetCollisionObjects(objects);
|
||||
float bullet_range = gun_meta->i->range();
|
||||
if (gun_upgrade_meta && gun_upgrade_meta->GetAttrValue(gun_lv, EA_ShotRange) > 0) {
|
||||
bullet_range += gun_upgrade_meta->GetAttrValue(gun_lv, EA_ShotRange);
|
||||
}
|
||||
if (!objects.empty() || distance > bullet_range || distance >= movement->target_distance ||
|
||||
(IsBomb() && meta->i->_inventory_slot() != 4 && distance >= fly_distance)
|
||||
) {
|
||||
if (IsBomb()) {
|
||||
ProcBomb();
|
||||
} else {
|
||||
deleted = true;
|
||||
if (!objects.empty()) {
|
||||
OnHit(objects);
|
||||
}
|
||||
room->RemoveObjectLater(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Bullet::MapServiceUpdate()
|
||||
{
|
||||
pos = pos + dir * gun_meta->i->bullet_speed() / (float)SERVER_FRAME_RATE;
|
||||
|
@ -38,7 +38,6 @@ class Bullet : public Entity
|
||||
void OnHit(std::set<Entity*>& objects);
|
||||
void ProcBomb();
|
||||
bool IsBomb();
|
||||
void RayDetectionUpdate();
|
||||
void MapServiceUpdate();
|
||||
|
||||
private:
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "app.h"
|
||||
#include "roommgr.h"
|
||||
#include "android.h"
|
||||
#include "movement.h"
|
||||
#include "gamelog.h"
|
||||
|
||||
#include "framework/cpp/utils.h"
|
||||
@ -48,19 +47,10 @@ Human::Human():Entity()
|
||||
inventory_[IS_12GAUGE] = FIGHTING_MODE_BULLET_NUM;
|
||||
inventory_[IS_RPG] = FIGHTING_MODE_BULLET_NUM;
|
||||
}
|
||||
walk_zone = new AabbCollider();
|
||||
walk_zone->_min.x = -(WALK_ZONE_WIDTH / 2.0f);
|
||||
walk_zone->_min.y = -(WALK_ZONE_WIDTH / 2.0f);
|
||||
walk_zone->_max.x = WALK_ZONE_WIDTH / 2.0f;
|
||||
walk_zone->_max.y = WALK_ZONE_WIDTH / 2.0f;
|
||||
}
|
||||
|
||||
Human::~Human()
|
||||
{
|
||||
delete movement ;
|
||||
movement = nullptr;
|
||||
delete walk_zone;
|
||||
walk_zone = nullptr;
|
||||
}
|
||||
|
||||
void Human::Initialize()
|
||||
@ -70,8 +60,6 @@ void Human::Initialize()
|
||||
RecalcSelfCollider();
|
||||
volume_ = meta->volume;
|
||||
observers_.insert(this);
|
||||
movement = new MovementComponent();
|
||||
movement->owner = this;
|
||||
}
|
||||
|
||||
float Human::GetSpeed()
|
||||
@ -343,43 +331,6 @@ bool Human::IsCollision()
|
||||
return !objects.empty();
|
||||
}
|
||||
|
||||
bool Human::IsCollisionInWalkZone()
|
||||
{
|
||||
if (room->OverBorder(pos, meta->i->radius())){
|
||||
return true;
|
||||
}
|
||||
|
||||
if (a8::HasBitFlag(status, HS_Jump)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (last_collider && !last_collider->owner->dead) {
|
||||
CircleCollider circle_box;
|
||||
GetCircleBox(circle_box);
|
||||
if (circle_box.Intersect(last_collider)) {
|
||||
if (last_collision_door != last_collider->owner) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Entity* entity : seen_objects) {
|
||||
switch (entity->entity_type) {
|
||||
case ET_Obstacle:
|
||||
case ET_Building:
|
||||
{
|
||||
if (!entity->dead && TestCollision(entity)) {
|
||||
if (last_collision_door != entity) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Human::IsCollisionInMapService()
|
||||
{
|
||||
if (room->OverBorder(pos, meta->i->radius())){
|
||||
@ -455,51 +406,6 @@ void Human::FindPath()
|
||||
pos = old_pos;
|
||||
}
|
||||
|
||||
void Human::FindPathInWalkZone()
|
||||
{
|
||||
Vector2D old_pos = pos;
|
||||
{
|
||||
float up_dot = Vector2D::UP.Dot(move_dir);
|
||||
bool at_left_side = Vector2D::LEFT.Dot(move_dir) > 0.0001f;
|
||||
if (std::abs(up_dot) <= 0.001f) { //相互垂直
|
||||
//向上
|
||||
pos = old_pos + Vector2D::UP;
|
||||
if (!IsCollisionInWalkZone()) {
|
||||
return;
|
||||
} else {
|
||||
//向下
|
||||
pos = old_pos + Vector2D::DOWN;
|
||||
if (!IsCollisionInWalkZone()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (up_dot > 0.001f) { //基本相同
|
||||
pos = old_pos + (at_left_side ? Vector2D::LEFT : Vector2D::RIGHT);
|
||||
if (!IsCollisionInWalkZone()) {
|
||||
return;
|
||||
} else {
|
||||
//向上
|
||||
pos = old_pos + Vector2D::UP;
|
||||
if (!IsCollisionInWalkZone()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (up_dot < 0.001f) { //基本相反
|
||||
pos = old_pos + (at_left_side ? Vector2D::LEFT : Vector2D::RIGHT);
|
||||
if (!IsCollisionInWalkZone()) {
|
||||
return;
|
||||
} else {
|
||||
//向下
|
||||
pos = old_pos + Vector2D::DOWN;
|
||||
if (!IsCollisionInWalkZone()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pos = old_pos;
|
||||
}
|
||||
|
||||
void Human::FindPathInMapService()
|
||||
{
|
||||
Vector2D old_pos = pos;
|
||||
@ -1879,112 +1785,6 @@ int Human::SkinLv()
|
||||
return skin.skin_lv;
|
||||
}
|
||||
|
||||
void Human::GenerateWalkZone()
|
||||
{
|
||||
in_walk_zone = true;
|
||||
walk_zone_center = pos;
|
||||
seen_colliders.clear();
|
||||
seen_objects.clear();
|
||||
last_collider = nullptr;
|
||||
for (auto& grid : grid_list) {
|
||||
for (Entity* entity : grid->entity_list) {
|
||||
switch (entity->entity_type) {
|
||||
case ET_Obstacle:
|
||||
case ET_Building:
|
||||
{
|
||||
if (
|
||||
(last_collision_door == nullptr || last_collision_door != entity)
|
||||
){
|
||||
AabbCollider aabb_box;
|
||||
entity->GetAabbBox(aabb_box);
|
||||
if (IntersectAabbAabb(walk_zone_center + walk_zone->_min,
|
||||
walk_zone_center + walk_zone->_max,
|
||||
aabb_box.owner->pos + aabb_box._min,
|
||||
aabb_box.owner->pos + aabb_box._max)
|
||||
) {
|
||||
seen_objects.insert(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}//end for
|
||||
}
|
||||
|
||||
bool Human::InWalkZone()
|
||||
{
|
||||
float delta = 10.0f;
|
||||
if (pos.x - meta->i->radius() < walk_zone_center.x + walk_zone->_min.x - delta) {
|
||||
return false;
|
||||
}
|
||||
if (pos.x + meta->i->radius() > walk_zone_center.x + walk_zone->_max.x - delta) {
|
||||
return false;
|
||||
}
|
||||
if (pos.y - meta->i->radius() < walk_zone_center.y + walk_zone->_min.y - delta) {
|
||||
return false;
|
||||
}
|
||||
if (pos.y + meta->i->radius() > walk_zone_center.y + walk_zone->_max.y - delta) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Human::ClearWalkZone()
|
||||
{
|
||||
in_walk_zone = false;
|
||||
}
|
||||
|
||||
void Human::UpdateMoveInWalkZone(int speed)
|
||||
{
|
||||
for (int i = 0; i < speed; ++i) {
|
||||
Vector2D old_pos = pos;
|
||||
pos = pos + move_dir;
|
||||
if (InWalkZone()) {
|
||||
if (IsCollisionInWalkZone()) {
|
||||
pos = old_pos;
|
||||
FindPathInWalkZone();
|
||||
if (rand() % 3 == 0) {
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ClearWalkZone();
|
||||
pos = old_pos;
|
||||
movement->RayDetection();
|
||||
App::Instance()->perf.params[5]++;
|
||||
UpdateMoveInMap(speed - i);
|
||||
return;
|
||||
}
|
||||
room->grid_service.MoveHuman(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Human::UpdateMoveInMap(int speed)
|
||||
{
|
||||
for (int i = 0; i < speed; ++i) {
|
||||
Vector2D old_pos = pos;
|
||||
pos = pos + move_dir;
|
||||
if (movement->TestCollision()) {
|
||||
pos = old_pos;
|
||||
GenerateWalkZone();
|
||||
UpdateMoveInWalkZone(speed - i);
|
||||
return;
|
||||
} else {
|
||||
movement->passed_distance += 1;
|
||||
if (movement->passed_distance + 10 > movement->target_distance) {
|
||||
movement->RayDetection();
|
||||
App::Instance()->perf.params[5]++;
|
||||
}
|
||||
}
|
||||
room->grid_service.MoveHuman(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Human::_UpdateMove(int speed)
|
||||
{
|
||||
for (int i = 0; i < speed; ++i) {
|
||||
|
@ -31,7 +31,6 @@ struct xtimer_list;
|
||||
class CircleCollider;
|
||||
class AabbCollider;
|
||||
class Obstacle;
|
||||
class MovementComponent;
|
||||
class Human : public Entity
|
||||
{
|
||||
public:
|
||||
@ -128,10 +127,8 @@ class Human : public Entity
|
||||
void Shot(Vector2D& target_dir);
|
||||
void RecalcSelfCollider();
|
||||
bool IsCollision();
|
||||
bool IsCollisionInWalkZone();
|
||||
bool IsCollisionInMapService();
|
||||
void FindPath();
|
||||
void FindPathInWalkZone();
|
||||
void FindPathInMapService();
|
||||
float GetRadius();
|
||||
float GetMaxHP();
|
||||
@ -200,11 +197,6 @@ class Human : public Entity
|
||||
int SkinLv();
|
||||
|
||||
protected:
|
||||
void GenerateWalkZone();
|
||||
bool InWalkZone();
|
||||
void ClearWalkZone();
|
||||
void UpdateMoveInWalkZone(int speed);
|
||||
void UpdateMoveInMap(int speed);
|
||||
void _UpdateMove(int speed);
|
||||
|
||||
private:
|
||||
@ -241,14 +233,6 @@ protected:
|
||||
std::set<Human*> observers_;
|
||||
Human* follow_target_ = nullptr;
|
||||
bool follow_synced_active_player = false;
|
||||
MovementComponent* movement = nullptr;
|
||||
|
||||
bool in_walk_zone = false;
|
||||
Vector2D walk_zone_center;
|
||||
AabbCollider* walk_zone = nullptr;
|
||||
std::set<ColliderComponent*> seen_colliders;
|
||||
std::set<Entity*> seen_objects;
|
||||
ColliderComponent* last_collider = nullptr;
|
||||
|
||||
private:
|
||||
CircleCollider* self_collider_ = nullptr;
|
||||
|
@ -65,7 +65,6 @@ void MapService::UnInit()
|
||||
|
||||
void MapService::AddCollider(ColliderComponent* collider)
|
||||
{
|
||||
#if MAP_SERVICE
|
||||
CellNode* top_node = nullptr;
|
||||
CellNode* bot_node = nullptr;
|
||||
switch (collider->type) {
|
||||
@ -142,7 +141,6 @@ void MapService::AddCollider(ColliderComponent* collider)
|
||||
node_hash_[collider] = top_node;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void MapService::RemoveCollider(ColliderComponent* collider)
|
||||
|
@ -1,180 +0,0 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include "movement.h"
|
||||
#include "bullet.h"
|
||||
#include "human.h"
|
||||
#include "room.h"
|
||||
#include "metadata.h"
|
||||
#include "collider.h"
|
||||
#include "collision.h"
|
||||
#include "app.h"
|
||||
#include "obstacle.h"
|
||||
|
||||
void MovementComponent::RayDetection()
|
||||
{
|
||||
Clear();
|
||||
App::Instance()->perf.ray_times++;
|
||||
long long tick = a8::XGetTickCount();
|
||||
Vector2D left_p0;
|
||||
Vector2D left_p1;
|
||||
Vector2D right_p0;
|
||||
Vector2D right_p1;
|
||||
if (owner->entity_type == ET_Bullet) {
|
||||
Bullet* bullet = (Bullet*)owner;
|
||||
Init(bullet->pos, bullet->born_dir, bullet->gun_meta->i->bullet_rad(), MAP_CELL_WIDTH - MAP_GRID_WIDTH * 3,
|
||||
left_p0, left_p1, right_p0, right_p1);
|
||||
} else if (owner->entity_type == ET_Player) {
|
||||
Human* hum = (Human*)owner;
|
||||
Init(hum->pos, hum->move_dir, hum->meta->i->radius(), MAP_CELL_WIDTH - MAP_GRID_WIDTH * 3,
|
||||
left_p0, left_p1, right_p0, right_p1);
|
||||
}
|
||||
int count = 0;
|
||||
for (auto& grid : owner->grid_list) {
|
||||
for (Entity* entity : grid->entity_list) {
|
||||
count++;
|
||||
switch (entity->entity_type) {
|
||||
case ET_Building:
|
||||
case ET_Obstacle:
|
||||
{
|
||||
if (entity->entity_type == ET_Obstacle && ((Obstacle*)entity)->is_door) {
|
||||
//门直接加入检查列表
|
||||
detection_objects.insert(entity);
|
||||
} else {
|
||||
AabbCollider aabb_box;
|
||||
entity->GetAabbBox(aabb_box);
|
||||
if (IntersectSegmentAabb(left_p0, left_p1,
|
||||
aabb_box.owner->pos + aabb_box._min,
|
||||
aabb_box.owner->pos + aabb_box._max) ||
|
||||
IntersectSegmentAabb(right_p0, right_p1,
|
||||
aabb_box.owner->pos + aabb_box._min,
|
||||
aabb_box.owner->pos + aabb_box._max)
|
||||
) {
|
||||
detection_objects.insert(entity);
|
||||
}
|
||||
}
|
||||
App::Instance()->perf.params[4]++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}//end for entity_list
|
||||
}//end for grid
|
||||
if (App::Instance()->perf.params[2] < count) {
|
||||
App::Instance()->perf.params[2] = count;
|
||||
}
|
||||
if (App::Instance()->perf.params[6] < detection_objects.size()) {
|
||||
App::Instance()->perf.params[6] = detection_objects.size();
|
||||
}
|
||||
App::Instance()->perf.ray_time += a8::XGetTickCount() - tick;
|
||||
}
|
||||
|
||||
void MovementComponent::Clear()
|
||||
{
|
||||
passed_distance = 0.0f;
|
||||
target_distance = 0.0f;
|
||||
start_point = Vector2D();
|
||||
target_point = Vector2D();
|
||||
detection_objects.clear();
|
||||
}
|
||||
|
||||
void MovementComponent::GetCollisionObjects(std::set<Entity*>& objects)
|
||||
{
|
||||
if (owner->entity_type == ET_Bullet) {
|
||||
Bullet* bullet = (Bullet*)owner;
|
||||
for (Entity* entity : detection_objects) {
|
||||
switch (entity->entity_type) {
|
||||
case ET_Obstacle:
|
||||
case ET_Building:
|
||||
{
|
||||
if (!entity->dead && bullet->TestCollision(entity)) {
|
||||
objects.insert(entity);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool MovementComponent::TestCollision()
|
||||
{
|
||||
if (owner->entity_type == ET_Bullet) {
|
||||
Bullet* bullet = (Bullet*)owner;
|
||||
if (bullet->room->OverBorder(bullet->pos, bullet->gun_meta->i->bullet_rad())){
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Entity* entity : detection_objects) {
|
||||
switch (entity->entity_type) {
|
||||
case ET_Obstacle:
|
||||
case ET_Building:
|
||||
{
|
||||
if (!entity->dead && bullet->TestCollision(entity)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (owner->entity_type == ET_Player) {
|
||||
Human* hum = (Human*)owner;
|
||||
if (hum->room->OverBorder(hum->pos, hum->meta->i->radius())){
|
||||
return true;
|
||||
}
|
||||
if (a8::HasBitFlag(hum->status, HS_Jump)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Entity* entity : detection_objects) {
|
||||
switch (entity->entity_type) {
|
||||
case ET_Obstacle:
|
||||
case ET_Building:
|
||||
{
|
||||
if (!entity->dead && hum->TestCollision(entity)) {
|
||||
if (hum->last_collision_door != entity) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void MovementComponent::Init(Vector2D pos, Vector2D dir, float rad, float distance,
|
||||
Vector2D& left_p0, Vector2D& left_p1, Vector2D& right_p0, Vector2D& right_p1)
|
||||
{
|
||||
start_point = pos;
|
||||
target_point = pos + dir * (MAP_CELL_WIDTH - MAP_GRID_WIDTH);
|
||||
target_distance = (target_point - start_point).Norm();
|
||||
|
||||
Vector2D left_dir = dir;
|
||||
left_dir.Rotate(-90 / 180.f);
|
||||
left_dir.Normalize();
|
||||
Vector2D right_dir = dir;
|
||||
right_dir.Rotate(+90 / 180.f);
|
||||
right_dir.Normalize();
|
||||
|
||||
left_p0 = pos + left_dir * (rad + 1);
|
||||
left_p1 = left_p0 + dir * distance;
|
||||
right_p0 = pos + right_dir * (rad + 1);
|
||||
right_p1 = right_p0 + dir * distance;
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
class Entity;
|
||||
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();
|
||||
|
||||
private:
|
||||
|
||||
void Init(Vector2D pos, Vector2D dir, float rad, float distance,
|
||||
Vector2D& left_p0, Vector2D& left_p1, Vector2D& right_p0, Vector2D& right_p1);
|
||||
};
|
@ -12,7 +12,6 @@
|
||||
#include "building.h"
|
||||
#include "loot.h"
|
||||
#include "app.h"
|
||||
#include "movement.h"
|
||||
#include "collider.h"
|
||||
|
||||
Player::Player():Human()
|
||||
@ -108,25 +107,15 @@ void Player::UpdateMove()
|
||||
moving = false;
|
||||
moved_frames = 0;
|
||||
last_collision_door = nullptr;
|
||||
movement->Clear();
|
||||
return;
|
||||
}
|
||||
++moved_frames;
|
||||
if (moved_frames > 4) {
|
||||
moving = false;
|
||||
moved_frames = 0;
|
||||
movement->Clear();
|
||||
return;
|
||||
}
|
||||
#if MAP_SERVICE
|
||||
_UpdateMove(std::max(1, (int)GetSpeed()));
|
||||
#else
|
||||
if (in_walk_zone) {
|
||||
UpdateMoveInWalkZone(std::max(1, (int)GetSpeed()));
|
||||
} else {
|
||||
UpdateMoveInMap(std::max(1, (int)GetSpeed()));
|
||||
}
|
||||
#endif
|
||||
if (last_collision_door && !TestCollision(last_collision_door)) {
|
||||
last_collision_door = nullptr;
|
||||
}
|
||||
@ -833,14 +822,6 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
|
||||
move_dir.FromPB(&msg.move_dir());
|
||||
move_dir.Normalize();
|
||||
moving = true;
|
||||
#if MAP_SERVICE
|
||||
#else
|
||||
if (std::abs(move_dir.x - old_move_dir.x) > 0.000001f ||
|
||||
std::abs(move_dir.y - old_move_dir.y) > 0.000001f) {
|
||||
ClearWalkZone();
|
||||
movement->RayDetection();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
assert(!isnan(move_dir.x) && !isnan(move_dir.y));
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "roommgr.h"
|
||||
#include "app.h"
|
||||
#include "hero.h"
|
||||
#include "movement.h"
|
||||
#include "gamelog.h"
|
||||
|
||||
const int ROOM_MAX_PLAYER_NUM = 50;
|
||||
@ -563,10 +562,6 @@ void Room::CreateBullet(Human* hum, Weapon* weapon,
|
||||
bullet->Initialize();
|
||||
AddObjectLater(bullet);
|
||||
grid_service.AddBullet(bullet);
|
||||
#if MAP_SERVICE
|
||||
#else
|
||||
bullet->movement->RayDetection();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Room::RemoveObjectLater(Entity* entity)
|
||||
|
Loading…
x
Reference in New Issue
Block a user