Example #1
0
void AWalkerAIController::TryPauseMovement(const bool bItWasRunOver)
{
  if ((Status != EWalkerStatus::Paused) && (Status != EWalkerStatus::RunOver)) {
    auto MoveRequestID = GetCurrentMoveRequestID();
    if (MoveRequestID == FAIRequestID()) { // equals invalid request.
      LOG_AI_WALKER(Error, "has invalid move ID");
    } else {
      if (!PauseMove(MoveRequestID)) {
        LOG_AI_WALKER(Error, "is unable to pause movement");
      } else {
        LOG_AI_WALKER(Log, "paused");
        Status = (bItWasRunOver ? EWalkerStatus::RunOver : EWalkerStatus::Paused);
      }
    }
  }
}
Example #2
0
void AWalkerAIController::TryResumeMovement()
{
  if (Status != EWalkerStatus::Moving) {
    auto MoveRequestID = GetCurrentMoveRequestID();
    if (MoveRequestID == FAIRequestID()) { // equals invalid request.
      LOG_AI_WALKER(Error, "has invalid move ID");
    } else {
      if (!ResumeMove(MoveRequestID)) {
        LOG_AI_WALKER(Error, "is unable to resume movement");
      } else {
        LOG_AI_WALKER(Log, "resuming movement");
        Status = EWalkerStatus::Moving;
      }
    }
  }
}
Example #3
0
void AWalkerAIController::Tick(float DeltaSeconds)
{
  Super::Tick(DeltaSeconds);

  if (Status != EWalkerStatus::RunOver) {
    switch (GetMoveStatus()) {
      case EPathFollowingStatus::Idle:
      case EPathFollowingStatus::Waiting:
        LOG_AI_WALKER(Warning, "is stuck!");
        Status = EWalkerStatus::Stuck;
        break;
      case EPathFollowingStatus::Paused:
        LOG_AI_WALKER(Log, "is paused");
        TryResumeMovement();
        break;
    };
  }
}
Example #4
0
void AWalkerAIController::OnPawnTookDamage(
    AActor *DamagedActor,
    float Damage,
    const UDamageType *DamageType,
    AController *InstigatedBy,
    AActor *DamageCauser)
{
  LOG_AI_WALKER(Warning, "has been run over");
  constexpr bool bItWasRunOver = true;
  TryPauseMovement(bItWasRunOver);
  Status = EWalkerStatus::RunOver;
}
Example #5
0
void AWalkerAIController::Tick(float DeltaSeconds)
{
  Super::Tick(DeltaSeconds);
  TimeInState+=DeltaSeconds;
  if (Status != EWalkerStatus::RunOver) 
  {
    switch (GetMoveStatus()) 
	{
	  default: break;
      case EPathFollowingStatus::Idle: 
      //case EPathFollowingStatus::Waiting: //<-- incomplete path
        LOG_AI_WALKER(Warning, "is stuck!");
        ChangeStatus(EWalkerStatus::Stuck);
        break;
      case EPathFollowingStatus::Paused:
		if(TimeInState>WALKER_MAX_TIME_PAUSED){
			LOG_AI_WALKER(Log, "is paused, trying resume movement");
			TryResumeMovement();
		}
        break;
	
	};
  }
}