void UAISense_Sight::GenerateQueriesForListener(const FPerceptionListener& Listener, const FDigestedSightProperties& PropertyDigest) { bool bNewQueriesAdded = false; const IGenericTeamAgentInterface* ListenersTeamAgent = Listener.GetTeamAgent(); // create sight queries with all legal targets for (TMap<FName, FAISightTarget>::TConstIterator ItTarget(ObservedTargets); ItTarget; ++ItTarget) { const AActor* TargetActor = ItTarget->Value.GetTargetActor(); if (TargetActor == NULL) { continue; } // @todo this should be configurable - some AI might want to observe Neutrals and Friendlies as well if (ListenersTeamAgent == NULL || ListenersTeamAgent->GetTeamAttitudeTowards(*TargetActor) == ETeamAttitude::Hostile) { // create a sight query FAISightQuery SightQuery(Listener.GetListenerID(), ItTarget->Key); SightQuery.Importance = CalcQueryImportance(Listener, ItTarget->Value.GetLocationSimple(), PropertyDigest.SightRadiusSq); SightQueryQueue.Add(SightQuery); bNewQueriesAdded = true; } } // sort Sight Queries if (bNewQueriesAdded) { SortQueries(); RequestImmediateUpdate(); } }
void UAISense_Sight::GenerateQueriesForListener(const FPerceptionListener& Listener, const FDigestedSightProperties& PropertyDigest) { bool bNewQueriesAdded = false; const IGenericTeamAgentInterface* ListenersTeamAgent = Listener.GetTeamAgent(); const AActor* Avatar = Listener.GetBodyActor(); // create sight queries with all legal targets for (TMap<FName, FAISightTarget>::TConstIterator ItTarget(ObservedTargets); ItTarget; ++ItTarget) { const AActor* TargetActor = ItTarget->Value.GetTargetActor(); if (TargetActor == NULL || TargetActor == Avatar) { continue; } if (FAISenseAffiliationFilter::ShouldSenseTeam(ListenersTeamAgent, *TargetActor, PropertyDigest.AffiliationFlags)) { // create a sight query FAISightQuery SightQuery(Listener.GetListenerID(), ItTarget->Key); SightQuery.Importance = CalcQueryImportance(Listener, ItTarget->Value.GetLocationSimple(), PropertyDigest.SightRadiusSq); SightQueryQueue.Add(SightQuery); bNewQueriesAdded = true; } } // sort Sight Queries if (bNewQueriesAdded) { SortQueries(); RequestImmediateUpdate(); } }
void UAISense_Blueprint::OnNewListenerImpl(const FPerceptionListener& NewListener) { UAIPerceptionComponent* PercComp = NewListener.Listener.Get(); if (PercComp) { ListenerContainer.AddUnique(PercComp); OnListenerRegistered(PercComp->GetOwner(), PercComp); RequestImmediateUpdate(); } }
bool UAISense_Sight::RegisterTarget(AActor& TargetActor, FQueriesOperationPostProcess PostProcess) { SCOPE_CYCLE_COUNTER(STAT_AI_Sense_Sight); FAISightTarget* SightTarget = ObservedTargets.Find(TargetActor.GetFName()); if (SightTarget == NULL) { FAISightTarget NewSightTarget(&TargetActor); SightTarget = &(ObservedTargets.Add(NewSightTarget.TargetId, NewSightTarget)); SightTarget->SightTargetInterface = Cast<IAISightTargetInterface>(&TargetActor); } // set/update data SightTarget->TeamId = FGenericTeamId::GetTeamIdentifier(&TargetActor); // generate all pairs and add them to current Sight Queries bool bNewQueriesAdded = false; AIPerception::FListenerMap& ListenersMap = *GetListeners(); const FVector TargetLocation = TargetActor.GetActorLocation(); for (AIPerception::FListenerMap::TConstIterator ItListener(ListenersMap); ItListener; ++ItListener) { const FPerceptionListener& Listener = ItListener->Value; const IGenericTeamAgentInterface* ListenersTeamAgent = Listener.GetTeamAgent(); if (Listener.HasSense(GetSenseID()) && Listener.GetBodyActor() != &TargetActor) { const FDigestedSightProperties& PropDigest = DigestedProperties[Listener.GetListenerID()]; if (FAISenseAffiliationFilter::ShouldSenseTeam(ListenersTeamAgent, TargetActor, PropDigest.AffiliationFlags)) { // create a sight query FAISightQuery SightQuery(ItListener->Key, SightTarget->TargetId); SightQuery.Importance = CalcQueryImportance(ItListener->Value, TargetLocation, PropDigest.SightRadiusSq); SightQueryQueue.Add(SightQuery); bNewQueriesAdded = true; } } } // sort Sight Queries if (PostProcess == Sort && bNewQueriesAdded) { SortQueries(); RequestImmediateUpdate(); } return bNewQueriesAdded; }
void UAISense_Aquaphobia::OnNewListenerImpl(const FPerceptionListener& NewListener) { //Since we have at least one AI actor with this sense this function will fire when the game starts GLog->Log("hello new listener!"); check(NewListener.Listener.IsValid()); //Get the config UAISenseConfig* Config = NewListener.Listener->GetSenseConfig(GetSenseID()); const UAISenseConfig_Aquaphobia* SenseConfig = Cast<const UAISenseConfig_Aquaphobia>(Config); check(SenseConfig); //Consume properties from the sense config FDigestedAquaProperties PropertyDigest(*SenseConfig); DigestedProperties.Add(PropertyDigest); RequestImmediateUpdate(); }
void UAISense_Team::RegisterEvent(const FAITeamStimulusEvent& Event) { RegisteredEvents.Add(Event); RequestImmediateUpdate(); }
void UAISense_Touch::RegisterEvent(const FAITouchEvent& Event) { RegisteredEvents.Add(Event); RequestImmediateUpdate(); }
void UAISense_Blueprint::RegisterWrappedEvent(UAISenseEvent& PerceptionEvent) { UnprocessedEvents.Add(&PerceptionEvent); RequestImmediateUpdate(); }
void UAISense_Prediction::RegisterEvent(const FAIPredictionEvent& Event) { RegisteredEvents.Add(Event); RequestImmediateUpdate(); }
void UAISense_Damage::RegisterEvent(const FAIDamageEvent& Event) { RegisteredEvents.Add(Event); RequestImmediateUpdate(); }