commit d3b4f002d361d10852d4ae7519ae5d0360875f9e Author: Jonasz Bigda Date: Sun Jul 30 16:30:14 2023 +0200 Init diff --git a/Config/DefaultEditor.ini b/Config/DefaultEditor.ini new file mode 100644 index 0000000..e69de29 diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini new file mode 100644 index 0000000..ee01ca3 --- /dev/null +++ b/Config/DefaultEngine.ini @@ -0,0 +1,70 @@ + + +[/Script/EngineSettings.GameMapsSettings] +GameDefaultMap=/Game/Levels/Main.Main +EditorStartupMap=/Game/Levels/Main.Main + +[/Script/WindowsTargetPlatform.WindowsTargetSettings] +DefaultGraphicsRHI=DefaultGraphicsRHI_DX12 +-D3D12TargetedShaderFormats=PCD3D_SM5 ++D3D12TargetedShaderFormats=PCD3D_SM6 +-D3D11TargetedShaderFormats=PCD3D_SM5 ++D3D11TargetedShaderFormats=PCD3D_SM5 +Compiler=Default +AudioSampleRate=48000 +AudioCallbackBufferFrameSize=1024 +AudioNumBuffersToEnqueue=1 +AudioMaxChannels=0 +AudioNumSourceWorkers=4 +SpatializationPlugin= +SourceDataOverridePlugin= +ReverbPlugin= +OcclusionPlugin= +CompressionOverrides=(bOverrideCompressionTimes=False,DurationThreshold=5.000000,MaxNumRandomBranches=0,SoundCueQualityIndex=0) +CacheSizeKB=65536 +MaxChunkSizeOverrideKB=0 +bResampleForDevice=False +MaxSampleRate=48000.000000 +HighSampleRate=32000.000000 +MedSampleRate=24000.000000 +LowSampleRate=12000.000000 +MinSampleRate=8000.000000 +CompressionQualityModifier=1.000000 +AutoStreamingThreshold=0.000000 +SoundCueCookQualityIndex=-1 + +[/Script/HardwareTargeting.HardwareTargetingSettings] +TargetedHardwareClass=Desktop +AppliedTargetedHardwareClass=Desktop +DefaultGraphicsPerformance=Maximum +AppliedDefaultGraphicsPerformance=Maximum + +[/Script/Engine.RendererSettings] +r.GenerateMeshDistanceFields=True +r.DynamicGlobalIlluminationMethod=1 +r.ReflectionMethod=1 +r.Shadow.Virtual.Enable=1 +r.DefaultFeature.AutoExposure.ExtendDefaultLuminanceRange=True + +[/Script/WorldPartitionEditor.WorldPartitionEditorSettings] +CommandletClass=Class'/Script/UnrealEd.WorldPartitionConvertCommandlet' + +[/Script/Engine.Engine] ++ActiveGameNameRedirects=(OldGameName="TP_Blank",NewGameName="/Script/UE5_GridTool") ++ActiveGameNameRedirects=(OldGameName="/Script/TP_Blank",NewGameName="/Script/UE5_GridTool") ++ActiveClassRedirects=(OldClassName="TP_BlankGameModeBase",NewClassName="UE5_GridToolGameModeBase") + +[/Script/AndroidFileServerEditor.AndroidFileServerRuntimeSettings] +bEnablePlugin=True +bAllowNetworkConnection=True +SecurityToken=1E5C251E4FE5E97D0DE06C9C4F292D89 +bIncludeInShipping=False +bAllowExternalStartInShipping=False +bCompileAFSProject=False +bUseCompression=False +bLogFiles=False +bReportStats=False +ConnectionType=USBOnly +bUseManualIPAddress=False +ManualIPAddress= + diff --git a/Config/DefaultGame.ini b/Config/DefaultGame.ini new file mode 100644 index 0000000..fea94ae --- /dev/null +++ b/Config/DefaultGame.ini @@ -0,0 +1,3 @@ + +[/Script/EngineSettings.GeneralProjectSettings] +ProjectID=8541077E41E6FCEB2E0EE49C8DCD06BF diff --git a/Config/DefaultInput.ini b/Config/DefaultInput.ini new file mode 100644 index 0000000..4cc3605 --- /dev/null +++ b/Config/DefaultInput.ini @@ -0,0 +1,85 @@ +[/Script/Engine.InputSettings] +-AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) +-AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) +-AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) +-AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) +-AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f)) +-AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f)) +-AxisConfig=(AxisKeyName="Mouse2D",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f)) ++AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Mouse2D",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MouseWheelAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Gamepad_LeftTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Gamepad_RightTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Gamepad_Special_Left_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Gamepad_Special_Left_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Vive_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Vive_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Vive_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Vive_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Vive_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Vive_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="OculusTouch_Left_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="OculusTouch_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="OculusTouch_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="OculusTouch_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="OculusTouch_Right_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="OculusTouch_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="OculusTouch_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="OculusTouch_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Left_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Left_Grip_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Right_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Right_Grip_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) +bAltEnterTogglesFullscreen=True +bF11TogglesFullscreen=True +bUseMouseForTouch=False +bEnableMouseSmoothing=True +bEnableFOVScaling=True +bCaptureMouseOnLaunch=True +bEnableLegacyInputScales=True +bEnableMotionControls=True +bFilterInputByPlatformUser=False +bShouldFlushPressedKeysOnViewportFocusLost=True +bAlwaysShowTouchInterface=False +bShowConsoleOnFourFingerTap=True +bEnableGestureRecognizer=False +bUseAutocorrect=False +DefaultViewportMouseCaptureMode=CapturePermanently_IncludingInitialMouseDown +DefaultViewportMouseLockMode=LockOnCapture +FOVScale=0.011110 +DoubleClickTime=0.200000 +DefaultPlayerInputClass=/Script/EnhancedInput.EnhancedPlayerInput +DefaultInputComponentClass=/Script/EnhancedInput.EnhancedInputComponent +DefaultTouchInterface=/Engine/MobileResources/HUD/DefaultVirtualJoysticks.DefaultVirtualJoysticks +-ConsoleKeys=Tilde ++ConsoleKeys=Tilde ++ConsoleKeys=Caret + diff --git a/Content/Blueprints/BP_LevelChunk.uasset b/Content/Blueprints/BP_LevelChunk.uasset new file mode 100644 index 0000000..062e92f Binary files /dev/null and b/Content/Blueprints/BP_LevelChunk.uasset differ diff --git a/Content/Blueprints/SpawnableElements/BP_SpawnableBox.uasset b/Content/Blueprints/SpawnableElements/BP_SpawnableBox.uasset new file mode 100644 index 0000000..4b122d2 Binary files /dev/null and b/Content/Blueprints/SpawnableElements/BP_SpawnableBox.uasset differ diff --git a/Content/Blueprints/SpawnableElements/BP_SpawnableElementBase.uasset b/Content/Blueprints/SpawnableElements/BP_SpawnableElementBase.uasset new file mode 100644 index 0000000..b7ab933 Binary files /dev/null and b/Content/Blueprints/SpawnableElements/BP_SpawnableElementBase.uasset differ diff --git a/Content/Blueprints/SpawnableElements/BP_SpawnableSphere.uasset b/Content/Blueprints/SpawnableElements/BP_SpawnableSphere.uasset new file mode 100644 index 0000000..14991e2 Binary files /dev/null and b/Content/Blueprints/SpawnableElements/BP_SpawnableSphere.uasset differ diff --git a/Content/Levels/Main.umap b/Content/Levels/Main.umap new file mode 100644 index 0000000..5990bf3 Binary files /dev/null and b/Content/Levels/Main.umap differ diff --git a/Source/UE5_GridTool.Target.cs b/Source/UE5_GridTool.Target.cs new file mode 100644 index 0000000..e082038 --- /dev/null +++ b/Source/UE5_GridTool.Target.cs @@ -0,0 +1,15 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +using UnrealBuildTool; +using System.Collections.Generic; + +public class UE5_GridToolTarget : TargetRules +{ + public UE5_GridToolTarget( TargetInfo Target) : base(Target) + { + Type = TargetType.Game; + DefaultBuildSettings = BuildSettingsVersion.V2; + IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_1; + ExtraModuleNames.Add("UE5_GridTool"); + } +} diff --git a/Source/UE5_GridTool/LevelChunk.cpp b/Source/UE5_GridTool/LevelChunk.cpp new file mode 100644 index 0000000..c7c29f8 --- /dev/null +++ b/Source/UE5_GridTool/LevelChunk.cpp @@ -0,0 +1,84 @@ +#include "LevelChunk.h" + +ALevelChunk::ALevelChunk() +{ + PrimaryActorTick.bCanEverTick = false; + RootComponent = CreateDefaultSubobject(TEXT("RootComponent")); + SetupGrid(); +} + +// Called when the game starts or when spawned +void ALevelChunk::BeginPlay() +{ + Super::BeginPlay(); + CleanupComponents(); +} + +void ALevelChunk::SetupGrid() { + // Set XYZ base points. Next we will offset each next slot from these points + float ZBase = -(100.f * (SizeZ - 1) / 2); + float XBase = -(100.f * (SizeX - 1) / 2); + float YBase = -(100.f * (SizeY - 1) / 2); + int32 Count = 0; + + // Z axis loop + for (int32 z = 0; z < SizeZ; ++z) { + float ZOffset = ZBase + (100.f * z); + + // X axis loop + for (int32 x = 0; x < SizeX; ++x) { + float XOffset = XBase + (100.f * x); + + // Y axis loop + for (int32 y = 0; y < SizeY; ++y) { + float YOffset = YBase + (100.f * y); + ULevelGridSlot* ThisSlot = CreateDefaultSubobject(*FString::Printf(TEXT("GridSlot %i"), Count)); + UStaticMeshComponent* PreviewMesh = CreateDefaultSubobject(*FString::Printf(TEXT("PreviewMesh %i"), Count)); + ThisSlot->Index = Count; + ThisSlot->SetupAttachment(RootComponent); + ThisSlot->EditorScale = 0.25f; + ThisSlot->SetRelativeLocation(FVector(XOffset, YOffset, ZOffset)); + PreviewMesh->SetRelativeLocation(FVector(XOffset, YOffset, ZOffset)); + Slots.Add(ThisSlot); + PreviewMeshes.Add(PreviewMesh); + Count++; + } + } + } +} + +// Preview elements --- Go through all of the slots and if given slot has any class chosen, and that class has any static mesh, set corresponding PreviewMesh to display that mesh. +void ALevelChunk::PreviewElements() { + for (ULevelGridSlot* Slot : Slots) { + if (IsValid(Slot)) { + + UClass* Class = Slot->ResolveClass(); + if (IsValid(Class)) { + + ASpawnableElement* DefaultObject = Cast(Class->GetDefaultObject()); + if (IsValid(DefaultObject->StaticMesh)) { + PreviewMeshes[Slot->Index]->SetStaticMesh(DefaultObject->StaticMesh->GetStaticMesh()); + } + } + } + } +} + +// Set all PreviewMeshes to nullptr +void ALevelChunk::HidePreview() { + int32 Count = 0; + for (UStaticMeshComponent* PreviewMesh : PreviewMeshes) { + if (IsValid(PreviewMesh)) { + + PreviewMesh->SetStaticMesh(nullptr); + } + Count++; + } +} + +void ALevelChunk::CleanupComponents() { + for (UStaticMeshComponent* PreviewMesh : PreviewMeshes) { + PreviewMesh->UnregisterComponent(); + } + PreviewMeshes.Empty(); +} \ No newline at end of file diff --git a/Source/UE5_GridTool/LevelChunk.h b/Source/UE5_GridTool/LevelChunk.h new file mode 100644 index 0000000..99289dc --- /dev/null +++ b/Source/UE5_GridTool/LevelChunk.h @@ -0,0 +1,55 @@ +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/Actor.h" +#include "LevelGridSlot.h" +#include "Components/SceneComponent.h" +#include "Components/StaticMeshComponent.h" +#include "SpawnableElement.h" +#include "LevelChunk.generated.h" + +UCLASS() +class UE5_GRIDTOOL_API ALevelChunk : public AActor +{ + GENERATED_BODY() + +public: + ALevelChunk(); + + // --- Variables + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Actor Setup") + int32 SizeX = 6; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Actor Setup") + int32 SizeY = 6; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Actor Setup") + int32 SizeZ = 4; + + UPROPERTY(BlueprintReadWrite, EditDefaultsOnly) + TArray Slots; + + UPROPERTY() + TArray PreviewMeshes; + + // --- Functions + + // Remove preview elements + UFUNCTION(BlueprintCallable, CallInEditor, Category = "Actor Methods") + void HidePreview(); + + // Temporarily spawn each element in this chunk + UFUNCTION(BlueprintCallable, CallInEditor, Category = "Actor Methods") + void PreviewElements(); + +private: + void BeginPlay() override; + + UFUNCTION() + void SetupGrid(); + + UFUNCTION() + void CleanupComponents(); + +}; diff --git a/Source/UE5_GridTool/LevelGridSlot.cpp b/Source/UE5_GridTool/LevelGridSlot.cpp new file mode 100644 index 0000000..a642fed --- /dev/null +++ b/Source/UE5_GridTool/LevelGridSlot.cpp @@ -0,0 +1,37 @@ +#include "LevelGridSlot.h" + +// Sets default values for this component's properties +ULevelGridSlot::ULevelGridSlot() +{ + PrimaryComponentTick.bCanEverTick = false; +} + +// Called when the game starts +void ULevelGridSlot::BeginPlay() +{ + Super::BeginPlay(); + Spawn(); +} + +UClass* ULevelGridSlot::ResolveClass() { + UClass* Class = nullptr; + if (!Object.IsNull()) { + if (!Object.IsValid()) { + Class = Object.LoadSynchronous(); + } + else { + Class = Object.Get(); + } + } + return Class; +} + +void ULevelGridSlot::Spawn() { + UClass* Class = ResolveClass(); + + if (IsValid(Class)) { + FActorSpawnParameters SpawnParams; + GetWorld()->SpawnActor(Class, this->GetComponentLocation(), this->GetComponentRotation(), SpawnParams); + } + this->DestroyComponent(); +} \ No newline at end of file diff --git a/Source/UE5_GridTool/LevelGridSlot.h b/Source/UE5_GridTool/LevelGridSlot.h new file mode 100644 index 0000000..9eebf55 --- /dev/null +++ b/Source/UE5_GridTool/LevelGridSlot.h @@ -0,0 +1,36 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "SpawnableElement.h" +#include "Components/BillboardComponent.h" +#include "LevelGridSlot.generated.h" + + +UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +class UE5_GRIDTOOL_API ULevelGridSlot : public UBillboardComponent +{ + GENERATED_BODY() + +public: + // Sets default values for this component's properties + ULevelGridSlot(); + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Actor Setup") + TSoftClassPtr Object; + + UPROPERTY() + int32 Index; + + UFUNCTION() + UClass* ResolveClass(); + +protected: + // Called when the game starts + virtual void BeginPlay() override; + +private: + UFUNCTION() + void Spawn(); +}; diff --git a/Source/UE5_GridTool/SpawnableElement.cpp b/Source/UE5_GridTool/SpawnableElement.cpp new file mode 100644 index 0000000..1cb7ec6 --- /dev/null +++ b/Source/UE5_GridTool/SpawnableElement.cpp @@ -0,0 +1,7 @@ +#include "SpawnableElement.h" + +ASpawnableElement::ASpawnableElement() +{ + PrimaryActorTick.bCanEverTick = false; + StaticMesh = CreateDefaultSubobject(TEXT("StaticMesh")); +} \ No newline at end of file diff --git a/Source/UE5_GridTool/SpawnableElement.h b/Source/UE5_GridTool/SpawnableElement.h new file mode 100644 index 0000000..b00a1ab --- /dev/null +++ b/Source/UE5_GridTool/SpawnableElement.h @@ -0,0 +1,21 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/Actor.h" +#include "Components/StaticMeshComponent.h" +#include "SpawnableElement.generated.h" + +UCLASS() +class UE5_GRIDTOOL_API ASpawnableElement : public AActor +{ + GENERATED_BODY() + +public: + // Sets default values for this actor's properties + ASpawnableElement(); + + UPROPERTY(EditAnywhere, BlueprintReadOnly) + UStaticMeshComponent* StaticMesh; +}; diff --git a/Source/UE5_GridTool/UE5_GridTool.Build.cs b/Source/UE5_GridTool/UE5_GridTool.Build.cs new file mode 100644 index 0000000..401019f --- /dev/null +++ b/Source/UE5_GridTool/UE5_GridTool.Build.cs @@ -0,0 +1,23 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +using UnrealBuildTool; + +public class UE5_GridTool : ModuleRules +{ + public UE5_GridTool(ReadOnlyTargetRules Target) : base(Target) + { + PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; + + PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" }); + + PrivateDependencyModuleNames.AddRange(new string[] { }); + + // Uncomment if you are using Slate UI + // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" }); + + // Uncomment if you are using online features + // PrivateDependencyModuleNames.Add("OnlineSubsystem"); + + // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true + } +} diff --git a/Source/UE5_GridTool/UE5_GridTool.cpp b/Source/UE5_GridTool/UE5_GridTool.cpp new file mode 100644 index 0000000..971579b --- /dev/null +++ b/Source/UE5_GridTool/UE5_GridTool.cpp @@ -0,0 +1,6 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#include "UE5_GridTool.h" +#include "Modules/ModuleManager.h" + +IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, UE5_GridTool, "UE5_GridTool" ); diff --git a/Source/UE5_GridTool/UE5_GridTool.h b/Source/UE5_GridTool/UE5_GridTool.h new file mode 100644 index 0000000..677c8e2 --- /dev/null +++ b/Source/UE5_GridTool/UE5_GridTool.h @@ -0,0 +1,6 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#pragma once + +#include "CoreMinimal.h" + diff --git a/Source/UE5_GridTool/UE5_GridToolGameModeBase.cpp b/Source/UE5_GridTool/UE5_GridToolGameModeBase.cpp new file mode 100644 index 0000000..ac42876 --- /dev/null +++ b/Source/UE5_GridTool/UE5_GridToolGameModeBase.cpp @@ -0,0 +1,5 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + + +#include "UE5_GridToolGameModeBase.h" + diff --git a/Source/UE5_GridTool/UE5_GridToolGameModeBase.h b/Source/UE5_GridTool/UE5_GridToolGameModeBase.h new file mode 100644 index 0000000..763a155 --- /dev/null +++ b/Source/UE5_GridTool/UE5_GridToolGameModeBase.h @@ -0,0 +1,17 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/GameModeBase.h" +#include "UE5_GridToolGameModeBase.generated.h" + +/** + * + */ +UCLASS() +class UE5_GRIDTOOL_API AUE5_GridToolGameModeBase : public AGameModeBase +{ + GENERATED_BODY() + +}; diff --git a/Source/UE5_GridToolEditor.Target.cs b/Source/UE5_GridToolEditor.Target.cs new file mode 100644 index 0000000..8bf8900 --- /dev/null +++ b/Source/UE5_GridToolEditor.Target.cs @@ -0,0 +1,15 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +using UnrealBuildTool; +using System.Collections.Generic; + +public class UE5_GridToolEditorTarget : TargetRules +{ + public UE5_GridToolEditorTarget( TargetInfo Target) : base(Target) + { + Type = TargetType.Editor; + DefaultBuildSettings = BuildSettingsVersion.V2; + IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_1; + ExtraModuleNames.Add("UE5_GridTool"); + } +} diff --git a/UE5_GridTool.uproject b/UE5_GridTool.uproject new file mode 100644 index 0000000..22bc685 --- /dev/null +++ b/UE5_GridTool.uproject @@ -0,0 +1,25 @@ +{ + "FileVersion": 3, + "EngineAssociation": "5.1", + "Category": "", + "Description": "", + "Modules": [ + { + "Name": "UE5_GridTool", + "Type": "Runtime", + "LoadingPhase": "Default", + "AdditionalDependencies": [ + "Engine" + ] + } + ], + "Plugins": [ + { + "Name": "ModelingToolsEditorMode", + "Enabled": true, + "TargetAllowList": [ + "Editor" + ] + } + ] +} \ No newline at end of file