80 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			80 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| #pragma once
 | |
| #include "Engine/DataTable.h"
 | |
| #include "Level/Map/Components/TerrainLayerComponent.h"
 | |
| #include "Level/Map/Components/StaticResourceLayerComponent.h"
 | |
| #include "GameMapActor.generated.h"
 | |
| 
 | |
| 
 | |
| DECLARE_LOG_CATEGORY_EXTERN(LogMapGenerate, Log, All);
 | |
| 
 | |
| UINTERFACE()
 | |
| class UGameMapInterface : public UInterface
 | |
| {
 | |
| 	GENERATED_BODY()
 | |
| };
 | |
| 
 | |
| class IGameMapInterface
 | |
| {
 | |
| 	GENERATED_BODY()
 | |
| public:
 | |
| 	UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
 | |
| 	void GetMapSize(float &OutX, float &OutY);
 | |
| 
 | |
| 	UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
 | |
| 	float GetMapFieldSize();
 | |
| 	
 | |
| 	UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
 | |
| 	FGameplayTag GetTerrainAt(const float X, const float Y);
 | |
| };
 | |
| 
 | |
| 
 | |
| 
 | |
| UCLASS(Blueprintable, Blueprintable)
 | |
| class AGameMapActor : public AActor, public IGameMapInterface
 | |
| {
 | |
| 	GENERATED_BODY()
 | |
| public:
 | |
| 	AGameMapActor();
 | |
| 
 | |
| public:
 | |
| 	virtual void GetMapSize_Implementation(float& OutWidth, float& OutHeight) override;
 | |
| 	virtual FGameplayTag GetTerrainAt_Implementation(const float X, const float Y) override;
 | |
| 	virtual float GetMapFieldSize_Implementation() override;
 | |
| 
 | |
| public:
 | |
| 	virtual void BeginPlay() override;
 | |
| 
 | |
| 	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
 | |
| 
 | |
| 
 | |
| public:
 | |
| 	UFUNCTION(BlueprintCallable)
 | |
| 	const UTerrainLayerComponent* GetTerrainLayer() const
 | |
| 	{
 | |
| 		return TerrainLayer;
 | |
| 	}
 | |
| 
 | |
| 
 | |
| 
 | |
| protected:
 | |
| 	UPROPERTY(EditAnywhere, BlueprintReadOnly)
 | |
| 	float MapWidth = 32;
 | |
| 	UPROPERTY(EditAnywhere, BlueprintReadOnly)
 | |
| 	float MapHeight = 32;
 | |
| 	UPROPERTY(EditAnywhere, BlueprintReadOnly)
 | |
| 	float MapFieldSize = 128;
 | |
| 
 | |
| 	
 | |
| 	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
 | |
| 	TObjectPtr<UTerrainLayerComponent> TerrainLayer;
 | |
| 
 | |
| 	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
 | |
| 	TObjectPtr<class UStaticResourceLayerComponent> ResourceLayer;
 | |
| 
 | |
| 	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
 | |
| 	TObjectPtr<class USceneComponent> SceneComp;
 | |
| 
 | |
| 
 | |
| };
 | |
| 
 |