Files
UnrealPrototyping/Source/Salty/Variant_Combat/CombatGameMode.cpp
T
Rainer LeitandClaude Fable 5.1 4f2c55cd2a Step 1: the Salty project, two modules, tests and the gym
Salty.uproject (UE 5.8) from the Third Person template with class redirects, the SaltyCore and Salty modules,
the three build targets, USaltyAssetManager calling InitGlobalData, Config/Tags with the 23 root namespaces,
Scripts/run-tests.sh, build.sh and Authoring/create_gym.py, L_Gym, Git LFS attributes and the placeholder test.
Template variants kept as reference (D-41). The four Fab packs stay out of the repository for now (~10 GB).
The editor serves the engine MCP plugin on 127.0.0.1:8000 through DefaultEditorPerProjectUserSettings.ini.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-16 20:10:43 +03:00

54 lines
1.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Variant_Combat/CombatGameMode.h"
#include "Kismet/GameplayStatics.h"
#include "GameFramework/PlayerStart.h"
#include "Engine/World.h"
ACombatGameMode::ACombatGameMode()
{
// stub
}
void ACombatGameMode::BeginPlay()
{
Super::BeginPlay();
// create each additional local player.
// Player 0 will be created automatically as part of regular game init
for (int32 i = 2; i <= NumberOfLocalPlayers; ++i)
{
UGameplayStatics::CreatePlayer(GetWorld(), -1, true);
}
}
AActor* ACombatGameMode::ChoosePlayerStart_Implementation(AController* Player)
{
// build the current player tag
FName PlayerTag = FName(*FString::Printf(TEXT("Player%d"), CurrentPlayerStartAssignment));
// find all player starts with the matching player tag
TArray<AActor*> PlayerStarts;
UGameplayStatics::GetAllActorsOfClassWithTag(GetWorld(), APlayerStart::StaticClass(), PlayerTag, PlayerStarts);
// increment the player start assignment index
++CurrentPlayerStartAssignment;
// if no PlayerStarts were found, default to all PlayerStarts instead
if (PlayerStarts.IsEmpty())
{
UGameplayStatics::GetAllActorsOfClass(GetWorld(), APlayerStart::StaticClass(), PlayerStarts);
}
// have we found at least one PlayerStart?
if (!PlayerStarts.IsEmpty())
{
return PlayerStarts[ FMath::RandRange(0, PlayerStarts.Num() - 1) ];
}
// no PlayerStarts in the level
return nullptr;
}