Files
Tactica/Source/Tactica/Public/GridCell.h
T

62 lines
1.6 KiB
C++

#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "GridCell.generated.h"
class UStaticMeshComponent;
class UMaterialInstanceDynamic;
UCLASS()
class TACTICA_API AGridCell : public AActor
{
GENERATED_BODY()
public:
AGridCell();
// マスの見た目(板状の立方体)
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Grid")
TObjectPtr<UStaticMeshComponent> MeshComponent;
// グリッド上の座標 (X, Y)
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Grid")
FIntPoint GridCoord = FIntPoint::ZeroValue;
// 高さ(階層)
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Grid")
int32 Height = 0;
// 歩行可能か
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Grid")
bool bIsWalkable = true;
// 通常時の色
UPROPERTY(EditAnywhere, Category = "Grid|Highlight")
FLinearColor NormalColor = FLinearColor(0.15f, 0.15f, 0.15f);
// ホバー時の色
UPROPERTY(EditAnywhere, Category = "Grid|Highlight")
FLinearColor HoverColor = FLinearColor(1.0f, 0.8f, 0.1f);
// 選択時の色
UPROPERTY(EditAnywhere, Category = "Grid|Highlight")
FLinearColor SelectedColor = FLinearColor(0.1f, 0.6f, 1.0f);
void SetHovered(bool bInHovered);
void SetSelected(bool bInSelected);
protected:
virtual void BeginPlay() override;
private:
// 状態から色を決めて反映する(優先順位: 選択 > ホバー > 通常)
void RefreshColor();
bool bHovered = false;
bool bSelected = false;
// 色変更用のダイナミックマテリアル
UPROPERTY()
TObjectPtr<UMaterialInstanceDynamic> DynamicMaterial;
};