You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.2 KiB
67 lines
2.2 KiB
2 years ago
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||
|
|
||
|
|
||
2 years ago
|
#include "Explosion.h"
|
||
2 years ago
|
#include "Trooper.h"
|
||
|
#include "Net/UnrealNetwork.h"
|
||
|
#include "Particles/ParticleSystemComponent.h"
|
||
|
|
||
2 years ago
|
AExplosion::AExplosion() {
|
||
2 years ago
|
// if (!CollisionComponent) {
|
||
|
// CollisionComponent = CreateDefaultSubobject<USphereComponent>(
|
||
|
// TEXT("SphereComponent"));
|
||
|
// RootComponent = CollisionComponent;
|
||
|
// }
|
||
|
if (!ParticleSystemComponent) {
|
||
|
ParticleSystemComponent = CreateDefaultSubobject<
|
||
|
UParticleSystemComponent>(
|
||
|
TEXT("ParticleSystemComponent"));
|
||
|
RootComponent = ParticleSystemComponent;
|
||
|
}
|
||
|
InitialLifeSpan = 1.0f;
|
||
|
}
|
||
|
|
||
2 years ago
|
void AExplosion::Initialize(float damage,
|
||
2 years ago
|
float splashRadius,
|
||
|
uint8 playerIndex) {
|
||
|
Damage = damage;
|
||
|
PlayerIndex = playerIndex;
|
||
|
float Scale = splashRadius / 50;
|
||
|
// CollisionComponent->SetWorldScale3D({Scale, Scale, Scale});
|
||
|
if (ParticleSystemComponent && ParticleSystemComponent->IsValidLowLevel()) {
|
||
|
ParticleSystemComponent->SetWorldScale3D({Scale, Scale, Scale});
|
||
|
}
|
||
|
}
|
||
|
|
||
2 years ago
|
void AExplosion::BeginPlay() {
|
||
2 years ago
|
Super::BeginPlay();
|
||
|
}
|
||
|
|
||
2 years ago
|
void AExplosion::NotifyActorBeginOverlap(AActor *OtherActor) {
|
||
2 years ago
|
Super::NotifyActorBeginOverlap(OtherActor);
|
||
|
ATrooper *OtherTrooper = Cast<ATrooper>(OtherActor);
|
||
|
if (OtherTrooper) {
|
||
|
UE_LOG(LogTemp, Warning,
|
||
|
TEXT(
|
||
|
"Begin explosion overlap: id: %d, index: %d, damage: %f, my index: %d"
|
||
|
),
|
||
|
OtherTrooper->GetId(), OtherTrooper->GetPlayerIndex(), Damage,
|
||
|
PlayerIndex);
|
||
|
if (PlayerIndex != -1 && PlayerIndex != OtherTrooper->
|
||
|
GetPlayerIndex()) {
|
||
2 years ago
|
OtherTrooper->TrooperTakeDamage(Damage);
|
||
2 years ago
|
}
|
||
|
} else {
|
||
|
UE_LOG(LogTemp, Warning, TEXT("Overlapped not a trooper"));
|
||
|
}
|
||
|
}
|
||
|
|
||
2 years ago
|
void AExplosion::GetLifetimeReplicatedProps(
|
||
2 years ago
|
TArray<FLifetimeProperty> &OutLifetimeProps) const {
|
||
|
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||
2 years ago
|
DOREPLIFETIME(AExplosion, Damage);
|
||
|
DOREPLIFETIME(AExplosion, PlayerIndex);
|
||
2 years ago
|
// DOREPLIFETIME(AMyExplosion, CollisionComponent);
|
||
2 years ago
|
DOREPLIFETIME(AExplosion, ParticleSystemComponent);
|
||
2 years ago
|
}
|