Commit a66441cc authored by Carl Findahl's avatar Carl Findahl 💬
Browse files

Add blood FX on hit. Fix spawning in Arena mode

parent bf3864b1
No preview for this file type
......@@ -5,6 +5,8 @@
#include "VikingCharacter.h"
#include "VikingWeaponItem.h"
#include "Engine/World.h"
#include "Kismet/GameplayStatics.h"
#include "GameFramework/PlayerStart.h"
void AVikingArenaGameMode::StartMatch() {
Super::StartMatch();
......@@ -37,7 +39,31 @@ bool AVikingArenaGameMode::ReadyToStartMatch_Implementation()
return GetNumPlayers() == MaxPlayers;
}
AVikingArenaGameMode::AVikingArenaGameMode()
void AVikingArenaGameMode::BeginPlay()
{
Super::BeginPlay();
FindAndStoreAllSpawnPoints();
}
AActor* AVikingArenaGameMode::ChoosePlayerStart_Implementation(AController* Player)
{
Super::ChoosePlayerStart_Implementation(Player);
if (SpawnPoints.Num() == 0)
{
FindAndStoreAllSpawnPoints();
}
AActor* SpawnPoint = SpawnPoints[NextSpawnPoint];
NextSpawnPoint = (NextSpawnPoint + 1) % SpawnPoints.Num();
return SpawnPoint;
}
void AVikingArenaGameMode::FindAndStoreAllSpawnPoints()
{
UWorld* World = GetWorld();
if (!ensure(World != nullptr)) return;
SpawnPoints.Empty();
UGameplayStatics::GetAllActorsOfClass(World, APlayerStart::StaticClass(), SpawnPoints);
}
......@@ -16,6 +16,12 @@ class VIKING_API AVikingArenaGameMode : public AGameMode
private:
virtual void StartMatch() override;
/** Possible spawn points for player */
TArray<AActor*> SpawnPoints{};
/** Next spawn point to use */
int32 NextSpawnPoint = 0;
protected:
/** Max players in Arena */
......@@ -26,8 +32,15 @@ protected:
UPROPERTY(EditDefaultsOnly, Category = ArenaMode)
class UVikingWeaponItem* WeaponItem;
/** True when match can begin */
virtual bool ReadyToStartMatch_Implementation() override;
/** Fetches all spawn points and stores them */
virtual void BeginPlay() override;
public:
AVikingArenaGameMode();
virtual AActor* ChoosePlayerStart_Implementation(AController* Player) override;
private:
void FindAndStoreAllSpawnPoints();
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment