remove movement
This commit is contained in:
parent
b3da54c99c
commit
0e44bf23f8
@ -2,7 +2,6 @@
|
||||
|
||||
#include "android.ai.h"
|
||||
#include "android.h"
|
||||
#include "movement.h"
|
||||
#include "room.h"
|
||||
#include "metamgr.h"
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include "android.h"
|
||||
#include "metamgr.h"
|
||||
#include "movement.h"
|
||||
#include "android.ai.h"
|
||||
|
||||
Android::Android():Human()
|
||||
@ -27,6 +26,5 @@ void Android::Initialize()
|
||||
|
||||
void Android::Update(int delta_time)
|
||||
{
|
||||
movement->Update(delta_time);
|
||||
ai->Update(delta_time);
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include "bullet.h"
|
||||
#include "metamgr.h"
|
||||
#include "movement.h"
|
||||
#include "room.h"
|
||||
#include "collider.h"
|
||||
#include "obstacle.h"
|
||||
@ -11,14 +10,10 @@
|
||||
Bullet::Bullet():Entity()
|
||||
{
|
||||
entity_type = ET_Bullet;
|
||||
movement = new MovementComponent();
|
||||
movement->owner = this;
|
||||
}
|
||||
|
||||
Bullet::~Bullet()
|
||||
{
|
||||
delete movement;
|
||||
movement = nullptr;
|
||||
}
|
||||
|
||||
void Bullet::Initialize()
|
||||
@ -28,7 +23,6 @@ void Bullet::Initialize()
|
||||
|
||||
void Bullet::Update(int delta_time)
|
||||
{
|
||||
movement->Update(delta_time);
|
||||
pos = pos + dir * gun_meta->i->bullet_speed() / 20.0f;
|
||||
float distance = (pos - born_pos).Norm();
|
||||
if (meta->i->_inventory_slot() == 5 ||
|
||||
|
@ -34,7 +34,6 @@ enum EntitySubType_e
|
||||
class Room;
|
||||
class Obstacle;
|
||||
class ColliderComponent;
|
||||
class MovementComponent;
|
||||
class Entity
|
||||
{
|
||||
public:
|
||||
@ -44,7 +43,6 @@ class Entity
|
||||
Room* room = nullptr;
|
||||
Vector2D pos;
|
||||
int updated_times = 0;
|
||||
MovementComponent* movement = nullptr;
|
||||
std::list<ColliderComponent*> colliders;
|
||||
bool deleted = false;
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include "human.h"
|
||||
#include "cs_proto.pb.h"
|
||||
#include "movement.h"
|
||||
#include "metamgr.h"
|
||||
#include "room.h"
|
||||
#include "bullet.h"
|
||||
@ -11,8 +10,6 @@
|
||||
|
||||
Human::Human()
|
||||
{
|
||||
movement = new MovementComponent();
|
||||
movement->owner = this;
|
||||
default_weapon.weapon_idx = 0;
|
||||
default_weapon.weapon_id = 12101;
|
||||
default_weapon.weapon_lv = 1;
|
||||
@ -37,8 +34,6 @@ Human::Human()
|
||||
|
||||
Human::~Human()
|
||||
{
|
||||
delete movement;
|
||||
movement = nullptr;
|
||||
}
|
||||
|
||||
void Human::Initialize()
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include "loot.h"
|
||||
#include "metamgr.h"
|
||||
#include "movement.h"
|
||||
#include "room.h"
|
||||
#include "collider.h"
|
||||
|
||||
|
@ -1,57 +0,0 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include "movement.h"
|
||||
#include "entity.h"
|
||||
|
||||
void MovementComponent::Update(int delta_time)
|
||||
{
|
||||
if (path_index_ < paths_.size()) {
|
||||
MovePathPoint& target_point = paths_[path_index_];
|
||||
if (owner->pos == target_point.pos) {
|
||||
++path_index_;
|
||||
return;
|
||||
}
|
||||
#if 1
|
||||
assert(false);
|
||||
#else
|
||||
Vector2D dir = target_point.pos - owner->pos;
|
||||
dir.Normalize();
|
||||
float distance = path.Norm();
|
||||
owner->pos = owner->pos + dir * std::min(move_speed_, distance);
|
||||
if (owner->pos == target_point.pos) {
|
||||
++path_index_;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
bool MovementComponent::GetMovePosition(int delta_time, Vector2D& out_pos)
|
||||
{
|
||||
if (path_index_ < paths_.size()) {
|
||||
MovePathPoint& target_point = paths_[path_index_];
|
||||
out_pos = owner->pos + (target_point.pos - owner->pos) * delta_time * move_speed_;
|
||||
} else {
|
||||
out_pos = owner->pos;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MovementComponent::Arrived()
|
||||
{
|
||||
return path_index_ >= paths_.size();
|
||||
}
|
||||
|
||||
void MovementComponent::AddPathPoint(Vector2D& pos, float distance, float speed)
|
||||
{
|
||||
MovePathPoint& point = a8::FastAppend(paths_);
|
||||
point.pos = pos;
|
||||
point.distance = distance;
|
||||
move_speed_ = speed;
|
||||
}
|
||||
|
||||
void MovementComponent::ClearPath()
|
||||
{
|
||||
move_speed_ = 0.0f;
|
||||
path_index_ = 0;
|
||||
paths_.clear();
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
struct MovePathPoint
|
||||
{
|
||||
Vector2D pos;
|
||||
float distance = 0.0;
|
||||
};
|
||||
|
||||
class Entity;
|
||||
class MovementComponent
|
||||
{
|
||||
public:
|
||||
Entity* owner = nullptr;
|
||||
|
||||
virtual void Update(int delta_time);
|
||||
bool GetMovePosition(int delta_time, Vector2D& out_pos);
|
||||
bool Arrived();
|
||||
void AddPathPoint(Vector2D& pos, float distance, float speed);
|
||||
void ClearPath();
|
||||
|
||||
private:
|
||||
float move_speed_ = 0.0f;
|
||||
size_t path_index_ = 0;
|
||||
std::vector<MovePathPoint> paths_;
|
||||
};
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include "obstacle.h"
|
||||
#include "metamgr.h"
|
||||
#include "movement.h"
|
||||
#include "room.h"
|
||||
#include "collider.h"
|
||||
#include "building.h"
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "cs_proto.pb.h"
|
||||
#include "room.h"
|
||||
#include "metamgr.h"
|
||||
#include "movement.h"
|
||||
#include "bullet.h"
|
||||
#include "obstacle.h"
|
||||
#include "building.h"
|
||||
@ -37,7 +36,6 @@ void Player::Update(int delta_time)
|
||||
if (poisoning) {
|
||||
poisoning_time += delta_time;
|
||||
}
|
||||
movement->Update(delta_time);
|
||||
if (moving) {
|
||||
UpdateMove();
|
||||
}
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "room.h"
|
||||
#include "android.h"
|
||||
#include "metamgr.h"
|
||||
#include "movement.h"
|
||||
#include "bullet.h"
|
||||
#include "collider.h"
|
||||
#include "obstacle.h"
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "playermgr.h"
|
||||
#include "app.h"
|
||||
#include "metamgr.h"
|
||||
#include "movement.h"
|
||||
|
||||
void RoomMgr::Init()
|
||||
{
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include "smoke.h"
|
||||
#include "metamgr.h"
|
||||
#include "movement.h"
|
||||
#include "room.h"
|
||||
#include "collider.h"
|
||||
#include "obstacle.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user