hero ok
This commit is contained in:
parent
1b7064b92a
commit
d6fec365aa
@ -20,6 +20,7 @@ enum EntityType_e
|
||||
//ET_Decal = 7,
|
||||
//ET_Projectile = 8,
|
||||
ET_Smoke = 9,
|
||||
ET_Hero = 10,
|
||||
|
||||
ET_Bullet = 20,
|
||||
|
||||
|
@ -0,0 +1,65 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include "hero.h"
|
||||
#include "collider.h"
|
||||
#include "human.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;
|
||||
colliders.push_back(self_collider_);
|
||||
}
|
||||
self_collider_->pos = Vector2D();
|
||||
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);
|
||||
pos.ToPB(p->mutable_pos());
|
||||
attack_dir.ToPB(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);
|
||||
pos.ToPB(p->mutable_pos());
|
||||
attack_dir.ToPB(p->mutable_dir());
|
||||
|
||||
p->set_skin(skin);
|
||||
p->set_backpack(backpack);
|
||||
p->set_helmet(helmet);
|
||||
p->set_chest(chest);
|
||||
weapon.ToPB(p->mutable_weapon());
|
||||
}
|
||||
|
||||
ColliderComponent* Hero::GetBoxBound()
|
||||
{
|
||||
CircleCollider* collider = new CircleCollider();
|
||||
collider->owner = this;
|
||||
collider->pos = Vector2D();
|
||||
collider->rad = master->GetRadius();
|
||||
return collider;
|
||||
}
|
@ -2,6 +2,10 @@
|
||||
|
||||
#include "entity.h"
|
||||
|
||||
class Building;
|
||||
class CircleCollider;
|
||||
class AabbCollider;
|
||||
class Human;
|
||||
class Hero : public Entity
|
||||
{
|
||||
public:
|
||||
@ -9,7 +13,7 @@ class Hero : public Entity
|
||||
Vector2D move_dir;
|
||||
Vector2D attack_dir;
|
||||
|
||||
int master_uniid = 0;
|
||||
Human* master = nullptr;
|
||||
|
||||
int skin = 0;
|
||||
int backpack = 0;
|
||||
@ -17,6 +21,14 @@ class Hero : public Entity
|
||||
int chest = 0;
|
||||
Weapon weapon;
|
||||
|
||||
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;
|
||||
virtual ColliderComponent* GetBoxBound() override;
|
||||
|
||||
private:
|
||||
CircleCollider* self_collider_ = nullptr;
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "collision.h"
|
||||
#include "building.h"
|
||||
|
||||
Human::Human()
|
||||
Human::Human():Entity()
|
||||
{
|
||||
default_weapon.weapon_idx = 0;
|
||||
default_weapon.weapon_id = 12101;
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "building.h"
|
||||
#include "loot.h"
|
||||
|
||||
Player::Player()
|
||||
Player::Player():Human()
|
||||
{
|
||||
entity_type = ET_Player;
|
||||
entity_subtype = EST_Player;
|
||||
@ -20,6 +20,7 @@ Player::Player()
|
||||
|
||||
Player::~Player()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Player::Initialize()
|
||||
|
Loading…
x
Reference in New Issue
Block a user