mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2025-12-23 04:10:06 +00:00
Refactor and generalize NPCEvent logic
This commit is contained in:
@@ -316,12 +316,10 @@ void CombatNPC::transition(AIState newState, EntityRef src) {
|
||||
transition(AIState::INACTIVE, id);
|
||||
}
|
||||
|
||||
// TODO: Properly refactor this
|
||||
if (newState == AIState::DEAD && src.kind == EntityKind::PLAYER) {
|
||||
for (NPCEvent& event : NPCManager::NPCEvents)
|
||||
if (event.trigger == ON_KILLED && event.npcType == type)
|
||||
event.handler(src.sock, this);
|
||||
}
|
||||
// trigger special NPCEvents, if applicable
|
||||
for (NPCEvent& event : NPCManager::NPCEvents)
|
||||
if (event.triggerState == newState && event.npcType == type)
|
||||
event.handler(this);
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user