|
|
@ -3,6 +3,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include "PartySubsystem.h"
|
|
|
|
#include "PartySubsystem.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "Kismet/GameplayStatics.h"
|
|
|
|
|
|
|
|
|
|
|
|
void UPartySubsystem::AddToParty(UUnitInfo* UnitInfo)
|
|
|
|
void UPartySubsystem::AddToParty(UUnitInfo* UnitInfo)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (FPartyMember &Unit : Members)
|
|
|
|
for (FPartyMember &Unit : Members)
|
|
|
@ -32,7 +34,13 @@ int32 UPartySubsystem::SpawnParty(const float InVerticalSpacing, const float InH
|
|
|
|
this->HorizontalOffset = InHorizontalOffset;
|
|
|
|
this->HorizontalOffset = InHorizontalOffset;
|
|
|
|
this->NumRows = InNumRows;
|
|
|
|
this->NumRows = InNumRows;
|
|
|
|
this->HorizontalSpacing = InHorizontalSpacing;
|
|
|
|
this->HorizontalSpacing = InHorizontalSpacing;
|
|
|
|
|
|
|
|
CurrentColumn = 0;
|
|
|
|
|
|
|
|
SpawnQueue.Empty();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TArray<AActor*> SpawnPoints;
|
|
|
|
|
|
|
|
UGameplayStatics::GetAllActorsWithTag(GetWorld(), "PlayerSpawn", SpawnPoints);
|
|
|
|
|
|
|
|
SpawnPoint = SpawnPoints[0];
|
|
|
|
|
|
|
|
|
|
|
|
for (FPartyMember &Unit : GetMembers())
|
|
|
|
for (FPartyMember &Unit : GetMembers())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for(auto i = 0; i < GetMemberAllocated(Unit); i++)
|
|
|
|
for(auto i = 0; i < GetMemberAllocated(Unit); i++)
|
|
|
@ -41,7 +49,7 @@ int32 UPartySubsystem::SpawnParty(const float InVerticalSpacing, const float InH
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const auto NumUnits= SpawnQueue.Num();
|
|
|
|
const int32 NumUnits = SpawnQueue.Num();
|
|
|
|
|
|
|
|
|
|
|
|
SpawnUnits();
|
|
|
|
SpawnUnits();
|
|
|
|
GetWorld()->GetTimerManager().SetTimer(
|
|
|
|
GetWorld()->GetTimerManager().SetTimer(
|
|
|
@ -68,8 +76,22 @@ void UPartySubsystem::SpawnUnits()
|
|
|
|
FActorSpawnParameters SpawnActorParameters = {};
|
|
|
|
FActorSpawnParameters SpawnActorParameters = {};
|
|
|
|
SpawnActorParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn;
|
|
|
|
SpawnActorParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn;
|
|
|
|
|
|
|
|
|
|
|
|
FVector Location = FVector( VerticalSpacing * i - VerticalSpacing, -HorizontalOffset * CurrentColumn, 1000);
|
|
|
|
FVector Location = SpawnPoint->GetActorLocation() + FVector(i * -VerticalSpacing, -HorizontalOffset * CurrentColumn, 300);
|
|
|
|
GetWorld()->SpawnActor(SpawnQueue[i + LastSpawnIndex], &Location, nullptr, SpawnActorParameters);
|
|
|
|
FRotator Rotation = FRotator(0, 90.0f, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AActor* NewActor = GetWorld()->SpawnActor(SpawnQueue[i + LastSpawnIndex], &Location, &Rotation, SpawnActorParameters);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FHitResult Hit;
|
|
|
|
|
|
|
|
FVector TraceStart = NewActor->GetActorLocation();
|
|
|
|
|
|
|
|
FVector TraceEnd = -NewActor->GetActorUpVector() * 10000.0f;
|
|
|
|
|
|
|
|
FCollisionQueryParams QueryParams;
|
|
|
|
|
|
|
|
QueryParams.AddIgnoredActor(NewActor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NewActor->GetWorld()->LineTraceSingleByChannel(Hit, TraceStart, TraceEnd, ECC_WorldStatic, QueryParams);
|
|
|
|
|
|
|
|
if(Hit.bBlockingHit)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NewActor->SetActorLocation(Hit.Location, true, nullptr, ETeleportType::ResetPhysics);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LastSpawnIndex += NumRows;
|
|
|
|
LastSpawnIndex += NumRows;
|
|
|
|