remove hero.cc hero.h smoke.cc somke.h

This commit is contained in:
aozhiwei 2020-05-19 10:04:36 +08:00
parent 2affb61573
commit 4e8b61e4ae
9 changed files with 8 additions and 230 deletions

View File

@ -12,14 +12,18 @@ Android::Android():Human()
entity_subtype = EST_Android;
ai = new AndroidAI;
ai->owner = this;
#if 0
++App::Instance()->perf.entity_num[ET_Android];
#endif
}
Android::~Android()
{
delete ai;
ai = nullptr;
#if 0
--App::Instance()->perf.entity_num[ET_Android];
#endif
}
void Android::Initialize()

View File

@ -214,12 +214,13 @@ enum EntityType_e
//ET_DeadBody = 6,
//ET_Decal = 7,
//ET_Projectile = 8,
ET_Smoke = 9,
ET_Hero = 10,
//ET_Smoke = 9,
//ET_Hero = 10,
ET_Bullet = 20,
ET_Android = 30,
//ET_Android = 30,
ET_Unuse = 30,
ET_MAX
};

View File

@ -1,58 +0,0 @@
#include "precompile.h"
#include "hero.h"
#include "collider.h"
#include "human.h"
#include "typeconvert.h"
Hero::Hero(): Entity()
{
entity_type = ET_Hero;
}
Hero::~Hero()
{
}
void Hero::Initialize()
{
Entity::Initialize();
RecalcSelfCollider();
}
void Hero::RecalcSelfCollider()
{
if (!self_collider_) {
self_collider_ = new CircleCollider();
self_collider_->owner = this;
AddCollider(self_collider_);
}
self_collider_->pos = a8::Vec2();
self_collider_->rad = master->GetRadius();
}
void Hero::FillMFObjectPart(cs::MFObjectPart* part_data)
{
part_data->set_object_type(entity_type);
cs::MFHeroPart* p = part_data->mutable_union_obj_10();
p->set_obj_uniid(entity_uniid);
TypeConvert::ToPb(GetPos(), p->mutable_pos());
TypeConvert::ToPb(attack_dir, p->mutable_dir());
}
void Hero::FillMFObjectFull(cs::MFObjectFull* full_data)
{
full_data->set_object_type(entity_type);
cs::MFHeroFull* p = full_data->mutable_union_obj_10();
p->set_obj_uniid(entity_uniid);
TypeConvert::ToPb(GetPos(), p->mutable_pos());
TypeConvert::ToPb(attack_dir, p->mutable_dir());
skin.ToPB(p->mutable_skin());
p->set_backpack(backpack);
p->set_helmet(helmet);
p->set_chest(chest);
weapon.ToPB(p->mutable_weapon());
p->set_energy_shield(energy_shield);
}

View File

@ -1,35 +0,0 @@
#pragma once
#include "entity.h"
class Building;
class CircleCollider;
class AabbCollider;
class Human;
class Hero : public Entity
{
public:
a8::Vec2 move_dir;
a8::Vec2 attack_dir;
Human* master = nullptr;
Skin skin;
int backpack = 0;
int helmet = 0;
int chest = 0;
Weapon weapon;
int energy_shield = 0;
Hero();
virtual ~Hero() override;
virtual void Initialize() override;
void RecalcSelfCollider();
virtual void FillMFObjectPart(cs::MFObjectPart* part_data) override;
virtual void FillMFObjectFull(cs::MFObjectFull* full_data) override;
private:
CircleCollider* self_collider_ = nullptr;
};

View File

@ -13,7 +13,6 @@
#include "collider.h"
#include "loot.h"
#include "building.h"
#include "hero.h"
#include "app.h"
#include "roommgr.h"
#include "android.h"
@ -1188,7 +1187,6 @@ void Human::RefreshView()
switch (entity->entity_type) {
case ET_Building:
case ET_Obstacle:
case ET_Hero:
case ET_Loot:
{
AddToNewObjects(entity);
@ -1224,7 +1222,6 @@ void Human::OnGridListChange(std::set<GridCell*>& old_grid_list,
switch (entity->entity_type) {
case ET_Building:
case ET_Obstacle:
case ET_Hero:
case ET_Loot:
{
AddToNewObjects(entity);
@ -1251,7 +1248,6 @@ void Human::OnGridListChange(std::set<GridCell*>& old_grid_list,
switch (entity->entity_type) {
case ET_Building:
case ET_Obstacle:
case ET_Hero:
case ET_Loot:
{
AddOutObjects(entity);
@ -1498,13 +1494,6 @@ void Human::FillBodyState(::google::protobuf::RepeatedPtrField<::cs::MFBodyState
state->set_left_time(std::max(0, skill_meta->last_time * 1000 - passed_time));
state->set_lasting_time(skill_meta->last_time * 1000);
}
if (a8::HasBitFlag(status, HS_SummonHero) && skill_meta) {
int passed_time = (room->frame_no - summon_hero_frameno_) * FRAME_RATE_MS;
cs::MFBodyState* state = states->Add();
state->set_state_type(HS_SummonHero);
state->set_left_time(std::max(0, skill_meta->last_time * 1000 - passed_time));
state->set_lasting_time(skill_meta->last_time * 1000);
}
#endif
if (a8::HasBitFlag(status, HS_AtkAdd)) {
cs::MFBodyState* state = states->Add();
@ -1531,39 +1520,6 @@ void Human::FillItemList(::google::protobuf::RepeatedPtrField<::cs::MFPair>* pb_
}
}
void Human::SummonHero()
{
#if 0
Hero* hero = room->CreateHero(this);
if (hero) {
summon_hero_frameno_ = room->frame_no;
a8::SetBitFlag(status, HS_SummonHero);
room->xtimer.AddDeadLineTimerAndAttach(skill_meta->last_time * SERVER_FRAME_RATE,
a8::XParams()
.SetSender(this)
.SetParam1(hero->entity_uniid),
[] (const a8::XParams& param)
{
},
&skill_xtimer_attacher_.timer_list_,
[] (const a8::XParams& param)
{
Human* hum = (Human*)param.sender.GetUserData();
Entity* hero = hum->room->GetEntityByUniId(param.param1);
if (hero && hero->entity_type == ET_Hero) {
hum->room->RemoveObjectLater(hero);
}
a8::UnSetBitFlag(hum->status, HS_SummonHero);
hum->need_sync_active_player = true;
hum->BroadcastFullState();
}
);
need_sync_active_player = true;
BroadcastFullState();
}
#endif
}
void Human::AddObserver(Human* observer)
{
observers_.insert(observer);
@ -1615,7 +1571,6 @@ void Human::SendUpdateMsg()
switch (entity->entity_type) {
case ET_Building:
case ET_Obstacle:
case ET_Hero:
case ET_Loot:
{
view_objects.insert(entity);

View File

@ -20,7 +20,6 @@
#include "loot.h"
#include "roommgr.h"
#include "app.h"
#include "hero.h"
#include "gamelog.h"
#include "typeconvert.h"
@ -500,39 +499,6 @@ Obstacle* Room::CreateObstacle(int id, float x, float y)
return entity;
}
Hero* Room::CreateHero(Human* hum)
{
a8::Vec2 pos = hum->GetPos();
{
a8::Vec2 dir = a8::Vec2::UP;
dir.Rotate(a8::RandAngle());
pos = pos + dir * (25 + rand() % 50);
}
Hero* hero = new Hero();
hero->room = this;
hero->entity_uniid = AllocUniid();
hero->SetPos(pos);
hero->move_dir = hum->move_dir;
hero->attack_dir = hum->attack_dir;
hero->master = hum;
#if 0
hero->skin = hum->GetSkin();
#endif
hero->backpack = hum->backpack;
hero->helmet = hum->helmet;
hero->chest = hum->chest;
hero->weapon = *hum->curr_weapon;
hero->energy_shield = hum->energy_shield;
hero->Initialize();
#if 1
uniid_hash_[hero->entity_uniid] = hero;
grid_service.AddEntity(hero);
#endif
hero->BroadcastFullState();
return hero;
}
int Room::CreateLoot(int equip_id, a8::Vec2 pos, int count, int equip_lv)
{
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(equip_id);
@ -611,7 +577,6 @@ void Room::RemoveObjectLater(Entity* entity)
}
break;
case ET_Loot:
case ET_Hero:
{
entity->BroadcastDeleteState();
entity->room->grid_service.DelEntity(entity);

View File

@ -81,7 +81,6 @@ public:
void ScatterDrop(a8::Vec2 center, int drop_id);
void DropItem(a8::Vec2 pos, int item_id, int item_count, int item_lv);
Hero* CreateHero(Human* hum);
int CreateLoot(int equip_id, a8::Vec2 pos, int count, int equip_lv);
void CreateBullet(Human* hum, Weapon* weapon,
a8::Vec2 pos, a8::Vec2 dir, float fly_distance, bool is_tank_skin = false);

View File

@ -1,26 +0,0 @@
#include "precompile.h"
#include "smoke.h"
#include "metamgr.h"
#include "room.h"
#include "collider.h"
#include "obstacle.h"
#include "player.h"
Smoke::Smoke():Entity()
{
entity_type = ET_Smoke;
}
Smoke::~Smoke()
{
}
void Smoke::Initialize()
{
Entity::Initialize();
}
void Smoke::Update(int delta_time)
{
}

View File

@ -1,27 +0,0 @@
#pragma once
#include "entity.h"
namespace MetaData
{
struct Player;
struct Equip;
}
class Human;
class Smoke : public Entity
{
public:
MetaData::Equip* gun_meta = nullptr;
MetaData::Equip* meta = nullptr;
Human* player = nullptr;
a8::Vec2 dir;
a8::Vec2 born_pos;
a8::Vec2 born_dir;
Smoke();
virtual ~Smoke() override;
virtual void Initialize() override;
virtual void Update(int delta_time) override;
};