Resolve many issues with invisible enemies and End Behavior nodes not firing (#1044)

* Finall fix invisible enemies

* Add garbage collection

* Add comment

* Add constexpr for lagFrames
This commit is contained in:
David Markowitz
2023-04-05 06:57:47 -07:00
committed by GitHub
parent 3202b5a36e
commit 541250176c
10 changed files with 51 additions and 24 deletions

View File

@@ -134,6 +134,10 @@ void SkillComponent::Update(const float deltaTime) {
CalculateUpdate(deltaTime);
}
if (m_Parent->IsPlayer()) {
for (const auto& pair : this->m_managedBehaviors) pair.second->UpdatePlayerSyncs(deltaTime);
}
std::map<uint32_t, BehaviorContext*> keep{};
for (const auto& pair : this->m_managedBehaviors) {
@@ -192,7 +196,15 @@ void SkillComponent::Interrupt() {
auto* combat = m_Parent->GetComponent<BaseCombatAIComponent>();
if (combat != nullptr && combat->GetStunImmune()) return;
for (const auto& behavior : this->m_managedBehaviors) behavior.second->Interrupt();
for (const auto& behavior : this->m_managedBehaviors) {
for (const auto& behaviorEndEntry : behavior.second->endEntries) {
behaviorEndEntry.behavior->End(behavior.second, behaviorEndEntry.branchContext, behaviorEndEntry.second);
}
behavior.second->endEntries.clear();
if (m_Parent->IsPlayer()) continue;
behavior.second->Interrupt();
}
}
void SkillComponent::RegisterCalculatedProjectile(const LWOOBJID projectileId, BehaviorContext* context, const BehaviorBranchContext& branch, const LOT lot, const float maxTime,
@@ -215,7 +227,7 @@ void SkillComponent::RegisterCalculatedProjectile(const LWOOBJID projectileId, B
this->m_managedProjectiles.push_back(entry);
}
bool SkillComponent::CastSkill(const uint32_t skillId, LWOOBJID target, const LWOOBJID optionalOriginatorID){
bool SkillComponent::CastSkill(const uint32_t skillId, LWOOBJID target, const LWOOBJID optionalOriginatorID) {
uint32_t behaviorId = -1;
// try to find it via the cache
const auto& pair = m_skillBehaviorCache.find(skillId);
@@ -463,7 +475,7 @@ void SkillComponent::HandleUnCast(const uint32_t behaviorId, const LWOOBJID targ
delete context;
}
SkillComponent::SkillComponent(Entity* parent) : Component(parent) {
SkillComponent::SkillComponent(Entity* parent): Component(parent) {
this->m_skillUid = 0;
}