void UAISense_Sight::OnListenerRemovedImpl(const FPerceptionListener& UpdatedListener) { RemoveAllQueriesByListener(UpdatedListener, DontSort); DigestedProperties.FindAndRemoveChecked(UpdatedListener.GetListenerID()); if (UpdatedListener.Listener.IsValid()) { // see if this listener is a Target as well const FAISightTarget::FTargetId AsTargetId = UpdatedListener.GetBodyActorName(); FAISightTarget* AsTarget = ObservedTargets.Find(AsTargetId); if (AsTarget != NULL) { RemoveAllQueriesToTarget(AsTargetId, Sort); } } else { //@todo quite possible there are left over sight queries with this listener as target } }
void UAISense_Sight::OnListenerUpdateImpl(const FPerceptionListener& UpdatedListener) { SCOPE_CYCLE_COUNTER(STAT_AI_Sense_Sight_ListenerUpdate); // first, naive implementation: // 1. remove all queries by this listener // 2. proceed as if it was a new listener // remove all queries RemoveAllQueriesByListener(UpdatedListener, DontSort); // see if this listener is a Target as well const FAISightTarget::FTargetId AsTargetId = UpdatedListener.GetBodyActorName(); FAISightTarget* AsTarget = ObservedTargets.Find(AsTargetId); if (AsTarget != NULL) { RemoveAllQueriesToTarget(AsTargetId, DontSort); if (AsTarget->Target.IsValid()) { RegisterTarget(*(AsTarget->Target.Get()), DontSort); } } const FPerceptionListenerID ListenerID = UpdatedListener.GetListenerID(); if (UpdatedListener.HasSense(GetSenseID())) { const UAISenseConfig_Sight* SenseConfig = Cast<const UAISenseConfig_Sight>(UpdatedListener.Listener->GetSenseConfig(GetSenseID())); check(SenseConfig); FDigestedSightProperties& PropertiesDigest = DigestedProperties.FindOrAdd(ListenerID); PropertiesDigest = FDigestedSightProperties(*SenseConfig); GenerateQueriesForListener(UpdatedListener, PropertiesDigest); } else { DigestedProperties.FindAndRemoveChecked(ListenerID); } }