Place initial gameplay actors in test map

This commit is contained in:
2026-05-13 19:04:41 -07:00
parent 744b3c35e2
commit 46d0e080b5
11 changed files with 288 additions and 21 deletions
@@ -0,0 +1,46 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "AgrarianEditorAutomationLibrary.h"
#include "Engine/World.h"
#if WITH_EDITOR
#include "Editor.h"
#endif
AActor* UAgrarianEditorAutomationLibrary::SpawnActorInEditorWorld(TSubclassOf<AActor> ActorClass, const FVector& Location, const FRotator& Rotation, const FString& ActorLabel)
{
#if WITH_EDITOR
if (!ActorClass)
{
return nullptr;
}
UWorld* EditorWorld = GEditor ? GEditor->GetEditorWorldContext().World() : nullptr;
if (!EditorWorld)
{
return nullptr;
}
FActorSpawnParameters SpawnParameters;
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
SpawnParameters.ObjectFlags = RF_Transactional;
AActor* SpawnedActor = EditorWorld->SpawnActor<AActor>(ActorClass, Location, Rotation, SpawnParameters);
if (!SpawnedActor)
{
return nullptr;
}
if (!ActorLabel.IsEmpty())
{
SpawnedActor->SetActorLabel(ActorLabel, true);
}
SpawnedActor->MarkPackageDirty();
EditorWorld->MarkPackageDirty();
return SpawnedActor;
#else
return nullptr;
#endif
}
@@ -0,0 +1,20 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "AgrarianEditorAutomationLibrary.generated.h"
/**
* Editor automation helpers used by Python setup scripts.
*/
UCLASS()
class AGRARIANGAME_API UAgrarianEditorAutomationLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category = "Agrarian|Editor Automation")
static AActor* SpawnActorInEditorWorld(TSubclassOf<AActor> ActorClass, const FVector& Location, const FRotator& Rotation, const FString& ActorLabel);
};
@@ -23,6 +23,13 @@ public class AgrarianGame : ModuleRules
PrivateDependencyModuleNames.AddRange(new string[] { });
if (Target.bBuildEditor)
{
PrivateDependencyModuleNames.AddRange(new string[] {
"UnrealEd"
});
}
PublicIncludePaths.AddRange(new string[] {
"AgrarianGame",
"AgrarianGame/Variant_Platforming",