Esempio n. 1
0
// Start the block restore event (Called by weapon)
void ALevelBlock::StartTimedRestore(AWeapon* newParentWeapon, float Time)
{
	if (newParentWeapon)
	{
		ParentWeapon = newParentWeapon;
		if (Time>0)
		{
			FTimerHandle MyHandle;
			GetWorldTimerManager().SetTimer(MyHandle, this, &ALevelBlock::ReturnBlock, Time, false);
		}
	}
}
Esempio n. 2
0
void ABatteryPickup::WasCollected_Implementation()
{
	Super::WasCollected_Implementation();
	
	ParticleSystem = UGameplayStatics::SpawnEmitterAttached(ParticleSystemTemplate, GetMesh(), NAME_None);
	UpdateBeamTargetPoint();

	FTimerHandle UnusedHandle;
	GetWorldTimerManager().SetTimer(
		UnusedHandle, this, &ABatteryPickup::DestroyAfterDelay, 1, false);

}
void ASWeapon::OnBurstFinished()
{
	BurstCounter = 0;

	if (GetNetMode() != NM_DedicatedServer)
	{
		StopSimulatingWeaponFire();
	}

	GetWorldTimerManager().ClearTimer(TimerHandle_HandleFiring);
	bRefiring = false;
}
Esempio n. 4
0
void ACountdown::AdvanceTimer()
{
	--CountdownTime;
	UpdateTimerDisplay();
	if (CountdownTime < 1)
	{
		// We're done counting down, so stop running the timer.
		GetWorldTimerManager().ClearTimer(CountdownTimerHandle);
		// Perform any special actions we want to do when the timer ends.
		CountdownHasFinished();
	}
}
void ARealmMoveController::GameEnded()
{
	StopMovement();
	GetWorldTimerManager().ClearAllTimersForObject(this);

	AGameCharacter* gc = Cast<AGameCharacter>(GetCharacter());
	if (IsValid(gc))
	{
		gc->StopAutoAttack();
		gc->GetCharacterMovement()->SetMovementMode(MOVE_None);
	}
}
Esempio n. 6
0
void ALobbyBeaconState::PostInitializeComponents()
{
	Super::PostInitializeComponents();

	if (Role == ROLE_Authority)
	{
		FTimerDelegate TimerDelegate = FTimerDelegate::CreateUObject(this, &ALobbyBeaconState::OneSecTick);
		GetWorldTimerManager().SetTimer(OneSecTimerHandle, TimerDelegate, 1.0f, true);

		LastTickTime = FPlatformTime::Seconds();
	}
}
Esempio n. 7
0
void ABomb::OnProjectileBounce(const FHitResult& ImpactResult, const FVector& ImpactVelocity)
{
	if (Role == ROLE_Authority)
	{
		Armed = true;

		// You must call the rep function yourself for the server or it will never change color.
		OnRep_Armed();

		GetWorldTimerManager().SetTimer(BombTimerHandle, this, &ABomb::OnFuseExpired,FuseTime, false);
	}
}
Esempio n. 8
0
void ALevelBounds::SubscribeToUpdateEvents()
{
	if (bSubscribedToEvents == false && GIsEditor && !GetWorld()->IsPlayInEditor())
	{
		GetWorldTimerManager().SetTimer(this, &ALevelBounds::OnTimerTick, 1, true);
		GEngine->OnActorMoved().AddUObject(this, &ALevelBounds::OnLevelActorMoved);
		GEngine->OnLevelActorDeleted().AddUObject(this, &ALevelBounds::OnLevelActorAddedRemoved);
		GEngine->OnLevelActorAdded().AddUObject(this, &ALevelBounds::OnLevelActorAddedRemoved);
		
		bSubscribedToEvents = true;
	}
}
Esempio n. 9
0
void ARageHUD::PostBeginPlay()
{
	if (GetOwningPawn() && Cast<ARagePlayerCar>(GetOwningPawn()))
	{
		Cast<ARagePlayerCar>(GetOwningPawn())->TheHUD = this;
	}
	else 
	{
		FTimerHandle MyHandle;
		GetWorldTimerManager().SetTimer(MyHandle, this, &ARageHUD::PostBeginPlay, PostDelay, false);
	}
}
void AManaJourneyCharacter::useShell()
{
	if (characterClasses.Contains("whiteMageClass") && whiteMageClassRef && !castOngoing)
	{
		toggleCastOngoing();
		bool bCastedShell = false;
		bCastedShell = whiteMageClassRef->castShell(*this, GetMesh());
		if (bCastedShell)
		{
			toggleCharacterMovement();
			updatePhysicProtection();
			castShellAnimation(level);
			toggleCastOngoing();

			//NOTE remove shell effect after fadeTimeForEffect has set to false (so add slight delay for beeing sure) 
			FTimerHandle UpdatePhysicProtectionTimer;
			GetWorldTimerManager().ClearTimer(UpdatePhysicProtectionTimer);
			FTimerDelegate UpdatePhysicProtectionTimerDelegate = FTimerDelegate::CreateUObject(this, &AManaJourneyCharacter::updatePhysicProtection);
			GetWorldTimerManager().SetTimer(UpdatePhysicProtectionTimer, UpdatePhysicProtectionTimerDelegate, fadeTimeForEffect + 0.2f, false);

			FTimerHandle EnableMovementTimer;
			GetWorldTimerManager().ClearTimer(EnableMovementTimer);
			FTimerDelegate updateCharacterMovementDelegate = FTimerDelegate::CreateUObject(this, &AManaJourneyCharacter::toggleCharacterMovement);
			GetWorldTimerManager().SetTimer(EnableMovementTimer, updateCharacterMovementDelegate, 1.50f, false);

			// timer for setting cast to false
			FTimerHandle CastOngoingHandler;
			GetWorldTimerManager().ClearTimer(CastOngoingHandler);
			FTimerDelegate CastOngoingHandlerDelegate = FTimerDelegate::CreateUObject(this, &AManaJourneyCharacter::toggleCastOngoing);
			GetWorldTimerManager().SetTimer(CastOngoingHandler, CastOngoingHandlerDelegate, whiteMageClassRef->fShellTimer, false);
		}
	}
}
Esempio n. 11
0
// Called when the game starts or when spawned
void ACountdown::BeginPlay()
{
	Super::BeginPlay();

	UpdateTimerDisplay();
	GetWorldTimerManager().SetTimer(CountdownTimerHandle, this, &ACountdown::AdvanceTimer, 1.0f, true);

	UE_LOG(QuickStart, Log, TEXT("ACountdown::BeginPlay()"));
	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Blue, "ACountdown::BeginPlay()");
	}
}
Esempio n. 12
0
void AGameState::DefaultTimer()
{
	if (IsMatchInProgress())
	{
		++ElapsedTime;
		if (GetNetMode() != NM_DedicatedServer)
		{
			OnRep_ElapsedTime();
		}
	}

	GetWorldTimerManager().SetTimer(TimerHandle_DefaultTimer, this, &AGameState::DefaultTimer, 1.0f / GetWorldSettings()->GetEffectiveTimeDilation(), true);
}
Esempio n. 13
0
void ABaseWeapon::HandleFiring()
{
	const float GameTime = GetWorld()->GetTimeSeconds();

	if (LastFireTime > 0 && WeaponConfig.TimeBetweenShots > 0 && LastFireTime + WeaponConfig.TimeBetweenShots > GameTime)
	{
		GetWorldTimerManager().SetTimer(time_handler, this, &ABaseWeapon::Fire, LastFireTime + WeaponConfig.TimeBetweenShots - GameTime, false);
	}
	else
	{
		Fire();
	}
}
Esempio n. 14
0
void AAWeapon::OnBurstStarted()
{
	// Start firing, can be delayed to satisfy TimeBetweenShots
	const float GameTime = GetWorld()->GetTimeSeconds();
	if (LastFireTime > 0 && TimeBetweenShots > 0.0f && LastFireTime + TimeBetweenShots > GameTime)
	{
		GetWorldTimerManager().SetTimer(TimerHandle_HandleFiring, this, &AAWeapon::HandleFiring, LastFireTime + TimeBetweenShots - GameTime, false);
	}
	else
	{
		HandleFiring();
	}
}
Esempio n. 15
0
void ASWeapon::OnBurstStarted()
{
	const float GameTime = GetWorld()->GetTimeSeconds();
	if ((LastFireTime > 0.0f) && (TimeBetweenShots > 0.0f) &&
		(LastFireTime + TimeBetweenShots > GameTime))
	{
		GetWorldTimerManager().SetTimer(HandleFiringTimerHandle, this, &ASWeapon::HandleFiring, LastFireTime + TimeBetweenShots - GameTime, false);
	}
	else
	{
		HandleFiring();
	}
}
Esempio n. 16
0
void AIceSpell::DealUniqueSpellFunctionality(ABBotCharacter* enemyPlayer)
{
  if (HasAuthority())
  {
	  // Slow the enemy movement speed
	  SlowEnemy(enemyPlayer);
	
	  // Bind enemy player to SlowEnemyEnd delegate
	  slowMovementDelegate.BindUObject(this, &AIceSpell::SlowEnemyEnd, (ABBotCharacter*)enemyPlayer);
	  // Remove the slow effect after the slow duration
	  GetWorldTimerManager().SetTimer(slowMovementHandler, slowMovementDelegate, slowDuration, false);
  }
}
Esempio n. 17
0
// Unequip curent weapon
void ARadeCharacter::UnEquipStart()
{
	// Set Animation State
	ServerSetAnimID(EAnimState::UnEquip);


	if (TheWeapon)
	{
		// Set Delay of current weapon
		FTimerHandle myHandle;
		GetWorldTimerManager().SetTimer(myHandle, this, &ARadeCharacter::UnEquipEnd, TheWeapon->EquipTime, false);
	}
	else 
	{
		// Set Default Delay
		FTimerHandle myHandle;
		GetWorldTimerManager().SetTimer(myHandle, this, &ARadeCharacter::UnEquipEnd, DefaultWeaponEquipDelay, false);
	}

	UpdateComponentsVisibility();

}
Esempio n. 18
0
void ASWeapon::OnUnEquip()
{
	bIsEquipped = false;
	StopFire();

	if (bPendingEquip)
	{
		StopWeaponAnimation(EquipAnim);
		bPendingEquip = false;

		GetWorldTimerManager().ClearTimer(EquipFinishedTimerHandle);
	}
	if (bPendingReload)
	{
		StopWeaponAnimation(ReloadAnim);
		bPendingReload = false;

		GetWorldTimerManager().ClearTimer(TimerHandle_ReloadWeapon);
	}

	DetermineWeaponState();
}
Esempio n. 19
0
void AOnlineBeaconClient::DestroyBeacon()
{
	SetConnectionState(EBeaconConnectionState::Closed);

	UWorld* World = GetWorld();
	if (World)
	{
		// Fail safe for connection to server but no client connection RPC
		GetWorldTimerManager().ClearTimer(TimerHandle_OnFailure);
	}

	Super::DestroyBeacon();
}
void ASCharacter::PostInitializeComponents()
{
	Super::PostInitializeComponents();

	if (Role == ROLE_Authority)
	{
		// Set a timer to increment hunger every interval
		FTimerHandle Handle;
		GetWorldTimerManager().SetTimer(Handle, this, &ASCharacter::IncrementHunger, IncrementHungerInterval, true);

		SpawnDefaultInventory();
	}
}
void AManaJourneyCharacter::useCure()
{
	// use whitemage class and power depending on the level

	if (characterClasses.Contains("whiteMageClass") && !castOngoing)
	{
		toggleCastOngoing();
		bool bCastedCure = false;
		bCastedCure = whiteMageClassRef->castCure(*this, GetMesh());
		if (bCastedCure)
		{
			castHealAnimation(level);
		}
		// timer for setting cast to false
		FTimerHandle CastOngoingHandler;
		GetWorldTimerManager().ClearTimer(CastOngoingHandler);
		FTimerDelegate CastOngoingHandlerDelegate = FTimerDelegate::CreateUObject(this, &AManaJourneyCharacter::toggleCastOngoing);
		GetWorldTimerManager().SetTimer(CastOngoingHandler, CastOngoingHandlerDelegate, 1.00f, false);
	}

	// use summoner class
}
Esempio n. 22
0
void AHeatmapDataCollector::CollectData()
{
	//if (!FPlatformFileManager::Get().GetPlatformFile().DirectoryExists(*SaveDir))											// Dir exist?
	//{
	//	FPlatformFileManager::Get().GetPlatformFile().CreateDirectory(*SaveDir);											// create if it not exist
	//	if (!FPlatformFileManager::Get().GetPlatformFile().DirectoryExists(*SaveDir))										//still could not make directory?
	//	{
	//		return false;																									//Could not make the specified directory
	//	}
	//	auto FileToSave = SaveDir + "/" + FileName;
	//	if (!FPlatformFileManager::Get().GetPlatformFile().FileExists(*FileToSave))	return false;
	//}
	if (bCollectData)
	{
		if (CharCurrentPtr)
		{
			FVector CALoc = CharCurrentPtr->GetActorLocation();

			/*if (SplineDataSwitcher == ESplineDataSwitcher::ES_ArrayData)
			{
				auto FileToSaveArr = SaveDir + "/" + "ArrayLocationLogs.txt";
				static TArray<int16> ArrayToFile;
				ArrayToFile.Add(CALoc.X);
				ArrayToFile.Add(CALoc.Y);
				ArrayToFile.Add(CALoc.Z);
				SaveArrayToFile(ArrayToFile, *FileToSaveArr);
				return true;
			}*/
			if (SplineDataSwitcher == ESplineDataSwitcher::ES_StringData)
			{
				auto FileToSaveArr = SaveDirectoryPath + "/" + LogFileName + "_" + FString::FromInt(CharNumberInWorld) + ".txt";

				const FString& loc = CALoc.ToString();
				const TCHAR* StrPtr = *loc;

				StringOfCoords.Append(" line");
				StringOfCoords.Append(FString::FromInt(it));
				StringOfCoords.Append(" ");
				StringOfCoords.Append(StrPtr);
				StringOfCoords.Append("\n");
				it++;
				FFileHelper::SaveStringToFile(*StringOfCoords, *FileToSaveArr);//FFileHelper::EEncodingOptions::ForceUTF8WithoutBOM

			}
		}
	}
	if (CharCurrentPtr)
	{
		GetWorldTimerManager().SetTimer(ChekTimeHandler, this, &AHeatmapDataCollector::CollectData, UpdateTimeBetweenChek, true);
	}
}
Esempio n. 23
0
void ACSUEBomb::checkOverlap() {
	TArray<AActor*> nearbyT;
	//UE_LOG(LogTemp, Warning, TEXT("FOUND ACTOR"));
	
	bombMesh->GetOverlappingActors(nearbyT);

	for (int32 i = 0; i < nearbyT.Num(); i++) {
		//UE_LOG(LogTemp, Warning, TEXT("FOUND ACTOR"));

		auto terrorist = Cast<ACSUETerrorist>(nearbyT[i]);
		auto ct = Cast<ACSUECounterTerrorist>(nearbyT[i]);
		auto player = Cast<ACSUECharacter>(nearbyT[i]);
		if (terrorist) {
			//UE_LOG(LogTemp, Warning, TEXT("FOUND TERRORIST"));
			//start bomb timer
			if (!planted) {
				GetWorldTimerManager().SetTimer(bombTimer, this, &ACSUEBomb::bombExplode, 2.f, false);
				planted = true;
				UE_LOG(LogTemp, Warning, TEXT("bomb planted"));

			}

		}

		if (player && player->getEnemyTeam() == FString(TEXT("ct"))) {
			//UE_LOG(LogTemp, Warning, TEXT("FOUND TERRORIST"));
			if (!planted) {
				GetWorldTimerManager().SetTimer(bombTimer, this, &ACSUEBomb::bombExplode, 10.f, false);
				planted = true;
				UE_LOG(LogTemp, Warning, TEXT("bomb planted"));

			}


		}
		else if (ct) {
			//defuse shit

			//timer not started yet?
			if (!GetWorldTimerManager().IsTimerActive(defuseTimer)) {
				GetWorldTimerManager().SetTimer(defuseTimer, this, &ACSUEBomb::bombDefused, 3.f, false);

				
			}
			
		}
		else {
			//if defuse timer is active, turn it off
			if (GetWorldTimerManager().IsTimerActive(defuseTimer)) {
				GetWorldTimerManager().ClearTimer(defuseTimer);
			}

		}
	

	}

}
void AShooterWeapon::OnBurstFinished()
{
	// stop firing FX on remote clients
	BurstCounter = 0;

	// stop firing FX locally, unless it's a dedicated server
	if (GetNetMode() != NM_DedicatedServer)
	{
		StopSimulatingWeaponFire();
	}
	
	GetWorldTimerManager().ClearTimer(TimerHandle_HandleFiring);
	bRefiring = false;
}
Esempio n. 25
0
void AConstructorWeapon::EquipEnd()
{
	Super::EquipEnd();

	if (!TheLevelBlockConstructor && GetWorld() && GetWorld()->GetAuthGameMode() && GetWorld()->GetAuthGameMode<ARadeGameMode>())
	{
		TheLevelBlockConstructor = GetWorld()->GetAuthGameMode<ARadeGameMode>()->TheLevelBlockConstructor;
	}

	if (ThePlayer)
	{
		if (ThePlayer->ThePC)
		{
			GetWorldTimerManager().SetTimer(DrawCubeHandle, this, &AConstructorWeapon::DrawBox, BoxDrawUpdate, true);
			if (AmmoRestoreTime>0)GetWorldTimerManager().SetTimer(AmmoRestoreHandle, this, &AConstructorWeapon::AmmoRestore, AmmoRestoreTime, true);
		}
		else 
		{
			Client_EnableDrawBox();
		}
	}

}
void AOnlineBeaconClient::ClientOnConnected_Implementation()
{
	SetConnectionState(EBeaconConnectionState::Open);
	BeaconConnection->State = USOCK_Open;

	Role = ROLE_Authority;
	SetReplicates(true);
	SetAutonomousProxy(true);

	// Fail safe for connection to server but no client connection RPC
	GetWorldTimerManager().ClearTimer(TimerHandle_OnFailure);

	// Call the overloaded function for this client class
	OnConnected();
}
Esempio n. 27
0
void AATCharacterAI_Magic::Attack(EAttackType EType, int AnimationState)
{
	if (AttackMontageList[AnimationState] != nullptr && EType == EAttackType::EAttack_Attack && !ATAnimInstance->Montage_IsPlaying(AttackMontageList[AnimationState]))
	{
		PlayAnimMontage(AttackMontageList[AnimationState]);

		if (bIsAttacking)
		{
			FTimerHandle AttackTimerHandle;
			GetWorldTimerManager().SetTimer(AttackTimerHandle, this, &AATCharacterAI_Magic::OnAttackEnd, AttackMontageList[AnimationState]->GetPlayLength() + FiringDelay, false);
			AttackType = EAttackType::EAttack_None;
			GetCharacterMovement()->MaxWalkSpeed = 0.f;
		}
	}
}
/*Unused for now*/
void AEnemy::UpdateCharacter()
{
	Super::UpdateCharacter();
	
	if (_receiverAttack)

		if (GetDistanceTo(_receiverAttack) < GetRangeAttack() && !IsAttacking() && !_receiverAttack->IsAttacked()) {
			auto timer = GetWorldTimerManager().GetTimerRate(_countdownTimerHandle);
			if (timer != GetFlipbook(Attack_Animation)->GetTotalDuration())
			{
				SetAttacking(true);
				GetCharacterMovement()->StopMovementImmediately();
				GetWorldTimerManager().SetTimer(_countdownTimerHandle, this, &AAzraelCharacter::Attacking, GetFlipbook(Attack_Animation)->GetTotalDuration()/2.0f, false);
			}
		}
		else {
			_receiverAttack->SetAttacked(false);
		}
		if (IsPawnJumping())
			GetCharacterMovement()->SetMovementMode(MOVE_Falling);
		else if (_isPatrolling && !_isImmobile) {
			GetCharacterMovement()->Velocity = FVector(GetPawnDirection()*-100.f, 0.f, 0.f);
		}
}
void UQosEvaluator::FinalizePingServers(EQosCompletionResult Result)
{
    UE_LOG(LogQos, Log, TEXT("Ping evaluation complete. Result:%s"), ToString(Result));

    TWeakObjectPtr<UQosEvaluator> WeakThisCap(this);
    FTimerDelegate TimerDelegate = FTimerDelegate::CreateLambda([Result, WeakThisCap]() {
        if (WeakThisCap.IsValid())
        {
            auto StrongThis = WeakThisCap.Get();
            StrongThis->OnQosPingEvalComplete.ExecuteIfBound(Result);
            StrongThis->ResetSearchVars();
        }
    });
    GetWorldTimerManager().SetTimerForNextTick(TimerDelegate);
}
Esempio n. 30
0
void AItemPickup::BeginPlay()
{
	Super::BeginPlay();

//	printr("Pickup Spawned");
	if (Role < ROLE_Authority)
		return;

	SetReplicateMovement(true);
	SetReplicates(true);

	FTimerHandle MyHandle;
	GetWorldTimerManager().SetTimer(MyHandle, this, &AItemPickup::ActivatePickupOverlap, PickupCollisionDelay, false);

}