This commit is contained in:
aozhiwei 2023-02-20 15:30:14 +08:00
parent 67a954d0db
commit b3a3888fb3
7 changed files with 37 additions and 13 deletions

View File

@ -482,16 +482,18 @@ A8_DECLARE_ENUM(TimerUserEvent_e,
kDeactiveDjsSkillTimerEvent
);
A8_DECLARE_CLASS_ENUM(GraspBuffTrigger, int,
A8_DECLARE_CLASS_ENUM(GraspBuffTrigger_e, int,
kHit = 1,
kKill = 2,
kTakeOn = 3,
kCond = 4,
kHitAndEnd = 5
kHitAndEnd = 5,
kEnd
);
A8_DECLARE_CLASS_ENUM(GraspBuffTriggerCond, int,
kImprint = 1
A8_DECLARE_CLASS_ENUM(GraspBuffTriggerCond_e, int,
kImprint = 1,
kEnd
);
const char* const PROJ_NAME_FMT = "game%d_gameserver";

View File

@ -20,6 +20,7 @@
#include "buff.h"
#include "mapinstance.h"
#include "collision.h"
#include "gungrasp.h"
#include "mt/Param.h"
#include "mt/Hero.h"
@ -59,6 +60,7 @@ Creature::Creature():MoveableEntity()
inventory_[IS_1XSCOPE].num = 1;
movement_ = std::make_shared<Movement>(this);
gun_grasp_ = std::make_shared<GunGrasp>(this);
}
Creature::~Creature()
@ -1601,7 +1603,6 @@ void Creature::SetCurrWeapon(Weapon* weapon)
room->xtimer.Delete(auto_switch_weapon_timer_);
}
if (curr_weapon_ != weapon) {
GetCurrWeapon()->CalcGraspBuffList(this);
GetTrigger()->TakeonWeapon(curr_weapon_, weapon);
}
curr_weapon_ = weapon;

View File

@ -62,6 +62,7 @@ class Trigger;
class DelayAddBuffHandle;
class Movement;
class Player;
class GunGrasp;
class Creature : public MoveableEntity
{
public:
@ -378,6 +379,8 @@ private:
std::map<int, long long> buff_interval_hash_;
std::array<Inventory, IS_END> inventory_ = {};
std::shared_ptr<GunGrasp> gun_grasp_;
friend class Buff;
friend class AddInventoryBuff;
friend class BePullBuff;
@ -390,4 +393,5 @@ private:
friend class Skill;
friend class Trigger;
friend class PBUtils;
friend class GunGrasp;
};

View File

@ -0,0 +1,11 @@
#include "precompile.h"
#include "gungrasp.h"
GunGrasp::GunGrasp(Creature* owner)
{
owner_ = owner;
for (auto& node : grasp_triggers_) {
INIT_LIST_HEAD(&node);
}
}

View File

@ -0,0 +1,12 @@
#pragma once
class Creature;
class GunGrasp
{
public:
GunGrasp(Creature* owner);
private:
Creature* owner_ = nullptr;
std::array<list_head, (int)GraspBuffTrigger_e::kEnd> grasp_triggers_ = {};
};

View File

@ -15,7 +15,6 @@ void Weapon::Clear()
meta = nullptr;
bullet_meta = nullptr;
skill_meta = nullptr;
grasp_buff_list.clear();
}
void Weapon::Recalc()
@ -49,8 +48,3 @@ int Weapon::GetReloadTime(Creature* c)
return meta ? meta->reload_time() :0;
}
}
void Weapon::CalcGraspBuffList(Creature* c)
{
grasp_buff_list.clear();
}

View File

@ -17,7 +17,6 @@ class Weapon
const mt::Equip* meta = nullptr;
const mt::Equip* bullet_meta = nullptr;
const mt::Skill* skill_meta = nullptr;
std::vector<const mt::GraspBuff*> grasp_buff_list;
void Clear();
void ToPB(Creature* c, cs::MFWeapon* pb_obj);
@ -25,7 +24,8 @@ class Weapon
int GetClipVolume(Creature* c);
int GetFireRate(Creature* c);
int GetReloadTime(Creature* c);
void CalcGraspBuffList(Creature* c);
private:
friend class PBUtils;
};