View difference between Paste ID: kTn39xkP and bvbvU2rh
SHOW: | | - or go back to the newest paste.
1
#include "Gameplay/Foes/MTD_FoeCharacter.h"
2
3
#include "Components/CapsuleComponent.h"
4
#include "FiniteStateMachine/FiniteStateMachine.h"
5
#include "Gameplay/Foes/AI/States/MTD_FoeState_MovingAroundBlockade.h"
6
#include "Gameplay/Foes/MTD_FoeController.h"
7
8
AMTD_FoeCharacter::AMTD_FoeCharacter()
9
{
10
	PrimaryActorTick.bCanEverTick = false;
11
	PrimaryActorTick.bStartWithTickEnabled = false;
12
13
	AIControllerClass = AMTD_FoeController::StaticClass();
14
}
15
16
void AMTD_FoeCharacter::PreInitializeComponents()
17
{
18
	Super::PreInitializeComponents();
19
20
	UPrimitiveComponent* Collision = GetCapsuleComponent();
21
	Collision->OnComponentHit.AddDynamic(this, &ThisClass::OnCapsuleHit);
22
}
23
24
void AMTD_FoeCharacter::OnCapsuleHit(
25
	UPrimitiveComponent* HitComponent,
26
	AActor* OtherActor,
27
	UPrimitiveComponent* OtherComp,
28
	FVector NormalImpulse,
29
	const FHitResult& Hit)
30
{
31
	if (!OtherActor->IsA(StaticClass()))
32
	{
33
		return;
34
	}
35
36
	const auto* FoeController = GetController<AMTD_FoeController>();
37
	check(IsValid(FoeController));
38
39
	UFiniteStateMachine* StateMachine = FoeController->GetStateMachine();
40
	check(IsValid(StateMachine));
41
42
	UMTD_FoeState_MovingAroundBlockade::MoveAroundBlockade(StateMachine, OtherActor, 0.f, Hit.Normal);
43
}
44