aozhiwei 1931d8c707 1
2019-07-23 14:53:35 +08:00

59 lines
1.3 KiB
C++

#include "precompile.h"
#include "loot.h"
#include "metamgr.h"
#include "room.h"
#include "collider.h"
#include "entity.h"
#include "app.h"
#include "typeconvert.h"
Loot::Loot():Entity()
{
entity_type = kET_Loot;
++App::Instance()->perf.entity_num[kET_Loot];
}
Loot::~Loot()
{
--App::Instance()->perf.entity_num[kET_Loot];
}
void Loot::Initialize()
{
Entity::Initialize();
RecalcSelfCollider();
}
void Loot::RecalcSelfCollider()
{
if (!self_collider_) {
self_collider_ = new CircleCollider();
self_collider_->owner = this;
self_collider_->tag = kColliderTag_Loot;
AddCollider(self_collider_);
}
self_collider_->pos = a8::Vec2();
self_collider_->rad = 64.0f / 2.0;
room->map_service.AddCollider(self_collider_);
}
void Loot::FillMFObjectPart(cs::MFObjectPart* part_data)
{
part_data->set_object_type(kET_Loot);
cs::MFLootPart* p = part_data->mutable_union_obj_5();
p->set_obj_uniid(entity_uniid);
TypeConvert::ToPb(pos, p->mutable_pos());
}
void Loot::FillMFObjectFull(cs::MFObjectFull* full_data)
{
full_data->set_object_type(kET_Loot);
cs::MFLootFull* p = full_data->mutable_union_obj_5();
p->set_obj_uniid(entity_uniid);
TypeConvert::ToPb(pos, p->mutable_pos());
p->set_item_id(item_id);
p->set_count(count);
}