void UGISInventoryBaseComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); if (CurrentPickupActor) { float distance = FVector::Dist(CurrentPickupActor->GetActorLocation(), GetOwner()->GetActorLocation()); if (distance > MaxLootingDistance) { ClientHideLootingWidget(); SetComponentTickEnabled(false); } } }
void UGameplayDebuggingControllerComponent::CloseDebugTool() { #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) if (GetDebuggingReplicator()) { Deactivate(); SetComponentTickEnabled(false); GetDebuggingReplicator()->ServerReplicateMessage(nullptr, EDebugComponentMessage::DeactivateReplilcation, EAIDebugDrawDataView::Empty); GetDebuggingReplicator()->EnableDraw(false); GetDebuggingReplicator()->ServerReplicateMessage(nullptr, EDebugComponentMessage::DeactivateReplilcation, EAIDebugDrawDataView::Empty); bToolActivated = false; } #endif //!(UE_BUILD_SHIPPING || UE_BUILD_TEST) }
void UFMODAudioComponent::Play() { Stop(); if (!FMODUtils::IsWorldAudible(GetWorld())) { return; } UE_LOG(LogFMOD, Verbose, TEXT("UFMODAudioComponent %p Play"), this); // Only play events in PIE/game, not when placing them in the editor FMOD::Studio::EventDescription* EventDesc = IFMODStudioModule::Get().GetEventDescription(Event.Get()); if (EventDesc != nullptr) { FMOD_RESULT result = EventDesc->createInstance(&StudioInstance); if (StudioInstance != nullptr) { FMOD_STUDIO_USER_PROPERTY UserProp = {0}; if (EventDesc->getUserProperty("Ambient", &UserProp) == FMOD_OK) { if (UserProp.type == FMOD_STUDIO_USER_PROPERTY_TYPE_FLOAT) // All numbers are stored as float { bApplyAmbientVolumes = (UserProp.floatValue != 0.0f); } } OnUpdateTransform(true); // Set initial parameters for (auto Kvp : StoredParameters) { FMOD_RESULT Result = StudioInstance->setParameterValue(TCHAR_TO_UTF8(*Kvp.Key.ToString()), Kvp.Value); if (Result != FMOD_OK) { UE_LOG(LogFMOD, Warning, TEXT("Failed to set initial parameter %s"), *Kvp.Key.ToString()); } } if (bEnableTimelineCallbacks) { verifyfmod(StudioInstance->setUserData(this)); verifyfmod(StudioInstance->setCallback(UFMODAudioComponent_EventCallback)); } verifyfmod(StudioInstance->start()); UE_LOG(LogFMOD, Verbose, TEXT("Playing component %p"), this); bIsActive = true; SetComponentTickEnabled(true); } } }
void UGameplayDebuggingControllerComponent::OnActivationKeyPressed() { if (GetDebuggingReplicator() && PlayerOwner.IsValid()) { if (!bToolActivated) { Activate(); SetComponentTickEnabled(true); BindAIDebugViewKeys(); GetDebuggingReplicator()->EnableDraw(true); GetDebuggingReplicator()->ServerReplicateMessage(NULL, EDebugComponentMessage::ActivateReplication, EAIDebugDrawDataView::Empty); } ControlKeyPressedTime = GetWorld()->GetTimeSeconds(); EnableTargetSelection(true); } }
void UGISInventoryBaseComponent::GetLootContainer(class AGISPickupActor* LootContainer) { if (GetOwnerRole() < ROLE_Authority) { ServerGetLootContainer(LootContainer); } else { if (!LootContainer->bIsCurrentlyBeingLooted) { CurrentPickupActor = LootContainer; LootContainer->bIsCurrentlyBeingLooted = true; for (UGISItemData* Item : LootContainer->ItemToLoot) { UGISItemData* test = ConstructObject<UGISItemData>(Item->GetClass(), this, NAME_None, RF_NoFlags, Item); LootedItems.Add(test); } SetComponentTickEnabled(true); //ClientConstructWidget(); } } }
void UFMODAudioComponent::OnPlaybackCompleted() { // Mark inactive before calling destroy to avoid recursion UE_LOG(LogFMOD, Verbose, TEXT("UFMODAudioComponent %p PlaybackCompleted"), this); bIsActive = false; SetComponentTickEnabled(false); OnEventStopped.Broadcast(); if (StudioInstance) { StudioInstance->setCallback(nullptr); StudioInstance->release(); StudioInstance = nullptr; } // Auto destruction is handled via marking object for deletion. if (bAutoDestroy) { DestroyComponent(); } }
void UGISInventoryBaseComponent::StartLooting(class AGISPickupActor* PickUp) { //should work differently. //1. Passs Array of actors. //2. Discard all actors wihtout loot (if they are in array). //3. Iterate over all actors and find closest to character. //4. Start interacting with closer one, and discard rest. SetComponentTickEnabled(true); ClientSwitchLootingWidget(); int32 ItemNum = PickUp->ItemToLoot.Num(); CurrentPickupActor = PickUp; LootFromPickup.Loot.Empty(); for (int32 ItemIndex = 0; ItemIndex < ItemNum; ItemIndex++) { FGISLootSlotInfo lootInfo; UGISItemData* dataDuplicate = ConstructObject<UGISItemData>(CurrentPickupActor->ItemToLoot[ItemIndex]->GetClass(), this, NAME_None, RF_NoFlags, CurrentPickupActor->ItemToLoot[ItemIndex]); lootInfo.OwningPickupActor = PickUp; lootInfo.SlotComponent = this; lootInfo.SlotIndex = ItemIndex; lootInfo.SlotData = dataDuplicate; LootFromPickup.Loot.Add(lootInfo); LootFromPickup.ForceRep++; } }
void UActorComponent::OnRep_IsActive() { SetComponentTickEnabled(bIsActive); }
void UPawnActionsComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); if (ControlledPawn == NULL) { CacheControlledPawn(); } if (ActionEvents.Num() > 1) { ActionEvents.Sort(FPawnActionEvenSort()); } if (ActionEvents.Num() > 0) { for (int32 EventIndex = 0; EventIndex < ActionEvents.Num(); ++EventIndex) { FPawnActionEvent& Event = ActionEvents[EventIndex]; if (Event.Action == nullptr) { UE_VLOG(ControlledPawn, LogPawnAction, Warning, TEXT("NULL action encountered during ActionEvents processing. May result in some notifies not being sent out.")); continue; } switch (Event.EventType) { case EPawnActionEventType::InstantAbort: // can result in adding new ActionEvents (from child actions) and reallocating data in ActionEvents array // because of it, we need to operate on copy instead of reference to memory address { FPawnActionEvent EventCopy(Event); EventCopy.Action->Abort(EAIForceParam::Force); ActionStacks[EventCopy.Priority].PopAction(*EventCopy.Action); } break; case EPawnActionEventType::FinishedAborting: case EPawnActionEventType::FinishedExecution: case EPawnActionEventType::FailedToStart: ActionStacks[Event.Priority].PopAction(*Event.Action); break; case EPawnActionEventType::Push: ActionStacks[Event.Priority].PushAction(*Event.Action); break; default: break; } } ActionEvents.Reset(); UpdateCurrentAction(); } if (CurrentAction) { CurrentAction->TickAction(DeltaTime); } // it's possible we got new events with CurrentAction's tick if (ActionEvents.Num() == 0 && (CurrentAction == NULL || CurrentAction->WantsTick() == false)) { SetComponentTickEnabled(false); } }