2025-10-15 18:25:31 +08:00

70 lines
1.6 KiB
C++

// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/DataAsset.h"
#include "ShapeAsset.generated.h"
USTRUCT(BlueprintType)
struct FShapeSlot
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 X;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 Y;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsActive;
FShapeSlot()
{
X = 0;
Y = 0;
bIsActive = false;
}
FShapeSlot(int32 InX, int32 InY, bool InIsActive)
{
X = InX;
Y = InY;
bIsActive = InIsActive;
}
};
/**
*
*/
UCLASS(BlueprintType)
class PROJECTFISH_API UShapeAsset : public UDataAsset
{
GENERATED_BODY()
public:
UShapeAsset();
UFUNCTION(BlueprintCallable, Category="Shape")
void InitializeShape();
UFUNCTION(BlueprintPure, Category="Shape")
int32 GetShapeWidth() { return ShapeWidth; }
UFUNCTION(BlueprintPure, Category="Shape")
int32 GetShapeHeight() { return ShapeHeight; }
UFUNCTION(Blueprintable, BlueprintPure, Category="Shape")
bool IsSlotActive(int32 X, int32 Y) const;
UFUNCTION(Blueprintable, Category="Shape")
void SetSlotActive(int32 X, int32 Y, bool Active);
private:
int32 FIndSlotIndex(int32 X, int32 Y) const;
public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Shape", meta = (ClampMin = "1", ClampMax = "10"))
int32 ShapeWidth;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Shape", meta = (ClampMin = "1", ClampMax = "10"))
int32 ShapeHeight;
//存储格子状态
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Shape")
TArray<FShapeSlot> Slots;
};