1
This commit is contained in:
parent
b4204e577e
commit
97e48f3410
@ -3793,3 +3793,8 @@ void Creature::CheckShotHold()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Creature::LateUpdate(int delta_time)
|
||||
{
|
||||
trigger_->Update();
|
||||
}
|
||||
|
@ -160,6 +160,7 @@ class Creature : public MoveableEntity
|
||||
virtual void FillMFObjectImage(Room* room, Human* hum, cs::MFCharacterImage* image_data) {};
|
||||
virtual void SetPos(Position pos) override;
|
||||
virtual float GetSpeed();
|
||||
virtual void LateUpdate(int delta_time) override;
|
||||
std::shared_ptr<Movement> GetMovement() { return movement_; };
|
||||
bool HasBuffEffect(int buff_effect_id);
|
||||
Buff* GetBuffByEffectId(int effect_id);
|
||||
|
@ -9,6 +9,7 @@ class MoveableEntity : public RoomEntity
|
||||
MoveableEntity();
|
||||
|
||||
virtual void Update(int delta_time) {};
|
||||
virtual void LateUpdate(int delta_time) {};
|
||||
int UpdatedTimes() { return updated_times_;}
|
||||
std::set<GridCell*>& GetGridList() { return grid_list_; }
|
||||
|
||||
|
@ -215,6 +215,7 @@ void Room::Update(int delta_time)
|
||||
#endif
|
||||
for (auto& pair : moveable_hash_) {
|
||||
pair.second->Update(50);
|
||||
pair.second->LateUpdate(50);
|
||||
}
|
||||
for (auto& pair : task_hash_) {
|
||||
(*pair.second)(nullptr);
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
|
||||
void Trigger::Init()
|
||||
{
|
||||
|
||||
INIT_LIST_HEAD(&delay_del_handles);
|
||||
}
|
||||
|
||||
void Trigger::UnInit()
|
||||
@ -59,6 +59,7 @@ void Trigger::UnInit()
|
||||
e->holder = nullptr;
|
||||
}
|
||||
}
|
||||
ClearDelayDelHandlers();
|
||||
}
|
||||
|
||||
void Trigger::TakeonWeapon(Weapon* old_weapon, Weapon* new_weapon)
|
||||
@ -492,9 +493,7 @@ void Trigger::RemoveEventHandler(std::weak_ptr<EventHandler> handler)
|
||||
auto p = handler.lock();
|
||||
p->cb = nullptr;
|
||||
list_del_init(&p->entry);
|
||||
#if 0
|
||||
owner_->room->AddFrameCall(DeleteEventHandler, e);
|
||||
#endif
|
||||
list_add_tail(&p->entry, &delay_del_handles);
|
||||
}
|
||||
}
|
||||
|
||||
@ -638,3 +637,24 @@ void Trigger::EnterCrazeMode()
|
||||
DispatchEvent(kCrazeModeEvent, {});
|
||||
}
|
||||
}
|
||||
|
||||
void Trigger::Update()
|
||||
{
|
||||
ClearDelayDelHandlers();
|
||||
}
|
||||
|
||||
void Trigger::ClearDelayDelHandlers()
|
||||
{
|
||||
while (!list_empty(&delay_del_handles)) {
|
||||
EventHandler* e = list_first_entry(&delay_del_handles,
|
||||
EventHandler,
|
||||
entry);
|
||||
list_del_init(&e->entry);
|
||||
#ifdef MYDEBUG
|
||||
if (e->holder.use_count() > 1) {
|
||||
A8_ABORT();
|
||||
}
|
||||
#endif
|
||||
e->holder = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
Trigger(Creature* owner) { owner_ = owner; };
|
||||
void Init();
|
||||
void UnInit();
|
||||
void Update();
|
||||
Creature* GetOwner() { return owner_; };
|
||||
void TakeonWeapon(Weapon* old_weapon, Weapon* new_weapon);
|
||||
void Shot(const mt::Equip* weapon_meta);
|
||||
@ -101,10 +102,12 @@ public:
|
||||
void AddBuffs(Buff* buff, int cond, const std::vector<int>& buffids,
|
||||
std::shared_ptr<std::vector<float>> buff_vars = nullptr);
|
||||
void RemoveBuffs(int cond, const std::vector<int>& buffids);
|
||||
void ClearDelayDelHandlers();
|
||||
|
||||
|
||||
private:
|
||||
Creature* owner_ = nullptr;
|
||||
int kill_num_ = 0;
|
||||
std::map<int, list_head> listeners_hash_;
|
||||
list_head delay_del_handles;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user