add moveableentity

This commit is contained in:
aozhiwei 2020-05-20 15:46:49 +08:00
parent 67610ac3cf
commit 51adf8e366
10 changed files with 22 additions and 11 deletions

View File

@ -1,10 +1,10 @@
#pragma once
class RoomEntity;
class MoveableEntity;
class AIComponent
{
public:
RoomEntity* owner = nullptr;
MoveableEntity* owner = nullptr;
virtual ~AIComponent();
virtual void Update(int delta_time);

View File

@ -8,7 +8,7 @@
#include "player.h"
#include "app.h"
Bullet::Bullet():RoomEntity()
Bullet::Bullet():MoveableEntity()
{
entity_type = ET_Bullet;
++App::Instance()->perf.entity_num[ET_Bullet];

View File

@ -1,6 +1,6 @@
#pragma once
#include "roomentity.h"
#include "moveableentity.h"
namespace MetaData
{
@ -13,7 +13,7 @@ class Human;
class Obstacle;
class CircleCollider;
class MovementComponent;
class Bullet : public RoomEntity
class Bullet : public MoveableEntity
{
public:
int gun_lv = 0;

View File

@ -20,7 +20,6 @@ class Entity
int entity_uniid = 0;
EntityType_e entity_type = ET_None;
EntitySubType_e entity_subtype = EST_None;
int updated_times = 0;
bool is_permanent = false;
MapService* permanent_map_service = nullptr;

View File

@ -28,7 +28,7 @@
const int kReviveTimeAdd = 12;
const int kSkinNum = 4;
Human::Human():RoomEntity()
Human::Human():MoveableEntity()
{
default_weapon.weapon_idx = 0;
default_weapon.weapon_id = 12101;

View File

@ -1,6 +1,6 @@
#pragma once
#include "roomentity.h"
#include "moveableentity.h"
#include "cs_proto.pb.h"
#include "GGListener.h"
@ -26,7 +26,7 @@ class AabbCollider;
class Obstacle;
class Loot;
class Buff;
class Human : public RoomEntity
class Human : public MoveableEntity
{
public:
int socket_handle = 0;

View File

View File

@ -0,0 +1,10 @@
#pragma once
#include "roomentity.h"
class MoveableEntity : public RoomEntity
{
public:
int updated_times = 0;
};

View File

@ -1185,7 +1185,8 @@ void Room::AddObjectLater(RoomEntity* entity)
{
RoomEntity* entity = (RoomEntity*)param.sender.GetUserData();
if (entity->entity_type == ET_Bullet) {
entity->room->moveable_hash_[entity->entity_uniid] = entity;
MoveableEntity* moveableentity = (MoveableEntity*)entity;
entity->room->moveable_hash_[entity->entity_uniid] = moveableentity;
}
entity->room->uniid_hash_[entity->entity_uniid] = entity;
entity->room->later_add_hash_.erase(entity->entity_uniid);

View File

@ -26,6 +26,7 @@ struct timer_list;
struct xtimer_list;
class Entity;
class RoomEntity;
class MoveableEntity;
class Obstacle;
class Bullet;
class Human;
@ -156,7 +157,7 @@ private:
std::set<int> refreshed_robot_set_;
std::map<int, std::set<Human*>> team_hash_;
std::map<std::string, Player*> accountid_hash_;
std::map<int, Entity*> moveable_hash_;
std::map<int, MoveableEntity*> moveable_hash_;
std::map<int, Entity*> uniid_hash_;
std::map<int, Entity*> later_add_hash_;
std::map<int, Human*> human_hash_;