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