完成action改造
This commit is contained in:
parent
4cf475dbd5
commit
a45e86ac58
@ -847,3 +847,49 @@ bool Creature::IsHuman() const
|
|||||||
{
|
{
|
||||||
return IsEntityType(ET_Player);
|
return IsEntityType(ET_Player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Creature::StartAction(ActionType_e action_type,
|
||||||
|
int action_duration,
|
||||||
|
int item_id,
|
||||||
|
int target_id)
|
||||||
|
{
|
||||||
|
if (this->action_type == action_type &&
|
||||||
|
this->action_item_id == item_id &&
|
||||||
|
this->action_target_id == target_id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
action_duration = std::max(0, action_duration);
|
||||||
|
this->action_type = action_type;
|
||||||
|
this->action_frameno = room->GetFrameNo();
|
||||||
|
this->action_duration = action_duration;
|
||||||
|
this->action_item_id = item_id;
|
||||||
|
this->action_target_id = target_id;
|
||||||
|
need_sync_active_player = true;
|
||||||
|
if (HasBuffEffect(kBET_Camouflage)) {
|
||||||
|
RemoveBuffByEffectId(kBET_Camouflage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Creature::CancelAction()
|
||||||
|
{
|
||||||
|
if (action_type == AT_Relive) {
|
||||||
|
Entity* entity = room->GetEntityByUniId(action_target_id);
|
||||||
|
if (!entity->IsEntityType(ET_Player)) {
|
||||||
|
Human* hum = (Human*)entity;
|
||||||
|
if (hum->action_type == AT_Rescue) {
|
||||||
|
hum->CancelAction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ResetAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Creature::ResetAction()
|
||||||
|
{
|
||||||
|
action_type = AT_None;
|
||||||
|
action_duration = 0;
|
||||||
|
action_frameno = 0;
|
||||||
|
action_item_id = 0;
|
||||||
|
action_target_id = 0;
|
||||||
|
need_sync_active_player = true;
|
||||||
|
}
|
||||||
|
@ -21,7 +21,6 @@ class Creature : public MoveableEntity
|
|||||||
bool dead = false;
|
bool dead = false;
|
||||||
int team_id = 0;
|
int team_id = 0;
|
||||||
bool aiming = false;
|
bool aiming = false;
|
||||||
ActionType_e action_type = AT_None;
|
|
||||||
a8::Vec2 attack_dir;
|
a8::Vec2 attack_dir;
|
||||||
HumanAbility ability;
|
HumanAbility ability;
|
||||||
a8::Vec2 target_pos;
|
a8::Vec2 target_pos;
|
||||||
@ -30,6 +29,8 @@ class Creature : public MoveableEntity
|
|||||||
Weapon* curr_weapon = nullptr;
|
Weapon* curr_weapon = nullptr;
|
||||||
Weapon car_weapon;
|
Weapon car_weapon;
|
||||||
|
|
||||||
|
bool need_sync_active_player = false;
|
||||||
|
|
||||||
virtual ~Creature() override;
|
virtual ~Creature() override;
|
||||||
virtual void Initialize() override;
|
virtual void Initialize() override;
|
||||||
bool HasBuffEffect(int buff_effect_id);
|
bool HasBuffEffect(int buff_effect_id);
|
||||||
@ -66,8 +67,6 @@ class Creature : public MoveableEntity
|
|||||||
MetaData::SkillPhase* GetCurrSkillPhase();
|
MetaData::SkillPhase* GetCurrSkillPhase();
|
||||||
bool CanSee(const Creature* c) const;
|
bool CanSee(const Creature* c) const;
|
||||||
|
|
||||||
virtual void CancelAction() {};
|
|
||||||
virtual void ResetAction() {};
|
|
||||||
virtual std::string GetName() { return "";};
|
virtual std::string GetName() { return "";};
|
||||||
virtual void SendDebugMsg(const std::string& debug_msg);
|
virtual void SendDebugMsg(const std::string& debug_msg);
|
||||||
virtual void DropItems(Obstacle* obstacle) {};
|
virtual void DropItems(Obstacle* obstacle) {};
|
||||||
@ -80,6 +79,15 @@ class Creature : public MoveableEntity
|
|||||||
float GetAttrAbs(int attr_id);
|
float GetAttrAbs(int attr_id);
|
||||||
float GetAttrRate(int attr_id);
|
float GetAttrRate(int attr_id);
|
||||||
|
|
||||||
|
void StartAction(ActionType_e action_type,
|
||||||
|
int action_duration,
|
||||||
|
int item_id,
|
||||||
|
int target_id);
|
||||||
|
void CancelAction();
|
||||||
|
void ResetAction();
|
||||||
|
int GetActionType() { return action_type; }
|
||||||
|
int GetActionTargetId() { return action_target_id; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
virtual void AddBuffPostProc(Creature* caster, Buff* buff);
|
virtual void AddBuffPostProc(Creature* caster, Buff* buff);
|
||||||
@ -99,6 +107,12 @@ private:
|
|||||||
protected:
|
protected:
|
||||||
RaceType_e race_ = kHumanRace;
|
RaceType_e race_ = kHumanRace;
|
||||||
|
|
||||||
|
ActionType_e action_type = AT_None;
|
||||||
|
int action_duration = 0;
|
||||||
|
long long action_frameno = 0;
|
||||||
|
int action_item_id = 0;
|
||||||
|
int action_target_id = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::array<float, kHAT_End> buff_attr_abs_ = {};
|
std::array<float, kHAT_End> buff_attr_abs_ = {};
|
||||||
std::array<float, kHAT_End> buff_attr_rate_ = {};
|
std::array<float, kHAT_End> buff_attr_rate_ = {};
|
||||||
|
@ -793,52 +793,6 @@ void Human::AutoLoadingBullet(bool manual)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::StartAction(ActionType_e action_type,
|
|
||||||
int action_duration,
|
|
||||||
int item_id,
|
|
||||||
int target_id)
|
|
||||||
{
|
|
||||||
if (this->action_type == action_type &&
|
|
||||||
this->action_item_id == item_id &&
|
|
||||||
this->action_target_id == target_id) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
action_duration = std::max(0, action_duration);
|
|
||||||
this->action_type = action_type;
|
|
||||||
this->action_frameno = room->GetFrameNo();
|
|
||||||
this->action_duration = action_duration;
|
|
||||||
this->action_item_id = item_id;
|
|
||||||
this->action_target_id = target_id;
|
|
||||||
need_sync_active_player = true;
|
|
||||||
if (HasBuffEffect(kBET_Camouflage)) {
|
|
||||||
RemoveBuffByEffectId(kBET_Camouflage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Human::CancelAction()
|
|
||||||
{
|
|
||||||
if (action_type == AT_Relive) {
|
|
||||||
Entity* entity = room->GetEntityByUniId(action_target_id);
|
|
||||||
if (!entity->IsEntityType(ET_Player)) {
|
|
||||||
Human* hum = (Human*)entity;
|
|
||||||
if (hum->action_type == AT_Rescue) {
|
|
||||||
hum->CancelAction();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ResetAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Human::ResetAction()
|
|
||||||
{
|
|
||||||
action_type = AT_None;
|
|
||||||
action_duration = 0;
|
|
||||||
action_frameno = 0;
|
|
||||||
action_item_id = 0;
|
|
||||||
action_target_id = 0;
|
|
||||||
need_sync_active_player = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Human::FillSMGameOver(cs::SMGameOver& msg)
|
void Human::FillSMGameOver(cs::SMGameOver& msg)
|
||||||
{
|
{
|
||||||
if (stats.rank <= 0) {
|
if (stats.rank <= 0) {
|
||||||
|
@ -69,10 +69,6 @@ class Human : public Creature
|
|||||||
bool disconnected = false;
|
bool disconnected = false;
|
||||||
int anim_type = 0;
|
int anim_type = 0;
|
||||||
int anim_seq = 0;
|
int anim_seq = 0;
|
||||||
long long action_frameno = 0;
|
|
||||||
int action_duration = 0;
|
|
||||||
int action_item_id = 0;
|
|
||||||
int action_target_id = 0;
|
|
||||||
Skin skin_jlf;
|
Skin skin_jlf;
|
||||||
int backpack = 0;
|
int backpack = 0;
|
||||||
int helmet = 0;
|
int helmet = 0;
|
||||||
@ -105,7 +101,6 @@ class Human : public Creature
|
|||||||
|
|
||||||
bool need_sync_team_data = false;
|
bool need_sync_team_data = false;
|
||||||
bool need_sync_teammate_data = false;
|
bool need_sync_teammate_data = false;
|
||||||
bool need_sync_active_player = false;
|
|
||||||
|
|
||||||
PlayerStats stats;
|
PlayerStats stats;
|
||||||
|
|
||||||
@ -167,12 +162,6 @@ class Human : public Creature
|
|||||||
float GetMaxHP();
|
float GetMaxHP();
|
||||||
void UpdatePoisoning();
|
void UpdatePoisoning();
|
||||||
void AutoLoadingBullet(bool manual = false);
|
void AutoLoadingBullet(bool manual = false);
|
||||||
void StartAction(ActionType_e action_type,
|
|
||||||
int action_duration,
|
|
||||||
int item_id,
|
|
||||||
int target_id);
|
|
||||||
virtual void CancelAction() override;
|
|
||||||
virtual void ResetAction() override;
|
|
||||||
void BeKill(int killer_id, const std::string& killer_name, int weapon_id);
|
void BeKill(int killer_id, const std::string& killer_name, int weapon_id);
|
||||||
virtual void DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id) override;
|
virtual void DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id) override;
|
||||||
void AddToNewObjects(Entity* entity);
|
void AddToNewObjects(Entity* entity);
|
||||||
|
@ -777,7 +777,7 @@ void Player::HumanInteraction(Human* hum)
|
|||||||
if (!hum->downed) {
|
if (!hum->downed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (hum->action_type == AT_Rescue) {
|
if (hum->GetActionType() == AT_Rescue) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
hum->StartAction(
|
hum->StartAction(
|
||||||
|
@ -3464,8 +3464,8 @@ void Room::FillObjectPositions(Human* hum, cs::SMUpdate& msg)
|
|||||||
void Room::RemoveRescue(Human* hum)
|
void Room::RemoveRescue(Human* hum)
|
||||||
{
|
{
|
||||||
for (auto& pair : human_hash_) {
|
for (auto& pair : human_hash_) {
|
||||||
if (pair.second != hum && pair.second->action_type == AT_Relive &&
|
if (pair.second != hum && pair.second->GetActionType() == AT_Relive &&
|
||||||
pair.second->action_target_id == hum->GetEntityUniId()) {
|
pair.second->GetActionTargetId() == hum->GetEntityUniId()) {
|
||||||
pair.second->CancelAction();
|
pair.second->CancelAction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user