Merge branch 'dev' into Inventory-System
This commit is contained in:
commit
55e9321288
@ -25,7 +25,6 @@ AAICharacter::AAICharacter()
|
|||||||
void AAICharacter::BeginPlay()
|
void AAICharacter::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every frame
|
// Called every frame
|
||||||
@ -54,31 +53,7 @@ float AAICharacter::TakeDamage(const float DamageAmount, FDamageEvent const& Dam
|
|||||||
CurrentHealth = 0;
|
CurrentHealth = 0;
|
||||||
UE_LOG(LogTemp, Display, TEXT("%s is dead"), *CharacterName.ToString());
|
UE_LOG(LogTemp, Display, TEXT("%s is dead"), *CharacterName.ToString());
|
||||||
|
|
||||||
/*const AAI_EnemyController* AIController = Cast<AAI_EnemyController>(GetController());
|
OnDeath();
|
||||||
AIController->GetBrainComponent()->StopLogic(" is dead");*/
|
|
||||||
this->Tags.Add(FName("Dead"));
|
|
||||||
//Ragdoll
|
|
||||||
DetachFromControllerPendingDestroy();
|
|
||||||
UCapsuleComponent* CapsuleComp = GetCapsuleComponent();
|
|
||||||
CapsuleComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
|
||||||
CapsuleComp->SetCollisionResponseToAllChannels(ECR_Ignore);
|
|
||||||
|
|
||||||
GetMesh()->SetCollisionProfileName(TEXT("Ragdoll"));
|
|
||||||
SetActorEnableCollision(true);
|
|
||||||
|
|
||||||
GetMesh()->SetAllBodiesSimulatePhysics(true);
|
|
||||||
GetMesh()->SetSimulatePhysics(true);
|
|
||||||
GetMesh()->WakeAllRigidBodies();
|
|
||||||
GetMesh()->bBlendPhysics = true;
|
|
||||||
|
|
||||||
if (UCharacterMovementComponent* CharacterComp = Cast<UCharacterMovementComponent>(GetMovementComponent()))
|
|
||||||
{
|
|
||||||
CharacterComp->StopMovementImmediately();
|
|
||||||
CharacterComp->DisableMovement();
|
|
||||||
CharacterComp->SetComponentTickEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
SetLifeSpan(30.0f);
|
|
||||||
}
|
}
|
||||||
return Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
|
return Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
|
||||||
}
|
}
|
||||||
@ -98,3 +73,31 @@ void AAICharacter::SetupStimuliSourceComponent()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AAICharacter::OnDeath()
|
||||||
|
{
|
||||||
|
/*const AAI_EnemyController* AIController = Cast<AAI_EnemyController>(GetController());
|
||||||
|
AIController->GetBrainComponent()->StopLogic(" is dead");*/
|
||||||
|
this->Tags.Add(FName("Dead"));
|
||||||
|
//Ragdoll
|
||||||
|
DetachFromControllerPendingDestroy();
|
||||||
|
UCapsuleComponent* CapsuleComp = GetCapsuleComponent();
|
||||||
|
CapsuleComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||||
|
CapsuleComp->SetCollisionResponseToAllChannels(ECR_Ignore);
|
||||||
|
|
||||||
|
GetMesh()->SetCollisionProfileName(TEXT("Ragdoll"));
|
||||||
|
SetActorEnableCollision(true);
|
||||||
|
|
||||||
|
GetMesh()->SetAllBodiesSimulatePhysics(true);
|
||||||
|
GetMesh()->SetSimulatePhysics(true);
|
||||||
|
GetMesh()->WakeAllRigidBodies();
|
||||||
|
GetMesh()->bBlendPhysics = true;
|
||||||
|
|
||||||
|
if (UCharacterMovementComponent* CharacterComp = Cast<UCharacterMovementComponent>(GetMovementComponent()))
|
||||||
|
{
|
||||||
|
CharacterComp->StopMovementImmediately();
|
||||||
|
CharacterComp->DisableMovement();
|
||||||
|
CharacterComp->SetComponentTickEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
SetLifeSpan(30.0f);
|
||||||
|
}
|
||||||
|
@ -35,6 +35,8 @@ protected:
|
|||||||
class UAIPerceptionStimuliSourceComponent* StimuliSourceComponent;
|
class UAIPerceptionStimuliSourceComponent* StimuliSourceComponent;
|
||||||
void SetupStimuliSourceComponent();
|
void SetupStimuliSourceComponent();
|
||||||
|
|
||||||
|
virtual void OnDeath();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Called every frame
|
// Called every frame
|
||||||
virtual void Tick(float DeltaTime) override;
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
@ -74,3 +74,8 @@ void AAIControlHub::SetPlayerLastKnownLocation(FVector Location)
|
|||||||
PlayerLastKnownLocation = Location;
|
PlayerLastKnownLocation = Location;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AAIControlHub::RemoveEnemyActor(AEnemyCharacter* EnemyActor)
|
||||||
|
{
|
||||||
|
EnemyActors.Remove(EnemyActor);
|
||||||
|
}
|
||||||
|
@ -35,6 +35,7 @@ public:
|
|||||||
int GetAlertLevel() const;
|
int GetAlertLevel() const;
|
||||||
void OnAlertLevelChanged();
|
void OnAlertLevelChanged();
|
||||||
void SetPlayerLastKnownLocation(FVector Location = FVector(0, 0, 0));
|
void SetPlayerLastKnownLocation(FVector Location = FVector(0, 0, 0));
|
||||||
|
void RemoveEnemyActor(AEnemyCharacter* EnemyActor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int AlertLevel = 0;
|
int AlertLevel = 0;
|
||||||
|
@ -23,6 +23,16 @@ void AEnemyCharacter::BeginPlay()
|
|||||||
CharacterName = "Enemy";
|
CharacterName = "Enemy";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AEnemyCharacter::OnDeath()
|
||||||
|
{
|
||||||
|
Super::OnDeath();
|
||||||
|
DelegatedControlHub->AlertLevelEvent.Remove(AlertLevelDelegateHandle);
|
||||||
|
DelegatedControlHub->HuntPlayerEvent.Remove(HuntPlayerDelegateHandle);
|
||||||
|
AlertLevelDelegateHandle.Reset();
|
||||||
|
HuntPlayerDelegateHandle.Reset();
|
||||||
|
DelegatedControlHub->RemoveEnemyActor(this);
|
||||||
|
}
|
||||||
|
|
||||||
// Called every frame
|
// Called every frame
|
||||||
void AEnemyCharacter::Tick(float DeltaTime)
|
void AEnemyCharacter::Tick(float DeltaTime)
|
||||||
{
|
{
|
||||||
@ -38,6 +48,8 @@ void AEnemyCharacter::SubscribeToGroupAIEvents(AAIControlHub* ControlHub)
|
|||||||
|
|
||||||
void AEnemyCharacter::SetAlertLevel(const int NewAlertLevel) const
|
void AEnemyCharacter::SetAlertLevel(const int NewAlertLevel) const
|
||||||
{
|
{
|
||||||
|
if (!IsValid(this)) return;
|
||||||
|
if (!IsValid(GetController())) return;
|
||||||
Cast<AAIController>(GetController())->GetBlackboardComponent()->SetValueAsInt("AlertLevel", NewAlertLevel);
|
Cast<AAIController>(GetController())->GetBlackboardComponent()->SetValueAsInt("AlertLevel", NewAlertLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +61,8 @@ void AEnemyCharacter::SetLocalAlertLevel(int NewAlertLevel) const
|
|||||||
|
|
||||||
void AEnemyCharacter::HuntPlayer(FVector PlayerLastKnownLocation)
|
void AEnemyCharacter::HuntPlayer(FVector PlayerLastKnownLocation)
|
||||||
{
|
{
|
||||||
|
if (!IsValid(this)) return;
|
||||||
|
if (!IsValid(GetController())) return;
|
||||||
SetAlertLevel(2);
|
SetAlertLevel(2);
|
||||||
Cast<AAIController>(GetController())->GetBlackboardComponent()->SetValueAsVector("LastKnownLocation", PlayerLastKnownLocation);
|
Cast<AAIController>(GetController())->GetBlackboardComponent()->SetValueAsVector("LastKnownLocation", PlayerLastKnownLocation);
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ protected:
|
|||||||
// Called when the game starts or when spawned
|
// Called when the game starts or when spawned
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
class AAIControlHub* DelegatedControlHub;
|
class AAIControlHub* DelegatedControlHub;
|
||||||
|
virtual void OnDeath() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Called every frame
|
// Called every frame
|
||||||
|
Loading…
Reference in New Issue
Block a user